GCC User Guide and GCC best compilation Parameters

Source: Internet
Author: User
Syntax:

GCC [Option | filename]...

G ++ [Option | filename]...

Where option is the option used for GCC (which will be detailed later ),

Filename is the object to be processed with GCC.

Note:

This C and C ++ compiler have integrated the related programs that generate new programs. Production

A new program requires four stages: preprocessing, compilation, assembly, and linking.

Compilers can process input files in different stages. Although the extension of the original program is

It is used to distinguish the language used to write the original program code, but different compiler, its preset Processing

Different programs:

Gcc

Preset files that have been preprocessed (with the extension. I) as C language, and

The connection phase is processed in C connection mode.

G ++

Preset files that have been pre-processed (with the extension. I) to C ++.

The sequential connection phase is processed in the C ++ connection mode.

The extension of the original code indicates the language used for programming and the corresponding

Management Method:

. C

C original program

; Preprocessing, compilation, assembly

. C

C ++ original program

; Preprocessing, compilation, assembly

. Cc c ++ original program

; Preprocessing, compilation, assembly

. Cxx C ++ original program

; Preprocessing, compilation, assembly

. M

Objective-C original program

; Preprocessing, compilation, assembly

. I

Original C program that has been preprocessed

; Compilation and assembly

. II Original C ++ program that has been preprocessed; compilation and assembly

. S

Original assembly language program

; Assembly

. S

Original assembly language program

; Preprocessing and assembly

. H

Preprocessing file (header file)

; (Not often in the command line)

Files with other extensions are processed by the link program, usually including:

. O

Object File

.

Archive file

Unless an error occurs during the compilation process, the "Link" must be the most

Later Stage. However, you can also set the entire process from

Phase. In the connection phase, all

. O files, libraries, and other files that cannot identify attributes from the file name (including files that do not use. o

Object file with the extension and archive file with the extension.)

It is handled by the link program (the files in the command line are passed as parameters of the link Program

Link program ).

Option:

Different options must be separated. For example, the '-write' option is larger than the'-D-R' option.

Different.

Most of the '-F' and'-W' options have two forms:-fname and

-Fno-Name (or-wname and-wno-name ). Only the non-preset ones are listed below

Format.

The following is a summary of all options. In the form. The meaning of the option will be explained in another section.

Ming.

General (rough, common) Options

-C-s-e-o file-pipe-v-x Language

Program language options

-ANSI-fall-Virtual-fcond-Mismatch

-Fdollars-in-identifiers-fenum-int-equiv

-Fexternal-templates-fno-ASM-fno-builtin

-Fno-strict-prototype-fsigned-bitfields

-Fsigned-Char-fthis-is-Variable

-Funsigned-bitfields-funsigned-Char

-Fwritable-strings-traditional-CPP

-Trigraphs

Warning options during compilation

-Fsyntax-only-pedantic-errors-w

-Wall-waggregate-return-wcast-align-wcast-Qual

-Wchar-subscript-wcomment-wconversion

-Wenum-clash-werror-wformat-wid-clash-Len

-Wimplicit-winline-wmissing-prototypes

-Wmissing-declarations-wnested-externs-wno-Import

-Wparentheses-wpointer-Arith-wredundant-decls

-Wreturn-type-wshadow-wstrict-prototypes-wswitch

-Wtemplate-debugging-wtraditional-wtrigraphs

-Wuninitialized-wunused-wwrite-strings

Debugging options

-A-dletters-fpretend-float-g-glevel-gcoff

-Gxcoff +-gdwarf +-gstabs +

-Ggdb-p-PG-save-temps-print-file-name = library

-Print-libgcc-file-name-print-prog-name = Program

Optimization Options

-Fcaller-saves-fcse-Follow-Jumps-fcse-Skip-Blocks

-Fdelayed-branch-felide-constructors

-Fexpensive-optimizations-ffast-math-ffloat-store

-Fforce-ADDR-Fforce-Mem-Finline-Functions

-Fkeep-inline-functions-fmemoize-lookups

-Fno-default-inline-fno-defer-pop

-Fno-function-CSE-fno-inline-fno-peephole

-Fomit-frame-pointer-frerun-CSE-after-Loop

-Fschedule-insns-fschedule-insns2

-Fstrength-reduce-fthread-Jumps-funroll-all-Loops

-Funroll-loops-o-O2

Preprocessing options

-Aassertion-C-dd-DM-DN-dmacro [= defn]-e-H

-Idirafter Dir-include file-imacros file-iprefix

File-iwithprefix Dir-m-MD-mm-MMD-nostdinc-P

-Umacro-UNDEF

Assembler options

-Wa, Option

Link Program Options

-Llibrary-nostartfiles-nostdlib-static-shared

-Symbolic-xlinker option-wl, option-u symbol

DIRECTORY Options

-Bprefix-Idir-I-ldir

Target options

-B machine-V version

Machine (Platform) related options

M680x0 options

-M68000-m68020-m68020-40-m68030-m68040-m68881

-Mbitfield-mc68000-mc68020-MFPA-mnobitfield

-MRTD-mshort-msoft-float

VAX options

-Mg-mgnu-munix

Iscsi options

-Mepilogue-mfpu-mhard-float-MnO-FPU

-MnO-epilogue-msoft-float-msparclite-mv8

-Msupernames-mcypress

Convex options

-Margcount-mc1-MC2-mnoargcount

Amd29k options

-M29000-m29050-MBW-MDW-mkernel-registers

-Mlarge-mnbw-mnodw-msmall-mstack-Check

-Muser-registers

M88k options

-M88000-m88100-m88110-mbig-pic

-Mcheck-Zero-division-mhandle-large-shift

-Midentify-revision-MnO-check-Zero-Division

-MnO-OCs-debug-Info-MnO-OCs-frame-Position

-MnO-optimize-Arg-area-MnO-serialize-volatile

-MnO-underscores-mocs-debug-Info

-Mocs-frame-position-moptimize-Arg-Area

-Mserialize-volatile-mshort-data-num-msvr3-msvr4

-Mtrap-large-shift-muse-div-Instruction

-Mversion-03.00-mwarn-passed-structs

Rs6000 options

-MFP-in-toc-MnO-fop-in-TOC

RT options

-MCALL-Lib-Mul-MFP-Arg-in-fpregs-MFP-Arg-in-Gregs

-Mfull-FP-blocks-mhc-struct-return-Min-line-Mul

-Mminimum-FP-blocks-mnohc-struct-return

MIPs options

-Mcpu = CPU type-mips2-mips3-mint64-mlong64

-Mlonglong128-mmips-as-MGAs-mrnames-MnO-rnames

-Mgpopt-MnO-gpopt-mstats-MnO-stats-mmemcpy

-MnO-memcpy-MnO-MIPS-tfile-mmips-tfile

-Msoft-float-mhard-float-mabicils-MnO-abicils

-Mhalf-pic-MnO-half-pic-G num-nocpp

I386 options

-Mbench-mno-486-msoft-float-mno-fp-ret-in-387

Hppa options

-Mpa-risc-1-0-mpa-risc-1-1-mkernel-mshared-libs

-MnO-shared-libs-mlong-CILS-mdisable-fpregs

-Mdisable-indexing-mtrailing-colon

I960 options

-Mcpu-type-mnumerics-msoft-float

-Mleaf-procedures-MnO-leaf-procedures-mtail-call

-MnO-tail-call-mcomplex-ADDR-MnO-complex-ADDR

-Mcode-align-MnO-code-align-mic-compat

-Mic2.0-compat-mic3.0-compat-MASM-compat

-Mintel-ASM-mstrict-align-MnO-strict-align

-Mold-align-MnO-old-align

DEC Alpha options

-MFP-regs-MnO-FP-regs-MnO-soft-float-msoft-float

System V Options

-G-QY-Qn-YP, paths-ym, Dir

Code Generation Options

-Fcall-saved-reg-fcall-used-reg-ffixed-Reg

-Finhibit-size-Directive-fnonnull-objects

-Fno-common-fno-Ident-fno-GNU-linker

-Fpcc-struct-return-FPIC

-Freg-struct-returno-fshared-data-fshort-enums

-Fshort-double-fvolatile-Global

-Fverbose-ASM

Pragmas

Two '# pragma' ctictives are supported for gnu c ++,

Permit using the same header file for two purposes: As

Definition of interfaces to a given object class, And

The full definition of the contents of that object class.

# Pragma Interface

(C ++ only.) use this directive in header files

That define object classes, to save space in most

Of the object files that use those classes. Nor-

Mally, local copies of certain information (Backup

Copies of inline member functions, debugging infor-

Mation, and the internal tables that implement vir-

Tual functions) must be kept in each object file

That includes des class definitions. You can use this

Pragma to avoid such duplication. When a header

File ining '# pragma interface' is supported in

A compilation, this auxiliary information will not

Be generated (unless the main input source file it-

Self uses '# pragma implementation'). Instead,

Object files will contain in references to be resolved

At link time.

# Pragma implementation

# Pragma implementation "objects. H"

(C ++ only.) Use This pragma in a main input file,

When you want full output from included Header

Files to be generated (and made globally visible ).

The encoded header file, in turn, shocould use

'# Pragma interface'. backup copies of inline mem-

Ber functions, debugging information, and the in-

Ternal tables used to implement virtual functions

Are all generated in implementation files.

If you use '# pragma implementation' with no argu-

Ment, it applies to an include file with the same

Basename as your source file; for example, in

'Allclass. CC', '# pragma implementation' by itself

Is equivalent

To

'# Pragma

Implementation

"Allclass. H" '. Use the string argument if you want

A single implementation file to include code from

Multiple header files.

There is no way to split up the contents of a sin-

GLE header file into multiple implementation files.

File description

File. c

C source file

File. h

C header (Preprocessor) File

File. I

Pre-processed C source file

File. c

C ++ source file

File. CC

C ++ source file

File. cxx

C ++ source file

File. m

Objective-C source file

File. s

Assembly Language file

File. o

Object File

A. Out

Link edited output

Tmpdir/CC *

Temporary Files

Libdir/CPP

Preprocessor

Libdir/PC3

Compiler for C

Libdir/cc1plus

Compiler for C ++

Libdir/collect

Linker front end needed on some machines

Libdir/libgcc.

GCC subroutine library

/Lib/CRT [01n]. o

Start-up routine

Libdir/ccrt0

Additional start-up routine for C ++

/Lib/libc.

Standard C library, see man page intro (3)

/Usr/include

Standard Directory for # include files

Libdir/include

Standard GCC directory for # include files

Libdir/g ++-include additional g ++ directory for # include

Libdir is usually/usr/local/lib/machine/version.

Tmpdir comes from the environment variable tmpdir (default

/Usr/tmp if available, else/tmp ).

GCC best compilation Parameters

Summary

This article focuses on the parameters specified for GCC in different hardware environments for optimal performance.

This article is separated from a programming instruction manual named Gentoo Linux, which is helpful for compiling programs.

--------------------------------------------------------------------------------

I. version 1.2 (GCC 2.9.x)

I386 (Intel), do you really want to install Gentoo on that? Chost = "i386-pc-linux-gnu" cflags = "-March = i386-O3-pipe-fomit-frame-pointer" cxxflags = "-March = i386-O3-pipe-fomit-frame-pointer"

Isung (Intel), do you really want to install Gentoo on that? Chost = "i486-pc-linux-gnu" cflags = "-March = isung-O3-pipe-fomit-frame-pointer" cxxflags = "-March = isung-O3-pipe-fomit-frame-pointer"

Pentium, Pentium MMX +, celeon (Mendocino) (Intel) chost = "i586-pc-linux-gnu" cflags = "-March = Pentium-O3-pipe-fomit-frame-pointer" cxxflags = "-March = Pentium-O3-pipe-fomit-frame-pointer"

Pentium Pro/II/III/4, celon (Coppermine), celon (Willamette ?) (Intel) chost = "i686-pc-linux-gnu" cflags = "-March = i686-O3-pipe-fomit-frame-pointer" cxxflags = "-March = i686-O3-pipe-fomit-frame-pointer"

Eden C3/Ezra () chost = "i586-pc-linux-gnu" cflags = "-March = i586-O3-pipe-fomit-frame-pointer" cxxflags = "-March = i586-O3-pipe-fomit-frame-pointer"

Quote: I did the original Gentoo install using 1.2, with GCC 2.95 using-March = i586. i686 won't work.

K6 or beyond (AMD) chost = "i586-pc-linux-gnu" cflags = "-March = K6-O3-pipe-fomit-frame-pointer" cxxflags = "-March = K6-O3-pipe-fomit-frame-pointer"

(A duron will report "athlon" in its/proc/cpuinfo)

Athlon (AMD) chost = "i686-pc-linux-gnu" cflags = "-March = K6-O3-pipe-fomit-frame-pointer" cxxflags = "-March = K6-O3-pipe-fomit-frame-pointer"

For the following, I don't know of any flag that enhance has ces..., do you?

PowerPC chost = "PowerPC-unknown-Linux-GNU" cflags = "-O3-pipe-fomit-frame-pointer" cxxflags = "-O3-pipe-fomit-frame-pointer"

Iscsi chost = "iSCSI-unknown-Linux-GNU" cflags = "-O3-pipe-fomit-frame-pointer" cxxflags = "-O3-pipe-fomit-frame-pointer"

64 chost = "sparc64-unknown-linux-gnu" cflags = "-O3-pipe-fomit-frame-pointer" cxxflags = "-O3-pipe-fomit-frame-pointer"

Ii. Version 1.4 (GCC 3.x ):

I386 (Intel), do you really want to install Gentoo on that? Chost = "i386-pc-linux-gnu" cflags = "-March = i386-O3-pipe-fomit-frame-pointer" cxxflags = "-March = i386-O3-pipe-fomit-frame-pointer"

Isung (Intel), do you really want to install Gentoo on that? Chost = "i486-pc-linux-gnu" cflags = "-March = isung-O3-pipe-fomit-frame-pointer" cxxflags = "-March = isung-O3-pipe-fomit-frame-pointer"

Pentium 1 (Intel) chost = "i586-pc-linux-gnu" cflags = "-March = Pentium-O3-pipe-fomit-frame-pointer" cxxflags = "-March = Pentium-O3-pipe-fomit-frame-pointer"

Pentium MMX (Intel) chost = "i586-pc-linux-gnu" cflags = "-March = Pentium-MMX-O3-pipe-fomit-frame-pointer" cxxflags = "-March = Pentium-MMX-O3-pipe-fomit -Frame-pointer"

Pentium Pro (Intel) chost = "i686-pc-linux-gnu" cflags = "-March = pentiumpro-O3-pipe-fomit-frame-pointer" cxxflags = "-March = pentiumpro-O3-pipe-fomit-frame-pointer"

Pentium II (Intel) chost = "i686-pc-linux-gnu" cflags = "-March = pentium2-O3-pipe-fomit-frame-pointer" cxxflags = "-March = pentium2-O3-pipe-fomit-frame-pointer"

Celon (Mendocino), aka celeron1 (Intel) chost = "i686-pc-linux-gnu" cflags = "-March = pentium2-O3-pipe-fomit-frame-pointer" cxxflags = "-March = pentium2-O3-pipe-fomit-frame-pointer"

Pentium III (Intel) chost = "i686-pc-linux-gnu" cflags = "-March = pentium3-O3-pipe-fomit-frame-pointer" cxxflags = "-March = pentium3-O3-pipe-fomit-frame-pointer"

Celon (Coppermine) AKA celeron2 (Intel) chost = "i686-pc-linux-gnu" cflags = "-March = pentium3-O3-pipe-fomit-frame-pointer" cxxflags = "-March = pentium3-O3-pipe-fomit-frame-pointer"

Celon (Willamette ?) (Intel) chost = "i686-pc-linux-gnu" cflags = "-March = pentium4-O3-pipe-fomit-frame-pointer" cxxflags = "-March = pentium4-O3-pipe-fomit-frame-pointer"

Pentium 4 (Intel) chost = "i686-pc-linux-gnu" cflags = "-March = pentium4-O3-pipe-fomit-frame-pointer" cxxflags = "-March = pentium4-O3-pipe-fomit-frame-pointer"

Eden C3/Ezra () chost = "i586-pc-linux-gnu" cflags = "-March = i586-m3dnow-O3-pipe-fomit-frame-pointer" cxxflags = "-March = i586-m3dnow-O3-pipe-fomit -Frame-pointer"

Quote: The Ezra doesn't have any special instructions that you cocould optimize for, just consider is a K6-3... basically a P2 with 3 dnow

K6 (AMD) chost = "i586-pc-linux-gnu" cflags = "-March = K6-O3-pipe-fomit-frame-pointer" cxxflags = "-March = K6-O3-pipe-fomit-frame-pointer"

AMD (K6-2) chost = "i586-pc-linux-gnu" cflags = "-March = k6-2-O3-pipe-fomit-frame-pointer" cxxflags = "-March = k6-2-O3-pipe-fomit-frame-pointer"

AMD (K6-3) chost = "i586-pc-linux-gnu" cflags = "-March = k6-3-O3-pipe-fomit-frame-pointer" cxxflags = "-March = k6-3-O3-pipe-fomit-frame-pointer"

Athlon (AMD) chost = "i686-pc-linux-gnu" cflags = "-March = athlon-O3-pipe-fomit-frame-pointer" cxxflags = "-March = athlon-O3-pipe-fomit-frame-pointer"

Athlon-tbird, aka K7 (AMD) chost = "i686-pc-linux-gnu" cflags = "-March = athlon-tbird-O3-pipe-fomit-frame-pointer" cxxflags = "-March = athlon-tbird-O3-pipe-fomit -Frame-pointer"

Athlon-tbird XP (AMD) chost = "i686-pc-linux-gnu" cflags = "-March = athlon-XP-O3-pipe-fomit-frame-pointer" cxxflags = "-March = athlon-XP-O3-pipe-fomit -Frame-pointer"

Athlon 4 (AMD) chost = "i686-pc-linux-gnu" cflags = "-March = athlon-4-O3-pipe-fomit-frame-pointer" cxxflags = "-March = athlon-4-O3-pipe-fomit-frame-pointer"

Athlon XP (AMD) chost = "i686-pc-linux-gnu" cflags = "-March = athlon-XP-O3-pipe-fomit-frame-pointer" cxxflags = "-March = athlon-XP-O3-pipe-fomit -Frame-pointer"

Athlon MP (AMD) chost = "i686-pc-linux-gnu" cflags = "-March = athlon-MP-O3-pipe-fomit-frame-pointer" cxxflags = "-March = athlon-MP-O3-pipe-fomit -Frame-pointer"

603 (PowerPC) chost = "PowerPC-unknown-Linux-GNU" cflags = "-O3-pipe-fomit-frame-pointer-fsigned-char" cxxflags = "-O3-pipe-fomit-Frame -pointer-fsigned-char"

603e (PowerPC) chost = "PowerPC-unknown-Linux-GNU" cflags = "-O3-pipe-fomit-frame-pointer-fsigned-char" cxxflags = "-O3-pipe-fomit-Frame -pointer-fsigned-char"

604 (PowerPC) chost = "PowerPC-unknown-Linux-GNU" cflags = "-O3-pipe-fomit-frame-pointer-fsigned-char" cxxflags = "-O3-pipe-fomit-Frame -pointer-fsigned-char"

604e (PowerPC) chost = "PowerPC-unknown-Linux-GNU" cflags = "-O3-pipe-fomit-frame-pointer-fsigned-char" cxxflags = "-O3-pipe-fomit-Frame -pointer-fsigned-char"

750 aka as G3 (PowerPC) chost = "PowerPC-unknown-Linux-GNU" cflags = "-mcpu = 750-O3-pipe-fomit-frame-pointer-fsigned-char" cxxflags = "-mcpu = 750 -O3-pipe-fomit-frame-pointer-fsigned-char"

Note: Do not use-March =

7400, aka G4 (PowerPC) chost = "PowerPC-unknown-Linux-GNU" cflags = "-mcpu = 7400-O3-pipe-fomit-frame-pointer-fsigned-Char-maltivec" cxxflags = "-mcpu = 7400-O3-pipe-fomit-frame-pointer-fsigned-Char-maltivec"

Note: Do not use-March =

7450, aka G4 second generation (PowerPC) chost = "PowerPC-unknown-Linux-GNU" cflags = "-mcpu = 7450-O3-pipe-fomit-frame-pointer-fsigned-Char-maltivec" cxxflags = "-mcpu = 7450-O3-pipe-fomit-frame-pointer-fsigned-Char-maltivec"

Note: Do not use-March =

POWERPC (if you don't know which one) chost = "PowerPC-unknown-Linux-GNU" cflags = "-O3-pipe-fomit-frame-pointer-fsigned-char" cxxflags = "-O3-pipe-fomit-Frame -pointer-fsigned-char"

Iscsi chost = "iSCSI-unknown-Linux-GNU" cflags = "-O3-pipe-fomit-frame-pointer" cxxflags = "-O3-pipe-fomit-frame-pointer"

64 chost = "sparc64-unknown-linux-gnu" cflags = "-O3-pipe-fomit-frame-pointer" cxxflags = "-O3-pipe-fomit-frame-pointer" GCC user guide for GCC use guide GCC User Guide

Reading: 989 times

Edit responsibility: tseteen
From: http://www.linuxpk.com/3771.html
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.