Gcc User Manual (3)

Source: Internet
Author: User
Gcc User Manual (3)-Linux general technology-Linux programming and kernel information. For details, see the following. -Print-libgcc-file-name

Same as '-print-file-name = libgcc..

-Print-prog-name = program

Similar to '-print-file-name', but find the program such as 'cpp '.



OPTIMIZATION OPTION)

These options control multiple optimization measures:

-O

-O1

Optimization. For large functions, optimizing compilation takes a little more time and a considerable amount of memory.

When the '-O' option is not used, the compiler aims to reduce the compilation overhead and enable the compilation result to be debugged. The statement is independent.
Yes: if you use a breakpoint to stop a program between two statements, you can assign a value to any variable or
In the data body, the program counter is directed to other statements and you can accurately obtain the expected results from the source program.

When the '-O' option is not used, only the variables declared with register are allocated with registers.
The '- o' option is slightly inferior to the PCC.

With the '-O' option, the compiler will try to reduce the size and execution time of the target code.

If the '-O' option is specified, the'-fthread-jumps 'and'-fdefer-pop' options are enabled.
On the ay slot machine, the '-fdelayed-branch' option will be turned on. Even if there is no frame pointer (frame
Pointer) on the machine that supports debugging, the '-fomit-frame-pointer' option will be turned on. On some machines
Other options may be enabled.

-O2

More optimizations. In addition to optimization options involving space and speed switching, execute almost all optimization work. For example, do not
Compare loop unrolling with inlining.
Added the Compilation Time and improved the Running Effect of generated code.

-O3

More optimizations. Apart from opening what-O2 does, it also opens the-finline-functions option.

-O0

Not optimized.

If multiple-O options are specified, the last option takes effect regardless of the number.

Options such as '-fflag' describe some machine-independent switches. Most switches have two types: yes and no.
Format; the negative format of the '-ffoo' Switch option should be '-fno-foo'. The list below only shows one type of Lattice
--- Format that is not the default option. You can remove or add 'no-'to construct another format.


-Ffloat-store

Do not store floating-point variables in registers. This prevents unexpected high precision on some machines, such as 6800.
The precision of the 0 floating-point register (from 68881) is greater than that of the double.

For most programs, precision is only good, but some programs depend strictly on the definition of IEEE floating point numbers.
Such a program can use the '-ffloat-store' option.

-Fmemoize-lookups

-Fsave-memoized

The heuristic method is used for faster compilation (only for C ++). By default, the exploration method is not used.
The method of exploration is only valid for some input files, and compilation speed of other programs will become slower.

For the first time, the compiler must create a call to the member function (or reference to the member data). It must (1) judge
Determine whether this class implements the member function of that name; (2) decide which member function to call (involving speculation
(3) check whether the member function is visible to the caller. All these constitute slower
Compilation. In general, the second call to a member function (or reference to member data) must go through
Processing with the same length. This means code like this

Cout <"This" <p <"has" <n <"legs. \ n ";

Perform six traversal of the entire three steps. By using the software cache, ''hit ''can significantly reduce this cost.
However, unfortunately, using this cache must implement other mechanisms, resulting in its own overhead. '-fmemoi
The ze-lookups option opens the software cache.

Because the function body environment is different, the function's access to members and member functions (visibility) may also be different, g
++ You may need to refresh the cache. Use the '-fmemoize-lookups' option to refresh the cache every time a function is compiled.
The '-fsave-memoized' option also enables the same cache, but when the compiler finds the last compiled letter
The access permission generated by the data body environment is the same as that of the next function to be compiled, and the compiler retains the cached content.
It is very useful when defining many member functions for a class: Except for some other class friend functions, each member function has
It has the same access permissions as other member functions, so you do not need to refresh the cache.

-Fno-default-inline

By default, member functions are not embedded, because they are defined in the scope of the class (only C ++ ).

-Fno-defer-pop

Once the function is returned, the parameter will pop up immediately. For those machines that must bring up parameters after calling the function, compiler 1
In general, let the parameters of several function calls pile up on the stack, and then pop up all at once.

-Fforce-mem

Before performing a mathematical operation, send the memory operations to be used to the Register.
Common subexpressions, which may produce good target codes. If they are not common subexpressions, the command combination should
Eliminate register loads. I 'd like to hear different opinions.

-Fforce-addr

The memory address constant to be used is sent to the register before the mathematical operation. It may be the same as '-fforce-mem '.
A good target code is generated. I 'd like to hear different opinions.

-Fomit-frame-pointer

Do not save the frame pointer in the register for functions that do not require frame pointers.
Saves, sets, and restores the frame pointer. It also provides an additional register for many functions.
Debugging fails on most machines.

This option is invalid on some machines, such as Vax, because the standard call sequence automatically processes frame pointers by pretending not to store
Without saving anything. The machine description macro FRAME_POINTER_REQUIRED controls whether the target machine supports this
Options.

-Finline-functions

Integrate all simple functions into the caller. The Compiler determines which functions are simple enough in an exploratory manner and deserve this
Integration.

If the call of all given functions is integrated and the function declaration is static, GCC generally has the right
Compile the code output function.

-Fcaller-saves

A number can be allocated in the register, but this scheme is usually affected by the calls of various functions. Therefore, GCC generates
The additional code saves and restores the register content before and after the function call. Only when the generated code looks better than the reverse
This allocation is implemented only when the result is returned.

This option is allowed on some machines by default. Generally, these machines do not call protection registers instead.

-Fkeep-inline-functions

Even if all calls of a function are integrated and the function is declared static
A standalone version that can be called during running.

-Fno-function-cse

Do not store the function address in the Register; explicitly give the function address for the instruction that calls the fixed function.

This option produces a low-efficiency target code, but if this option is not used, some unusual hack will change the sink
The output of the compiler may be confusing due to optimization.

-Fno-peephole

Disable any machine-related peephole Optimization.

-Ffast-math

This option allows GCC to violate certain ANSI or IEEE rules/specifications out of Speed Optimization. For example, it allows the Compiler
Assume that the parameters of the sqrt function are not negative.

This option is not enabled by any '-O' option, because for numbers that are strictly implemented by IEEE or ANSI rules/specifications
Learning functions, the program may produce incorrect results.

The following options control specific optimizations. The '-O2' option opens most of the following optimizations except '-funroll-lo
Ops' and '-funroll-all-loops.

The '-O' option usually opens'-fthread-jumps 'and'-fdelayed-branch' optimization items, but the specific
The default optimization items on the machine may change.

If you need ''fine-tuned ''Optimization in special cases, you can use the following options.

-Fstrength-reduce

Execute loop strength reduction optimization and eliminate repeated variables.

-Fthread-jumps

Where optimization is performed, if the destination of a jump branch has another condition comparison, and the condition Ratio
If the preceding comparison statement is included in the preceding comparison statement, the optimization is executed. The conditions are true or false.
The Branch is redirected to the destination of the second branch or immediately following the second branch.

-Funroll-loops

Optimized loop unrolling. It only indicates the number of cycles that can be determined at compile time or runtime.
Environment implementation.

-Funroll-all-loops

Loop unrolling optimization. All loops are implemented. The program runs slowly.

-Fcse-follow-jumps

When the common subexpression elimination is used
When the path reaches the destination of a jump, the jump command is scanned. For example, if the CSE encounters
If statement, when the condition test is false, the CSE will be behind the jump.

-Fcse-skip-blocks

It is similar to the '-fcse-follow-jumps' option, but the CSE follows the condition jump and the condition jump skips.
Block. if the CSE encounters a simple if statement without the else clause, '-fcse-skip-bloc
The ks option will cause the CSE to follow the if-generated jump.

-Frerun-cse-after-loop

After the loop optimization is executed, the public subexpression is re-used to remove the element.

-Felide-constructors

If it looks reasonable, the constructor (only C ++) is omitted. Based on this option, for the following code, the gnu c ++ direct
Call foo to initialize y without using temporary variables:

A foo (); A y = foo ();

Without this option, gnu c ++ first initializes y by calling the appropriate constructor of type.
The result of o is assigned to the temporary variable. Finally, replace the initial value of 'y' with the temporary variable.

The ansi c ++ standard draft specifies the default behavior ('-fno-elide-constructors'). If the program is constructed
Sub-effects exist. The '-felide-constructors' option can make the program behave differently, because it may
Ignore some constructor calls.

-Fexpensive-optimizations

Perform secondary optimization with relatively high overhead.

-Fdelayed-branch

If this feature is supported on the target machine, it tries to rearrange the commands to use the delayed bra
Nch) The gap behind the instruction.

-Fschedule-insns

If this function is supported on the target machine, it tries to rearrange the commands to eliminate execution caused by data inactivity.
Pause. This can help floating-point operations or slow memory access to the machine to retrieve commands, allowing other commands to be executed first,
It is not until the instruction or floating point operation is completed.

Fschedule-insns2

Similar to the '-fschedule-insns' option, but after the register is allocated, an additional instruction call is required.
Degree process. This option is used for a machine with a relatively small number of registers and a memory instruction greater than a cycle.
Especially useful.



TARGET OPTION)

By default, gnu cc compiles the target code of the local type. However, it can also be installed as a cross compiler,
Compile programs for other models. In fact, you can install the configuration of gnu cc at the same time for different target machines.
Then, use the '-B' option to specify the target host type.

By the way, the new version and the old version of gnu cc can coexist. One of the versions may be the latest one)
It is the default version, but sometimes you want to use another version.

-B machine

The machine parameter indicates the target type of compilation. This option is used to install gnu cc as a cross compiler.

The value of the machine parameter is the same as the machine type set when the gnu cc cross compiler is configured. For example, if
The interpreter is configured with 'configure i0000v', which means to compile the System V target code on 80386. Then you can
Use '-B iplusv' to run the cross compiler.

If the '-B' option is not specified, it usually refers to compiling the local target code.

-V version

The version parameter specifies the version of gnu cc to run. This option is used to install GCC of multiple versions. For example:
If the version is '2. 0', it means to run gnu cc 2.0.

If the '-V' option is not specified, the default version depends on the gnu cc installation method.
Version.



MACHINE DEPENDENT OPTION)

Each target model has its own special options. These options are guided by the '-m' switch and different hardware models are selected.
Number or configuration --- for example, 68010 or 68020, whether there is a floating point coprocessor. Install and compile by specifying the option
A version of the tool can be compiled for all models or configurations.

In addition, some compiler configurations support additional special options, usually to be compatible with this platform on the command line.
Other compilers.

The following is the '-m' option defined for the 68000 series:

-M68000

-Mc68000

Output the 68000 target code. If the compiler is configured based on the 68000 system, this option is the default option.


-M68020

-Mc68020

Output The 68020 target code (instead of 68000). If the compiler is configured based on the 68020 system, this option is
Is the default option.

-M68881

Output the target code containing the 68881 floating point instruction. This is the default option for most 68020-based systems, unless
-Nfp is specified when the compiler is set.

-M68030

Output The 68030 target code. If the compiler is configured based on the 68030 system, this option is the default option.


-M68040

Output The 68040 target code. If the compiler is configured based on the 68040 system, this option is the default option.


M68020-40

Output The 68040 target code, but do not use the new command. The generated code can be on 68020/68881 or
68030 or 68040.

-Mfpa

Output the target code containing the sun fpa floating point instruction.

-Msoft-float

Output the target code containing the floating-point Library call. Warning: the required library is not part of gnu cc. GC is generally used.
C uses the corresponding components of the Local C compiler of this model, but it cannot be used directly for cross-compilation.
Appropriate function libraries are provided for cross-compilation.

-Mshort

The int type is considered as 16-bit width, which is equivalent to short int.

-Mnobitfield

The '-mnobitfield' is implicitly specified without the bit-field Command. '-m68000 '.

-Mbitfield

Use the bitfield command. '-m68020' to implicitly specify'-mbitfield '. If you use not modified gcc
Is the default option.

-Mrtd

Another function call Convention is used. A function accepts a fixed number of parameters and is returned using the rtd command.
The parameters in the stack Are popped up. This method can save the caller a command because it does not need to bring up parameters here.


This call convention is not compatible with normal UNIX calls. Therefore, if you need to call the library functions compiled by the UNIX compiler
You cannot use this option.

In addition, the function must provide a function prototype (including printf) for the variable number of all parameters; otherwise, the compiler will generate
Incorrect call code.

In addition, if the function is called with too many parameters, the compiler will generate a serious error code (normally
.)

68010 and 68020 processors support rtd commands, but 68000 does not.

The '-m' option for VAX is as follows:

-Munix

Disable the output of certain jump commands (aobleq, etc.). The vax unix assembler cannot span the long ran
Ges.

-Mgnu

If the GNU assembler is used, the jump commands are output,

-Mg

The output g-format floating point instead of d-format.

The '-m' Option Switch supported by Linux is as follows:

-Mfpu

-Mhard-float

Output the target code containing the floating point command. This is the default option.

-Mno-fpu

-Msoft-float

Output the target code that contains the floating-point Library call. Warning: the GNU floating-point library is not provided for the Linux instance. Generally, this
The corresponding part of the local C compiler of the model, but it cannot be used for cross-compilation directly.
Library functions that are cross-compiled.

-Msoft-float changes the call conventions in the output file. Therefore, only this option can be used to compile the entire program.
Meaning.

-Mno-epilogue

-Mepilogue

When the-mepilogue (default) option is used, the compiler always places the exit code of the function at the end of the function.
The exit statement in the middle of the function (such as the return statement in C) will generate a jump instruction pointing to the end of the function.


When the-mno-epilogue option is used, the compiler tries its best to embed the exit code at each function exit point.

Mno-v8

-Mv8

-Msparclite

These three options are available for different types of iSCSI systems.

By default, GCC generates the destination code for the iSCSI v7, unless it is specially configured for the Fuji su SPARClite.

-Mv8 is used to generate the objective code of the iSCSI v8 instance. The only difference between the objective code of the v7 instance and the target code is that the compiler generates an integer multiplication and an integer.
Division command, which is not supported by the v7 system.

-Msparclite: generates the SPARClite target code. added the integer multiplication supported by SPARClite.
Scan (integer divide step and scan (ffs) commands. v7 does not support these commands.

-Mcypress

-Msuperiscsi

These two options select the processor model to optimize the code for the processor.

-The mcypress option (default) enables the compiler to optimize the code for the Cypress CY7C602 chip, SparcStation
/SparcServer 3xx series uses this chip. This option is also applicable to older versions of SparcStation 1, 2,
IPX and other models ..

-The msuperiscsi option enables the compiler to optimize code for the superiscsi processor, SparcStation 10,100
This chip is used in the 0 and 2000 series. This option also enables the complete.

The '-m' option for Convex is as follows:

-Mc1

Output the target code of C1. This is the default option when the compiler configures C1.

-Mc2

Output the target code of C2. This is the default option when the compiler configures C2.

-Margcount

Put an argument count word in front of each parameter list. Some cannot be transplanted.
The Convex and Vax programs require this parameter to count. (The debugger does not need this parameter unless the function has a variable length parameter.
Number list; this information is stored in the symbol table .)

-Mnoargcount

Ignore the parameter count. If you use the not modified gcc, This is the default option.

The '-m' option for AMD Am29000 is as follows:

-Mdw

The generated destination code is considered as the DW position, that is, bytes and half-word operations are directly supported by hardware. This option is selected by default.
Item.

-Mnodw

The generated target code does not hold the DW position.

-Mbw

The generated destination code is considered to support byte and semi-word write operations. This option is the default option.

-Mnbw

The generated target code does not support the byte and semi-word write operations. This option implicitly enables the '-mnodw' option.


-Msmall

In small memory mode, it is assumed that the address of all functions is within a 256 KB segment, or all functions
The absolute address of the number is less than K. In this way, you can use the call command to replace the const, conth, and calli command orders.
Column.

-Mlarge

This is the default option.

-M29050

Output the target code of Am29050.

-M29000

Output The Am29000 target code. This is the default option.

-Mkernel-registers

The generated destination code references the gr64-gr95 register instead of the gr96-gr127 register. This option can be used for compilation
Kernel code. The kernel requires a set of global registers, which are identical to those used in user mode.
Irrelevant.

Note: When this option is used, the register name in the '-F' option must be normal, user-mode, name
S.

-Muser-registers

Use the General Global Register set gr96-gr127. This is the default option.

-Mstack-check

Insert a _ msp_check call after each stack adjustment. This option is often used in kernel code.

The '-m' option defined for the Motorola 88K system is as follows:

-M88000

The generated target code can work properly on m88100 and m88110.

-M88100

The generated target code works best on m88100, but can also be run on m88110.

-M88110

The generated target code works best on m88110 and may not run on m88100.

-Midenvision-revision

The output end of the assembler contains an ident command, which records the source file name, compiler name and version, time scales, and
Compilation options used,

-Mno-underscores

At the output end of the assembler, no underline is added before the symbol name. By default
Prefix.

-Mno-check-zero-division

-Mcheck-zero-division

The 88K System of earlier models has problems in the division-by-zero operation. In certain situations, many machines cannot self-trap themselves.
Option to avoid including (or explicit inclusion) additional code that can check the sending example
The '-mcheck-zero-division' option is used by default for all GCC 88K configurations.

-Mocs-debug-info

-Mno-ocs-debug-info

Contains (or ignores) Additional debugging information (about the use of registers in each stack architecture), 88 Open Objec
T Compatibility Standard, ''ocs'. This information is described. GDB does not need this additional information.
The default configuration of DG/UX, SVr4, and Delta 88 SVr3.2 includes debugging information, and the default configuration of other 88k Models
The configuration ignores this information.

-Mocs-frame-position

-Mno-ocs-frame-position

Forcibly (or not required) store the register value to the specified position in the stack architecture (according to OCS instructions). DG/UX,
By default, the '-mocs-frame-position' option is used for Delta88 SVr3.2 and BCS configurations. Other 88k Models
The default configuration is '-mno-ocs-frame-position '.

-Moptimize-arg-area

-Mno-optimize-arg-area

Controls how to store function parameters in the stack structure. '-moptimize-arg-area' saves space, but can
Some debuggers (not GDB) can be down. '-mno-optimize-arg-area' proves better than standard options. Default
In this case, GCC does not optimize the parameter fields.

-Mshort-data-

Num is associated with r0 to generate a small data reference. In this way, you can call
A value (rather than a common dual command). You can use the num option to control which data reference is changed. For example
For example, if you specify '-mshort-data-512', then the affected data reference is less than 512 bytes
The.-mshort-data-num option is invalid for num greater than 64 K.

-Mserialize-volatile

-Mno-serialize-volatile

Generate, or do not generate code to ensure consistent results for easy-to-change memory access.

For Commonly Used processor sub-models, gnu cc always guarantees the consistency by default.
The sub-model of the processor.

The m88100 processor does not reschedule memory references, so the access results are consistent. If '-m88100
'Option. gnu cc does not generate any special commands for consistent results.

The memory reference sequence of the m88110 processor does not always conform to the reference sequence of the command request.
It may be executed before the previous storage commands. In a multi-processor environment, disorderly access disrupts variable memory access.
The results are consistent. Therefore, when the '-m88000' or'-m88110 'option is used, gnu cc generates
The execution order of special commands is correct.

The extra code used to ensure consistency may affect the program's performance. If you are sure you can safely give up
To ensure this, you can use the '-mno-serialize-volatile' option.

If you use the '-m88100' option, but the running results on the m88110 processor are consistent, you should add
On the '-mserialize-volatile' option.

-Msvr4

-Msvr3

Enable ('-msvr4') or disable ('-msvr3') compiler extensions related to System V version 4 (SVr4 ).
Results:

*

Which Assembly syntax is output (you can use the '-mversion-03.00' option to select separately ).

*

'-Msvr4' enable C Preprocessor to recognize' # pragma weak' command

*

'-Msvr4' enables GCC to output additional declaration commands (declaration ctictive) for SVr4.

In addition to the SVr4 configuration, '-msvr3' is the default option for all m88K configurations.

-Mtrap-large-shift

-Mhandle-large-shift

Contains some commands to detect the shifts greater than 31 bits (bit-shift). Based on the corresponding options
Trap or execute appropriate processing code. By default, GCC does not perform special processing on large displacement.


-Muse-div-instruction

There was no (div) division command for the 88K model a long time ago. Therefore, GCC avoids this command by default.
Indicates that the GCC command is safe.

Mversion-03.00

In the DG/UX configuration, there are two styles of SVr4. this option is modified-msvr4, select hybrid-COFF or re
Al-ELF style. This option is ignored in other configurations.

-Mwarn-passed-structs

If a function transmits the structure as a parameter or result, GCC sends a warning. With the development of C language
The transfer structure convention is changed, which often leads to porting problems. By default, GCC will not issue a warning.


The following options are used for IBM RS6000:

-Mfp-in-toc

-Mno-fp-in-toc

Controls whether to place floating-point constants in the content table (TOC). The content table stores all global variables and function addresses.
Under normal conditions, GCC puts the floating point constant here. If TOC overflow occurs, the '-mno-fp-in-toc' option can be reduced.
Reduce the TOC size to avoid overflow.

The following '-m' option is used for ibm rt pc:

-Min-line-mul

Use embedded code for integer multiplication. This is the default option.

-Mcall-lib-mul

Use lmul $ for integer multiplication.

-Mfull-fp-blocks

Generate full-size floating point data blocks, including the minimum number of active space (scratch space) recommended by IBM. This is
Default options.

-Mminimum-fp-blocks

Do not include additional active space in floating-point data blocks. In this way, a small but slightly slow executable program is generated,
Because the activity space must be dynamically allocated.

-Mfp-arg-in-fpregs

Use a call sequence that is incompatible with IBM call conventions and transmit floating-point parameters through floating-point registers. Note that if you specify
With this option, varargs. h and stdargs. h cannot support floating point units.

-Mfp-arg-in-gregs

Use the normal call convention to process floating-point parameters. This is the default option.

-Mhc-struct-return

Returns a structure larger than one word through memory, instead of using registers. Used to be compatible with MetaWare HighC (hc
) Compiler. Use the '-fpcc-struct-return' option to be compatible with the Portable C compiler (pcc ).

-Mnohc-struct-return

If possible, some structures larger than one word are returned through registers. This is the default option. If you plan to be compatible with IBM
For the provided compiler, use the '-fpcc-struct-return' or '-mhc-struct-return' option.

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.