GCC User Guide

xiaoxiao2021-03-06  75

1. The English version of the preface GCC compiler has been very comprehensive, and the structure is also very perfect, but there is no Chinese version, I read the main content of the GCC compiler this time, the content of the manual The structural understanding is made, and it is considered necessary to organize this reading, preparing for future work. Since I read this English manual is only structural. Therefore, there are many places that don't look, so I can only write some part of this document. For the place where you need more understanding, you will add content to this document, and the content that needs to add is mainly compiled. Switch. 2. GCC function introduction The GCC compiler completes the conversion of the target code running from the C, C , Objective-C equal source file (this is the task that needs to be completed). The source files that GCC can process are divided into C, C , Objective-C, assembly language, etc. For these source files, labeled them with their suffix names. GCC can handle suffixes: a. * .C * .c (c language) b. * .Cxx * .cc (C language) c. * .M (object-oriented C) d. * .I (pre-processing The post-C language source file) e. * .II (pre-processed C language source file) f. * .S * .s (assembly language) h. * .H (header) target file can be: a. * .o-compiled target file b. * .a library file compiler divides the task of compiling the target code into the following 4: a. Preprocessing, complete the pre-processing command scan; b. Compile, The result is compiled into a compilation or target module; c. Compilation, compile the compiled results into the target code module on the specific CPU; D. Connect, connect multiple target code modules to generate a large target module; 3. The GCC Switch GCC running switch is divided into 11 categories, which is the operation of the GCC program from 11 aspects to achieve specific compilation purposes. 3.1. The global switch (OVERALL OPTIONS) global switch is used to control the operation of the four steps in the GCC in the "GCC function introduction", in the default, these four steps are to be executed, but when a given After some global switches, these steps will be executed in one step, which creates intermediate results, for example, may simply need the result of the pre-processed pre-processing or assembly files (such as the proposed purpose to see a compilation on a CPU. How to write the language). 3.1.1. -X Language is written in what language written for the source file, which can be launched by the suffix of the file name or by this switch. The specified input file is written in what language is written. -X none is turned off for the -x switch introduced in the previous section. 3.1.3. -C compiles the source file target code, nothing to do. 3.1.4. -S Compiles the source file into assembly code, does not make assembly and connection actions. 3.1.5. -E only outputs the result of the source file after pretreatment. Do not do compile, assembly, and connection action. 3.1.6. -O file Indicates the output file name is file. 3.1.7. -V The output information of the entire compilation process is printed.

3.1.8. -Pipe Due to the completion of the GCC's work, it is necessary to generate temporary files during the process, and use -pipe to replace temporary files with pipelines. 3.2. Language Options (Language Options) is used to handle and language-related control switches. 3.2.1.-ANSI This switch allows the GCC compiler to turn off all GNU compiler features, allowing your programs to compatibility with ANSI standards. In addition to the above switches, there are still many language-related switches. If you encounter it in future work, it is not too late! 3.3. Preprocessor Options is used to control the switch set by the preprocessing. 3.3.1. -Include file Before compiling, put the file into it, equivalent to adding a #inclu de statement in front of all compiled source files, making more "oil". 3.3.2. -Imacros FILE is the same as -include file. However, this document is only used in specific compilation, and the value is used to define a macro in the File file. 3.3.3. -Nostdinc Remove the standard C language header file search path in the file path of Include, such as the stdio.h file is placed under the standard header file search path. 3.3.4. -Nostdinc is the same, just removes the header file search path of the standard C language. 3.3.5. -C Tong - E parameter is used. Let the results after pretreatment, keep your comment, let people read it better. 3.3.6. -Dmacro defines MacRo as string '1'. 3.3.7. -Dmacro = DEFN defines MacRo as DEFN. 3.3.8. -Umacro cancels the definition of Macro. In addition to the above switches, there are still many pretreatment related switches. If you encounter it in the future work, it is not too late! 3.4. Assembler Option is used to control the switch for assembly behavior. 3.4.1. -Wa, Option gives Option as the switch to the assembler. If there is a comma in Option, it is handled as a few lines. 3.5. Linker Options is used to control the switch options for the connection process. 3.5.1. Object-file-name 3.5.2. -Llibrary connection library file switch. For example, -LUGL, the program is connected to the libugl.a file. 3.5.3. -Lobjc This switch is used in library file processing of object-oriented C language files. 3.5.4. -Nostartfiles does not connect the system-related startup code when the connection is connected. 3.5.5. -Nostdlib does not connect the system-related startup files and system-related libraries when they are connected. 3.5.6. -Static supports dynamic connection on some systems, this switch does not allow dynamic connection. 3.5.7. -Shared Generates a target module that can be shared by other programs. There are still some connections related to the switch, and then make it again. 3.6. Directory Options (Directory Options) is used to define switches related to the directory operation. 3.6.1. -Idir macro INCLUDE needs to search for a directory. 3.6.2.-i- Similar to the -i switch. 3.6.3. -LDIR The path to the library file (* .a). There are still a lot of switches related to the directory, and it needs to be added later. 3.7. WARNING OPTIONS The switch is related to the warning. 3.7.1.-fsyntax-only checks the syntax errors in the code, but there is no output. 3.7.2. -W prohibits all warning information to print out.

3.7.3. -Wno-import prohibits a warning of macro #import. 3.7.4. -Pedant 3.7.5. -Pedantic-errors 3.7.6. -W There are still many switches related to the warning process, and then make up. 3.8. Debugging Options 3.8.1.-g Open the debugging switch to make the compiled target file have debugging information. There are still many switches related to debugging processing, and then make up. 3.9. Optimization Options -O1 -O2 -O3 -O0, these switches control optimized strength, and -O3 is the strongest. 3.10. Target Options 3.10.1. -B Machine In some time, the target code compiled by the GCC compiler is not running on the machine running this compilation action, which compiles another machine. Currently called cross-compilation, it is used to run the final target code called target machine, and Machine is used to indicate the type of target machine. 3.10.2. -V version is used to tell the compiler to use the number of versions of its version, and the version of the Version parameter is used to represent the version. 3.11. Machine Dependent Options is more useful when cross-compilation. talk about it later. 3.12. Code Generation Option **************************************************** *********************************** ********* ************** ** GCC Usage Guide Use Syntax: GCC [Option | FileName] ... G [option | filename] ... where option is the option when using GCC (will be detailed later), and FileName is to process GCC Document Description: This C Compiler has integrated related programs that generate new programs. Generating a new procedure requires four phases: pretreatment, compile, assembly, link, and these two compilers can process the input files different stages. Although the extension of the original program can be used to distinguish the language used by the original program code, the different compiler, its preset handler is different: the GCC presets via the pre-processed (extended names .i) The C language is handled in C's linking. G defaults to the C language via the pre-processed (extension .i) and processed in C .

The extension of the original program code indicates the language used by the written program used, and the corresponding processing method: .c C original program; pretreatment, compile, assembly .C C original program; pre-processing, compilation, assembly .cc C original program ; Pretreatment, compilation, assembly .cxx C original program; pretreatment, compile, compilation .m Objective-C original program; pre-processing, compilation, assembly .I has passed the pre-processed C original program; compilation, assembly .ii already C original program for pre-processing; compile, assembly. S-combined language original program; assembly. S-combined language original program; pre-processing, assembly .h pre-processing file (header file); (not often in the instruction line) The extension file is processed by the link, usually: .o Object File .a Archive File unless the compilation process has an error, "link" must be the final stage of generating a new program. However, you can also stop one of the four phases in four phases of options such as -c, -s or -e. In the coupling phase, all the .o files, libraries, and other files that cannot be identified from the original code (including the Object File that are not extended, as well as the extension .a), including .a .a archive file) Both will be handed over (in the instruction line as the parameter passing to the connection program). Options: Different options must be separated:, for example, `-dr 'This option is not the same as` -d -r'. Most of the larger `-f 'and` -w' options have two forms: -fname and -fno-name (or -wname and -wno-name). The following is only listed in the non-preset form. The following is a summary of all options. Classified in the form. The meaning of the option will also make another section.

General (rough, commonly used) option -c -s -e -o file -pipe -v -x language programming language options -ansi -fall-virtual -fcond-mismatch -fdollars-in-IdentifierS -fenum-int-equiviV -fexternal-templates -fno-asm -fno-builtin -fno-strict-prototype -fsigned-bitfields -fsigned-char -fthis-is-variable -funsigned-bitfields -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs compile time warning option -FSYNTAX-Only -pedantic -pedantic-errotes -w -w -wall -waggregate-return -wcast-align -wcast-qual -wchar-subscript -wcomment -wconversion -wenum-clamp -wconversion -wenum-clamp -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 debug option -a -dl ETTERS -FPRETEND-FLOAT -G -GLEVEL -GCOFF -GXCOFF -GXCOFF -GDWARF -GDWARF -GSTABS -GSTABS -GGDB -P -PG -SIAVE-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-reduuce -ft-jumps -funroll-all-loops -funroll-loops -o-ods pre-processing option -aAsSERTION -C -DD -DM -DN-DMACRO [= DEFN] -E -H -IDIRAFTER DIR -IPREFIX FILE-IWITHPREFIX DIR -M -MD -MM -MMD -NOSTDINC -P -UMACRO -UNDEF assembler option -wa, Option link program - LLIBRARY - Nostartfiles -nostdlib -static -shared -symbolic -xlinker option -wl,

Option -u Symbol Directory Options - BPREFIX -IDIR -I- -LDIR TARGET OPTIONS -B MACHINE -V Version and 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 SPARC Options -mepilogue -mfpu -mhard-float -mno-fpu -mno-epilogue -msoft-float -msparclite -mv8 - msupersparc -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-DIVISITION -MHANDLE-LARGE-SHIFT -MIDENTIFY-REVISITION -MNO-CHECK-ZERO-DIVISION-MNO-OCS-DEBUG-INFO-MNO-OCS-FRAME-POSITION -MNO-OPTIMIZE- arg-area-malo-serialize-volatile -Mno-unders Cores-MOCS-DEBUG-INFO -MOCS-FRAME-POSITION -MOPTIMIMIZE-ARG-Area-MSerialize-Volatile-MVR4 -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 -M

Abicalls -Mno-Abicalls-Mno-Mno-Half-Pic -g Num -NoCPP I386 OPTIONS -M486 -MNO-486 -MSOFT-FLOAT -MNO-FP-RET-IN-387 HPPA Options -MPa-RISC-1 -0 -MPA-RISC-1-1 -Mkernel-mshared-libs -Mno-shared-limited-fpregs -mdisable-indexing -mtrailing-color-960 options -mcpu-type -MNuMerics -Msoft-Float -MLEAF-PROCEDURES -MTAIL-CALL-MNO-TAIL-CALL-MNDR-MNO-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-mald-align dec alpha options -mfp-regs-malno-fp-regs -Mno- Soft-float-msoft-float system v Options -g -qy -qn -yp, paths -ym, dir code generation option options -fcall-saved-reg -fall-buy-reg -ffixed-reg -finhibit-size-directive Fnonnull-Objects -fno-Common -Fno-Ident -fno-gnu-linker -fpcc-struct-return-fpic -fpic -freg-struct-return -fshared-data -fshort-enums -fshort-double -fvolatile -fvolatile-global -fverbose-asm pragmas Two `#pragma ' directives are supported for GNU C , to permit using the same header file for two purposes: as a definition of interfaces to a given object class, and as the full definition of the contents of that object class #pragma interface (C only.). Uses 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 M

ember functions, debugging infor- mation, and the internal tables that implement vir- tual functions) must be kept in each object file that includes class definitions. You can use this pragma to avoid such duplication. When a header file containing `#pragma interface 'is included in a compilation, this auxiliary information will not be generated (unless the main input source file it- self uses `#pragma implementation'). Instead, the object files will contain 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 included header file, in turn, should Use `#pragma interface '. Backup Copies of Inline Mem - BER Functions, Debugging Informati on, 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 MultiPL

转载请注明原文地址:https://www.9cbs.com/read-108942.html

New Post(0)