GCC User Guide and gcc best compilation Parameters
Source: Internet
Author: User
GCC User Guide and gcc best compilation parameters-general Linux technology-Linux programming and kernel information. The following is a detailed description. GCC User Guide
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 presets files that have been preprocessed (with the extension. I) to C language, and
The connection phase is processed in C connection mode.
G ++ defaults that files that have been preprocessed (with the extension. I) are in the C ++ language.
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:
Original. c program; preprocessing, compilation, and assembly
Original. C ++ program; preprocessing, compilation, and assembly
. Cc C ++ original program; preprocessing, compilation, and assembly
. Cxx C ++ original program; preprocessing, compilation, and 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
Original program of. s combination language; Assembly
Original program of. S combination language; preprocessing and compilation
. H pre-processing file (header file); (not frequently displayed in the command line)
Files with other extensions are processed by the link program, usually including:
. O Object file
. A 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
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 ++ 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. a GCC subroutine library
/Lib/crt [01n]. o start-up routine
LIBDIR/ccrt0 additional start-up routine for C ++
/Lib/libc. a 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
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"
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.