PREV UP NEXT StackThreads/MP: version 0.77 User's Guide

7.1: STGCC/STG++: A wrapper for GCC

stgcc or stg++ are shell scripts that call gcc or g++, respectively. Below we say gcc to refer to both gcc and g++, and use stgcc to refer to both stgcc and stg++.

What it basically does is to intercept the compilation process that outputs object file just after gcc emits assembly, extract some information about stack frame formats of each procedure from, and put some tricky pieces of code at each procedure epilogue sequence.

stgcc is intended to be usable wherever gcc is used, unless a command line option fundamentally conflicts with what StackThreads/MP assumes. Most command line options are passed as is to gcc, but it must recognize some of the parameters that controls compilation. Certainly you do not have to know what it is exactly doing and you should not even have to learn anything, as long as you already know gcc.

What you have to know, however, is things that might conflict with your tricky way of using gcc. At present, stgcc does not produce any error even when a conflicting option is given. So, it is possible that even when a compilation succeeds, the resulting program is erroneous. We are trying to improve this in future. To be sure, give --show_commands option to stgcc, which displays invoked subcommands.

  1. A register is reserved for a OS-thread local storage and other must not be reserved. StackThreads/MP assumes that one register is reserved to access a thread-local storage (by -ffixed-REG in gcc). The reserved register is:

    Options are automatically specified by stgcc so you do not normally notice this. But if you want to reserve this register or another for your purpose, this is likely to be a problem. Contact me if you want to do this anyway.

  2. stgcc turns off inlining by giving -fno-inline-functions and -fno-default-inline to gcc. We assume that a procedure call written in ST_CREATE_THREAD(e) is translated into a procedure call in assembly level. In other words, e must not be inlined. This may severely hurt performance of some programs, but for now there are no ways to prohibit inlining of a particular call site or a particular function.

    You can instruct the compiler to explicitly inline some functions by giving inline directive before a procedure definition.

  3. stgcc gives -fno-omit-frame-pointer to gcc, so that each procedure keeps a separate frame pointer. Therefore giving -fomit-frame-pointer to stgcc conflicts with this. This has no performance effects on i386 and SPARC, but may have some on Mips and Alpha.
  4. On SPARC, stgcc turns off the use of register windows by giving -mflat to gcc. Hence giving -mno-flat to stgcc conflicts with this.

To summarize, the following options are prohibited in StackThreads/MP.

  1. -finline-functions, -fdefault-inline, -fomit-frame-pointer, and -ffixed-REG are prohibited on all CPUs
  2. -mno-flat is prohibited on SPARC

Here is the list of options supported by stgcc, in addition to all options supported by gcc.

Normally, stgcc defines STHREADS to 1. When --no_postprocess is given, stgcc does not define STHREADS but instead defines STHREADS_NOPP to 1.