最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

some gcc parameter

工作和技术 crifan 1526浏览 0评论

-Wdeclaration-after-statement (C only)
Warn when a declaration is found after a statement in a block. This construct,
known from C++, was introduced with ISO C99 and is by default allowed in
GCC. It is not supported by ISO C90 and was not supported by GCC versions
before GCC 3.0.

-Wundef

Warn if an undefined identifier is evaluated in an ‘#if’ directive.

-Wp

3.11 Options Controlling the Preprocessor
These options control the C preprocessor, which is run on each C source file before actual compilation.
If you use the ‘-E’ option, nothing is done except preprocessing. Some of these options make sense only together with ‘-E’ because they cause the preprocessor output to be unsuitable for actual compilation.
You can use ‘-Wp,option’ to bypass the compiler driver and pass option directly through to the preprocessor. If option contains commas, it is split into multiple options at the commas. However, many options are modified, translated or interpreted by the compiler driver before being passed to the preprocessor, and ‘-Wp’ forcibly bypasses this phase. The preprocessor’s direct interface is undocumented and subject to change, so whenever possible you should avoid using ‘-Wp’ and let the driver handle the options instead.

-MF

file When used with ‘-M’ or ‘-MM’, specifies a file to write the dependencies to. If no ‘-MF’ switch is given the preprocessor sends the rules to the same place it would have sent preprocessed output.
When used with the driver options ‘-MD’ or ‘-MMD’, ‘-MF’ overrides the default dependency output file.

-MD

‘-MD’ is equivalent to ‘-M -MF file’, except that ‘-E’ is not implied. The driver determines file based on whether an ‘-o’ option is given. If it is, the driver uses its argument but with a suffix of ‘.d’, otherwise it take the basename of the input file and applies a ‘.d’ suffix.
If ‘-MD’ is used in conjunction with ‘-E’, any ‘-o’ switch is understood to specify the dependency output file (see [-MF], page 102), but if used without ‘-E’, each ‘-o’ is understood to specify a target object file.
Since ‘-E’ is not implied, ‘-MD’ can be used to generate a dependency output file as a side-effect of the compilation process.

-nostdinc
Do not search the standard system directories for header files. Only the directories you have specified with ‘-I’ options (and the directory of the current file, if appropriate) are searched.

-isystem dir
Search dir for header files, after all directories specified by ‘-I’ but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories.

-D name

Predefine name as a macro, with definition 1.

-D name=definition
The contents of definition are tokenized and processed as if they appeared during translation phase three in a ‘#define’ directive. In particular, the definition will be truncated by embedded newline characters. If you are invoking the preprocessor from a shell or shell-like program you may need to use the shell’s quoting syntax to protect characters such as spaces that have a meaning in the shell syntax.
If you wish to define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals sign (if any). Parentheses are meaningful to most shells, so you will need to quote the option. With sh and csh, ‘-D’name(args…)=definition’’ works.
‘-D’ and ‘-U’ options are processed in the order they are given on the command line. All ‘-imacros file’ and ‘-include file’ options are processed after all ‘-D’ and ‘-U’ options.

-include file
Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor’s working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "…" search chain as normal. If multiple ‘-include’ options are given, the files are included in the order they appear on the command line.

-Wall

Turns on all optional warnings which are desirable for normal code. At present this is ‘-Wcomment’, ‘-Wtrigraphs’, ‘-Wmultichar’ and a warning about integer promotion causing a change of sign in #if expressions. Note that many of the preprocessor’s warnings are on by default and have no options to control them.

-Wcomment
-Wcomments
Warn whenever a comment-start sequence ‘/*’ appears in a ‘/*’ comment, or whenever a backslash-newline appears in a ‘//’ comment. (Both forms have the same effect.)

-Wtrigraphs
Most trigraphs in comments cannot affect the meaning of the program. However, a trigraph that would form an escaped newline (‘??/’ at the end of a line) can, by changing where the comment begins or ends. Therefore, only trigraphs that would form escaped newlines produce warnings inside a comment.
This option is implied by ‘-Wall’. If ‘-Wall’ is not given, this option is still enabled unless trigraphs are enabled. To get trigraph conversion without warnings, but get the other ‘-Wall’ warnings, use ‘-trigraphs -Wall -Wno-trigraphs’.

-Wno-multichar
Do not warn if a multicharacter constant (‘’FOOF’’) is used. Usually they indicate a typo in the user’s code, as they have implementation-defined values, and should not be used in portable code.

-Wstrict-prototypes (C only)
Warn if a function is declared or defined without specifying the argument types. (An old-style function definition is permitted without a warning if preceded by a declaration which specifies the argument types.)

-fstrict-aliasing

Allows the compiler to assume the strictest aliasing rules applicable to the language being compiled. For C (and C++), this activates optimizations based on the type of expressions. In particular, an object of one type is assumed never to reside at the same address as an object of a different type, unless the types
are almost the same. For example, an unsigned int can alias an int, but not a void* or a double. A character type may alias any other type.
Pay special attention to code like this:
union a_union {
int i;
double d;
};
int f() {
a_union t;
t.d = 3.0;
return t.i;
}
The practice of reading from a different union member than the one most recently written to (called “type-punning”) is common. Even with ‘-fstrict-aliasing’, type-punning is allowed, provided the memory is accessed through the union type. So, the code above will work as expected.
However, this code might not:
int f() {
a_union t;
int* ip;
t.d = 3.0;
ip = &t.i;
return *ip;
}
Every language that wishes to perform language-specific alias analysis should define a function that computes, given an tree node, an alias set for the node. Nodes in different alias sets are not allowed to alias. For an example, see the C front-end function c_get_alias_set.
Enabled at levels ‘-O2’, ‘-O3’, ‘-Os’.

-fno-common
In C, allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks. This has the effect that if the same variable is declared (without extern) in two different compilations, you will get an error when you link them. The only reason this might be useful is if you wish to verify that the program will work on other systems which always work this way.

-momit-leaf-frame-pointer
Don’t keep the frame pointer in a register for leaf functions. This avoids the instructions to save, set up and restore frame pointers and makes an extra register available in leaf functions. The option ‘-fomit-frame-pointer’ removes the frame pointer for all functions which might make debugging harder.

-mapcs-frame
Generate a stack frame that is compliant with the ARM Procedure Call Standard for all functions, even if this is not strictly necessary for correct execution of the code. Specifying ‘-fomit-frame-pointer’ with this option will cause the stack frames not to be generated for leaf functions. The default is ‘-mno-apcs-frame’.

-mapcs

This is a synonym for ‘-mapcs-frame’.

-mno-sched-prolog
Prevent the reordering of instructions in the function prolog, or the merging of those instruction with the instructions in the function’s body. This means that all functions will start with a recognizable set of instructions (or in fact one of a choice from a small set of different function prologues), and this information can be used to locate the start if functions inside an executable piece of code.
The default is ‘-msched-prolog’.

-mabi=name
Generate code for the specified ABI. Permissible values are: ‘apcs-gnu’, ‘atpcs’, ‘aapcs’, ‘aapcs-linux’ and ‘iwmmxt’.

-mthumb-interwork
Generate code which supports calling between the ARM and Thumb instruction sets. Without this option the two instruction sets cannot be reliably used inside one program. The default is ‘-mno-thumb-interwork’, since slightly larger code is generated when ‘-mthumb-interwork’ is specified.

-march=name
This specifies the name of the target ARM architecture. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. This option can be used in conjunction with or instead of the ‘-mcpu=’ option. Permissible names are: ‘armv2’, ‘armv2a’, ‘armv3’, ‘armv3m’, ‘armv4’, ‘armv4t’, ‘armv5’, ‘armv5t’, ‘armv5te’, ‘armv6’, ‘armv6j’, ‘iwmmxt’, ‘ep9312’.

-mcpu=name
This specifies the name of the target ARM processor. GCC uses this name to determine what kind of instructions it can emit when generating assembly code.

    Permissible names are: ‘arm2’, ‘arm250’, ‘arm3’, ‘arm6’, ‘arm60’,
‘arm600’, ‘arm610’, ‘arm620’, ‘arm7’, ‘arm7m’, ‘arm7d’, ‘arm7dm’, ‘arm7di’,
‘arm7dmi’, ‘arm70’, ‘arm700’, ‘arm700i’, ‘arm710’, ‘arm710c’, ‘arm7100’,
‘arm7500’, ‘arm7500fe’, ‘arm7tdmi’, ‘arm7tdmi-s’, ‘arm8’, ‘strongarm’,
‘strongarm110’, ‘strongarm1100’, ‘arm8’, ‘arm810’, ‘arm9’, ‘arm9e’,
‘arm920’, ‘arm920t’, ‘arm922t’, ‘arm946e-s’, ‘arm966e-s’, ‘arm968e-s’,
‘arm926ej-s’, ‘arm940t’, ‘arm9tdmi’, ‘arm10tdmi’, ‘arm1020t’, ‘arm1026ej-s’,
‘arm10e’, ‘arm1020e’, ‘arm1022e’, ‘arm1136j-s’, ‘arm1136jf-s’, ‘mpcore’,
‘mpcorenovfp’, ‘arm1176jz-s’, ‘arm1176jzf-s’, ‘xscale’, ‘iwmmxt’, ‘ep9312’.

-mtune=name
This option is very similar to the ‘-mcpu=’ option, except that instead of specifying the actual target processor type, and hence restricting which instructions can be used, it specifies that GCC should tune the performance of the code as if the target were of the type specified in this option, but still choosing the instructions that it will generate based on the cpu specified by a ‘-mcpu=’ option.
For some ARM implementations better performance can be obtained by using this option.

-mno-soft-float
-msoft-float
Use (do not use) the hardware floating-point instructions for floating-point operations. When ‘-msoft-float’ is specified, functions in ‘libgcc.a’ will be used to perform floating-point operations. Unless they are replaced by routines that emulate the floating-point operations, or compiled in such a way as to call
such emulations routines, these routines will issue floating-point operations. If you are compiling for an Alpha without floating-point operations, you must ensure that the library is built so as not to call them.
Note that Alpha implementations without floating-point operations are required to have floating-point registers.

-foptimize-sibling-calls
Optimize sibling and tail recursive calls.
Enabled at levels ‘-O2’, ‘-O3’, ‘-Os’.

-g

Produce debugging information in the operating system’s native format (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this debugging information.
On most systems that use stabs format, ‘-g’ enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but will probably make other debuggers crash or refuse to read the program. If you want to control for certain whether to generate the extra information, use ‘-gstabs+’, ‘-gstabs’, ‘-gxcoff+’, ‘-gxcoff’, or ‘-gvms’(see below).
GCC allows you to use ‘-g’ with ‘-O’. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops.
Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs. The following options are useful when GCC is generated with the capability for more than one debugging format.

-fstack-protector
Emit extra code to check for buffer overflows, such as stack smashing attacks. This is done by adding a guard variable to functions with vulnerable objects. This includes functions that call alloca, and functions with buffers larger than 8 bytes. The guards are initialized when a function is entered and then checked
when the function exits. If a guard check fails, an error message is printed and the program exits.

-Wpointer-sign
Warn for pointer argument passing or assignment with different signedness. This option is only supported for C and Objective-C. It is implied by ‘-Wall’ and by ‘-pedantic’, which can be disabled with ‘-Wno-pointer-sign’.

转载请注明:在路上 » some gcc parameter

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.159 seconds, using 22.12MB memory