Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: -fstrict-calling-conventions

The compiler used to build Illumos needs to have several features not present in mainline GCC, and several other properties which GCC otherwise lacks.

Below is an attempt to sketch out

  • What these changes are
  • Why they are desirable
  • Into which versions of GCC they must be patched

The majority of these changes were made by Codesourcery LLC under contract to Sun Microsystems, further changes were made by Sun itself.

Changes applicable to code generation

The following options affect code generation, and are not in any upstream version of GCC (they're not particularly useful in the general sense).

amd64 -msave-args

The amd64 ABI states that the first 6 integer-sized arguments are passed in registers, with the rest spilled to the stack. This makes it particularly difficult to find arguments without fairly full debugger support for something like DWARF (which would have its own complications).

Instead of this, GCC was modified to push the register-passed arguments onto the stack at the frame pointer (before the callee-saved registers) in the function prologue, and mdb was modified such that, when debugging the kernel (why this was not done for userland is unknown) we pattern-match the instruction prologue attempting to discover this modified prologue, and, if we discover it, we pull the arguments from there.

Without these changes, getting at function arguments from mdb is incredibly tedious and context specific (and is not guaranteed to be possible).

-mno-integer-ldd-std

The SPARC specification states that the memory operands of ldd and std must be 8-byte aligned. GCC generates code that uses ldd and std to load and store 64bit integers, presuming them to be suitably aligned as the ABI requires this. Some of our code does not align 64bit integers to the ABI requirement and thus requires that all integers be stored/loaded with pairs of st orld instructions instead. This option causes that to happen, similar to Sun C's -xmemalign=4

-massume-32bit-callers

Direct system calls on SPARC systems pass the first 6 word-sized arguments in registers, according to the normal ABI calling conventions.  Thus, when a 32bit process makes a system call to a 64bit kernel, negative arguments are twos complement in the width of the 32bit v7 register, not the 64bit v9 register the kernel sees.  This, in effect, makes any integer argument from a 32bit process implicitly signed.  This option causes GCC to emit code which does any promotion of function arguments in the callee rather than the caller, to account for this and allow direct 32bit calls to continue to function (at the cost of some pessimization).  This is also how Studio, and GCC prior to 4.2 would have generated the code.

Changes to DWARF

-fno-dwarf2-indirect-strings

The CTF convertion tools (source:usr/src/tools/ctf) have very minimal relocation processing, DWARF2 indirect strings may require relocation before being usefully accessible, rather than doing that, we disable their generation (newer libdwarf most likely obviates any need for this).

General changes

-nolibgcc

We don't want many (any, really) of our system utilities to link with libgcc. This flag prevents them doing so.

Support for cmn_err format specifiers

cmn_err(9F) has a variety of format specifiers not present in the normal printf family of functions, we'd like format-string checking of them.

#pragma redefine_extname should itself be macro expanded

We use #pragma redefine_extname with parameters which are themselves pre-processor macro expansions, GCC needs to be told that macro expansion should be performed.

We expect #pragma weak to be applied regardless of scoping

This change appears to be present upstream in recent GCC.

We expect warnings about casts between pointers and differently sized integers

Casting between pointers and integers not matching in size and signedness is dangerous (for obvious reasons in the case of truncation, due to the potential for sign-extension in the case of extension).

This option is now upstream in recent GCC.

-fno-jump-tables

We need an option to prevent the compiler generating jump tables for switch statements, regardless of whether the optimizer feels they would be beneficial. This is necessary for PIC code forming part of the runtime linker, unable to reference the address of a jump table.

It also has beneficial effects for DTrace, which must punt when encountering jump tables. (as it can no longer be truly certain of what is code and what is data).

This option is now upstream in recent GCC.

-fno-constant-pools

Do place constant data other than user-defined 'const' constants into read-only pools. Necessary for PIC code forming part of the runtime linker, which cannot reference their address.

This option is now upstream in recent GCC.

RUNPATH changes

We amend the default RUNPATH by passing -R to the link editors, inserting as well as the default library directories (/lib:/usr/lib) our own install location (/usr/sfw/lib) into the RUNPATH, to ensure that software we build will find libgcc and/or libstdc++ at runtime.

Allow #pragma align to be used after a variable is declared

GCC mandates that #pragma align precede any declaration, Sun C does not. It is easier to make the compilers agree on semantics.

Parameters to #pragma align need to be macro expanded

GCC does not macro-expand #pragma align, Sun C does. It is easier to make the compilers agree on semantics.

Support for #pragma align, #pragma init, #pragma fini

GCC does not support these pragmas, of which we make somewhat heavy use. They need to be implemented

(These are, I believe, all upstream in recent GCC, though the above tweaks to their behaviour may not be).

In the case of the GCC 3.4.3 currently used to build illumos, Support for Solaris 2.10 and above

This is, obviously, upstream in newer GCC but at the time the GCC 3.4.3 was put together, Solaris 10 had not yet been released, and these changes were bespoke.