Unterschiede bei den Compileroptionen zwischen gcc und cc

gcc-3.1 und SUN Forte Developer 6 update 2


Eigentlich wollte ich nur ein paar Perl-Module installieren, aber dann habe ich die halbe Nacht mit dem Studium von C-Dokumentationen verbracht, denn die Hälfte der benötigten Module (z. B. Time::HiRes, Net::DNS, Digest::MD5 und MIME::Base64) versuchte den cc anzusprechen. Da mein begrenzter Plattenplatz eine Installation der Try+Buy-Version von Forte nicht mehr zulassen wollte, begann ich die Makefiles zu bearbeiten. Leider konnte ich nirgendwo eine Vergleichstabelle für die Compileroptionen ergoogeln.

Deswegen für alle C-Unkundigen, die demnächst vor ähnlichen Problemen stehen:

CC = gcc
CCCDLFLAGS = -fPIC
LD = gcc
LDDLFLAGS = -shared
OPTIMIZE = -O3 -funroll-loops

Wer bessere Vorschläge oder Ergänzungen hat, den bitte ich um Mail. Bei mir (SUN Blade 100, Solaris 8) sind die Pakete damit durchgelaufen.

cc

gcc

-KPIC

-fPIC

Generate position-independent code for use in shared libraries (large model). Equivalent to -xcode=pic32. Permits references to at most 2**30 unique external symbols on 32-bit architectures, 2**29 on 64-bit architectures. If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, m88k, and the Sparc.

-G

-shared

Passes the option to the link editor to produce a shared object rather than a dynamically linked executable. This option is passed to ld(1), and cannot be used with the -dn option. Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options that were used to generate code (-fpic, -fPIC, or model suboptions) when you specify this option.

-xO3

-O3

Performs like -xO2, but also optimizes references or definitions for external variables. Loop unrolling and software pipelining are also performed. This level does not trace the effects of pointer assignments. When compiling either device drivers, or programs that modify external variables from within signal handlers, you may need to use the volatile type qualifier to protect the object from optimization. In general, the -xO3 level results in increased code size.  

-xdepend

-funroll-loops

(SPARC) Analyzes loops for inter-iteration data dependencies and does loop restructuring. Loop restructuring includes loop interchange, loop fusion, scalar replacement, and elimination of "dead" array assignments. If optimization is not at -xO3 or higher, optimization is raised to -xO3 and a warning is issued. Dependency analysis is also included with -xautopar or -xparallel. The dependency analysis is done at compile time. Dependency analysis may help on single-processor systems. However, if you try -xdepend on single-processor systems, you should not use either -xautopar or -xexplicitpar. If either of them is on, then the -xdepend optimization is done for multiple-processor systems. Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies both -fstrength-reduce and -frerun-cse-after-loop. This option makes code larger, and may or may not make it run faster.



Thorsten Hahn
Kiel, 04.07.2002