-E
Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output. Input files that don’t require preprocessing are ignored.
在预处理阶段之后停止;不要正确运行编译器。输出采用预处理后的源代码的形式,并将其发送到标准输出。不需要预处理的输入文件将被忽略。
Warnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky or suggest there may have been an error.
The following language-independent options do not enable specific warnings but control the kinds of diagnostics produced by GCC.
警告是诊断消息,报告的结构本质上不是错误的,但存在风险或建议可能存在错误。
以下与语言无关的选项不会启用特定警告,但会控制 GCC 生成的诊断类型。
inherently [ɪnˈhɪərəntlɪ]:adv. 内在地,固有地,天性地
erroneous [ɪ'rəʊnɪəs; e-]:adj. 错误的,不正确的
construction [kən'strʌkʃ(ə)n]:n. 建设,建筑物,解释,造句
-fsyntax-only
Check the code for syntax errors, but don’t do anything beyond that.
检查代码是否存在语法错误,但除此之外不要做任何事情。
-fmax-errors=n
Limits the maximum number of error messages to n, at which point GCC bails out rather than attempting to continue processing the source code. If n is 0 (the default), there is no limit on the number of error messages produced. If ‘-Wfatal-errors’
is also specified, then ‘-Wfatal-errors’
takes precedence over this option.
将最大错误消息数限制为 n,此时 GCC 将退出而不是尝试继续处理源代码。如果 n 为 0 (the default),则生成的错误消息数没有限制。如果还指定了 ‘-Wfatal-errors’,则 ‘-Wfatal-errors’ 优先于此选项。
bail[beɪl]:n. 保释,保释人,保释金,杓 vt. 保释,帮助某人脱离困境,往外舀水
precedence ['presɪd(ə)ns; prɪ'siːd(ə)ns]:n. 优先;居先
-w
Inhibit all warning messages.
禁止所有警告消息。
inhibit [ɪn'hɪbɪt]:vt. 抑制,禁止
-Werror
Make all warnings into errors.
将所有警告变为错误。
-Werror=
Make the specified warning into an error. The specifier for a warning is appended; for example ‘-Werror=switch’
turns the warnings controlled by ‘-Wswitch’
into errors. This switch takes a negative form, to be used to negate ‘-Werror’
for specific warnings; for example ‘-Wno-error=switch’
makes ‘-Wswitch’
warnings not be errors, even when ‘-Werror’
is in effect.
使指定的警告成为错误。附加警告的指定者,例如 ‘-Werror=switch’ 将 ‘-Wswitch’ 控制的警告变为错误。此开关采用否定形式,用于否定特定警告的 ‘-Werror’,例如 ‘-Wno-error=switch’ 使 ‘-Wswitch’ 警告不会出错,即使 ‘-Werror’ 生效也是如此。
The warning message for each controllable warning includes the option that controls the warning. That option can then be used with ‘-Werror=’
and ‘-Wno-error=’
as described above. (Printing of the option in the warning message can be disabled using the ‘-fno-diagnostics-show-option’
flag.)
每个可控警告的警告消息包括控制警告的选项。然后该选项可以与 ‘-Werror=’ and ‘-Wno-error=’ 一起使用,如上所述。(可以使用 ‘-fno-diagnostics-show-option’ 标志禁用在警告消息中打印选项。)
Note that specifying ‘-Werror=’
foo automatically implies ‘-W’
foo. However, ‘-Wno-error=’
foo does not imply anything.
请注意,指定 ‘-Werror=’foo 会自动隐含‘-W’foo。但是 ‘-Wno-error=’foo 并不意味着什么。
-Wfatal-errors
This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printing further error messages.
此选项会导致编译器在发生第一次错误时中止编译,而不是尝试继续执行并打印更多错误消息。
You can request many specific warnings with options beginning with ‘-W’
, for example ‘-Wimplicit’
to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning ‘-Wno-’
to turn off warnings; for example, ‘-Wno-implicit’
. This manual lists only one of the two forms, whichever is not the default.
您可以使用以 ‘-W’ 开头的选项请求许多特定警告,例如 ‘-Wimplicit’ 以请求隐式声明的警告。这些特定警告选项中的每一个也都有一个负的形式,以 ‘-Wno-’ 开头以关闭警告,例如 ‘-Wno-implicit’。本手册仅列出两种形式中的一种,不是默认值。
-Wno-unused-result
Do not warn if a caller of a function marked with attribute warn_unused_result
(see Section 6.31 [Function Attributes], page 392) does not use its return value. The default is ‘-Wunused-result’
.
如果标记有属性 warn_unused_result 的函数的调用者 (see Section 6.31 [Function Attributes], page 392) 不使用其返回值,请不要发出警告。The default is ‘-Wunused-result’.
-Wunknown-pragmas
Warn when a #pragma
directive is encountered that is not understood by GCC.
If this command-line option is used, warnings are even issued for unknown pragmas in system header files. This is not the case if the warnings are only
enabled by the ‘-Wall’
command-line option.
遇到 GCC 无法理解的 #pragma 指令时发出警告。
如果使用此命令行选项,则甚至会为系统 header files 中的未知 pragma 发出警告。如果警告仅由 ‘-Wall’ 命令行选项启用,则情况并非如此。
-Wno-pragmas
Do not warn about misuses of pragmas
, such as incorrect parameters, invalid syntax, or conflicts between pragmas. See also ‘-Wunknown-pragmas’
.
不要警告 pragmas 的滥用,例如参数不正确,语法无效或 pragmas 之间的冲突。
GCC has various special options that are used for debugging either your program or GCC:
GCC 拥有许多特别选项,既可以调试用户的程序,也可以对 GCC 排错:
-g
Produce debugging information in the operating system’s native format (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this debugging information.
以操作系统的本地格式 (stabs, COFF, XCOFF, or DWARF 2) 产生调试信息。GDB 能够使用这些调试信息.
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 probably makes 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).
在大多数使用 stabs 格式的系统上,‘-g’ 选项启动只有 GDB 才使用的额外调试信息。这些信息使 GDB 调试效果更好,但是有可能导致其他调试器崩溃,或拒绝读入程序。如果你确定要控制是否生成额外的信息,使用 ‘-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 are already at hand; some statements may execute in different places because they have been moved out of loops.
GCC 允许结合使用 ‘-g’ 和 ‘-O’ 选项。优化的代码偶尔制造一些惊异的结果:某些声明过的变量根本不存在;控制流程直接跑到没有预料到的地方;某些语句因为计算结果是常量或已经确定而没有执行;某些语句在其他地方执行,因为他们被移到循环外面了。
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.
如果 GCC 支持输出多种调试信息,下面的选项则非常有用。
occasionally [əˈkeɪʒnəli]:adv. 偶尔,间或
nevertheless [nevəðə'les]:adv. 然而,不过,虽然如此 conj. 然而,不过
reasonable ['riːz(ə)nəb(ə)l]:adj. 合理的,公道的,通情达理的
These options control various sorts of optimizations.
这些选项控制多种优化措施。
-O
-O1
Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function.
优化。对于大函数,优化编译占用稍微多的时间和相当大的内存.
With ‘-O’
, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time.
使用了 ‘-O’ 选项,编译器会试图减少目标码的大小和执行时间,而不执行任何需要大量编译时间的优化。
‘-O’
turns on the following optimization flags:
‘-O’ 打开以下优化标记:
-fauto-inc-dec
-fbranch-count-reg
-fcombine-stack-adjustments
-fcompare-elim
-fcprop-registers
-fdce
-fdefer-pop
-fdelayed-branch
-fdse
-fforward-propagate
-fguess-branch-probability
-fif-conversion2
-fif-conversion
-finline-functions-called-once
-fipa-pure-const
-fipa-profile
-fipa-reference
-fmerge-constants
-fmove-loop-invariants
-fshrink-wrap
-fsplit-wide-types
-ftree-bit-ccp
-ftree-ccp
-fssa-phiopt
-ftree-ch
-ftree-copy-prop
-ftree-copyrename
-ftree-dce
-ftree-dominator-opts
-ftree-dse
-ftree-forwprop
-ftree-fre
-ftree-phiprop
-ftree-sink
-ftree-slsr
-ftree-sra
-ftree-pta
-ftree-ter
-funit-at-a-time
‘-O’
also turns on ‘-fomit-frame-pointer’
on machines where doing so does not interfere with debugging.
‘-O’ 也会在机器上打开 ‘-fomit-frame-pointer’,这样做不会干扰调试。
interfere [ɪntə'fɪə]:vi. 干涉,妨碍,打扰 vt. 冲突,介入
-O 与 -O1 相同。
-O2
Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to ‘-O’
, this option increases both compilation time and the performance of the generated code.
多优化一些。除了涉及空间和速度交换的优化选项,执行几乎所有的优化工作。和 ‘-O’ 选项比较,这个选项既增加了编译时间,也提高了生成代码的运行效果。
‘-O2’
turns on all optimization flags specified by ‘-O’
. It also turns on the following optimization flags:
-O2’ 打开了所有 ‘-O’ 指定的优化。它也打开以下优化标记:
-fthread-jumps
-falign-functions -falign-jumps
-falign-loops -falign-labels
-fcaller-saves
-fcrossjumping
-fcse-follow-jumps -fcse-skip-blocks
-fdelete-null-pointer-checks
-fdevirtualize -fdevirtualize-speculatively
-fexpensive-optimizations
-fgcse -fgcse-lm
-fhoist-adjacent-loads
-finline-small-functions
-findirect-inlining
-fipa-cp
-fipa-cp-alignment
-fipa-sra
-fipa-icf
-fisolate-erroneous-paths-dereference
-flra-remat
-foptimize-sibling-calls
-foptimize-strlen
-fpartial-inlining
-fpeephole2
-freorder-blocks -freorder-blocks-and-partition -freorder-functions
-frerun-cse-after-loop
-fsched-interblock -fsched-spec
-fschedule-insns -fschedule-insns2
-fstrict-aliasing -fstrict-overflow
-ftree-builtin-call-dce
-ftree-switch-conversion -ftree-tail-merge
-ftree-pre
-ftree-vrp
-fipa-ra
Please note the warning under ‘-fgcse’
about invoking ‘-O2’
on programs that use computed gotos.
请注意 ‘-fgcse’ 下关于在使用 computed gotos 的程序上调用 ‘-O2’ 的警告。
-O3
Optimize yet more. ‘-O3’
turns on all optimizations specified by ‘-O2’
and also turns on the ‘-finline-functions’
, ‘-funswitch-loops’
, ‘-fpredictive-commoning’
, ‘-fgcse-after-reload’
, ‘-ftree-loop-vectorize’
, ‘-ftree-loop-distribute-patterns’
, ‘-ftree-slp-vectorize’
, ‘-fvect-cost-model’
, ‘-ftree-partial-pre’
and ‘-fipa-cp-clone’
options.
优化的更多。‘-O3’ 除了打开 ‘-O2’ 所做的一切,它还打开了 ‘-finline-functions’, ‘-funswitch-loops’, ‘-fpredictive-commoning’, ‘-fgcse-after-reload’, ‘-ftree-loop-vectorize’, ‘-ftree-loop-distribute-patterns’, ‘-ftree-slp-vectorize’, ‘-fvect-cost-model’, ‘-ftree-partial-pre’ and ‘-fipa-cp-clone’ 选项.
-O0
Reduce compilation time and make debugging produce the expected results.
减少编译时间并使调试产生预期的结果。
This is the default.
这是默认值。
-Os
Optimize for size. ‘-Os’
enables all ‘-O2’
optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.
优化尺寸。 ‘-Os’ 支持所有 ‘-O2’ 优化,通常不会增加代码大小。它还执行旨在减少代码大小的进一步优化。
‘-Os’
disables the following optimization flags:
-falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays
-Ofast
Disregard strict standards compliance. ‘-Ofast’
enables all ‘-O3’
optimizations. It also enables optimizations that are not valid for all standard compliant programs. It turns on ‘-ffast-math’
and the Fortran-specific ‘-fno-protect-parens’
and ‘-fstack-arrays’
.
无视严格的标准合规性。‘-Ofast’ 启用所有 ‘-O3’ 优化。它还支持对所有符合标准的程序无效的优化。
Ofast
将不会严格遵循语言标准,除了启用所有的 -O3
优化选项之外,也会针对某些语言启用部分优化。
#pragma GCC optimize(“Ofast”)
-Og
Optimize debugging experience. ‘-Og’
enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.
If you use multiple ‘-O’
options, with or without level numbers, the last such option is the one that is effective.
优化调试体验。‘-Og’ 启用不会干扰调试的优化。它应该是标准编辑 - 编译 - 调试周期的优化级别,提供合理的优化级别,同时保持快速编译和良好的调试体验。
如果你使用多个‘-O’ 选项,有或没有等级号,最后一个这样的选项是有效的选项。
disregard [dɪsrɪ'gɑːd]:vt. 忽视,不理,漠视,不顾 n. 忽视,不尊重
These options control the C preprocessor, which is run on each C source file before actual compilation.
这些选项控制 C 预处理器,它在实际编译之前在每个 C 源文件上运行。
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.
如果使用 ‘-E’ 选项,除预处理外不执行任何操作。其中一些选项只与 ‘-E’ 一起使用,因为它们会导致预处理器输出不适合实际编译。
-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’, ‘-Wtrigraphs’, ‘-Wmultichar’ 以及关于整数提升的警告,导致 #if 表达式中的符号发生变化。请注意,许多预处理程序的警告默认情况下处于启用状态,并且没有控制它们的选项。
These options come into play when the compiler links object files into an executable output file. They are meaningless if the compiler is not doing a link step.
当编译器将对象文件链接到可执行输出文件时,这些选项会起作用。如果编译器没有进行链接步骤,它们就毫无意义。
meaningless ['miːnɪŋlɪs]:adj. 无意义的,无目的的
object-file-name
A file name that does not end in a special recognized suffix is considered to name an object file or library. (Object files are distinguished from libraries by the linker according to the file contents.) If linking is done, these object files are used as input to the linker.
不以特殊识别后缀结尾的文件名称被视为命名对象文件或库。(链接器根据文件内容将对象文件与库区分开来。) 如果完成链接,则将这些对象文件用作链接器的输入。
-c
-S
-E
If any of these options is used, then the linker is not run, and object file names should not be used as arguments. See Section 3.2 [Overall Options], page 26.
如果使用了这些选项中的任何一个,则不会运行链接器,并且不应将对象文件名用作参数。
-fuse-ld=bfd
Use the bfd linker instead of the default linker.
-fuse-ld=gold
Use the gold linker instead of the default linker.
-llibrary
-l library
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)
链接时搜索名为 library 的库。(将库作为单独参数的第二种方法仅适用于POSIX,不建议使用。)
compliance [kəm'plaɪəns]:n. 顺从,服从,承诺
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’
searches library ‘z’
after file ‘foo.o’
but before ‘bar.o’
. If ‘bar.o’
refers to functions in ‘z’
, those functions may not be loaded.
它在您编写此选项的命令中有所不同,链接器按照指定的顺序搜索和处理库和对象文件。因此,‘foo.o -lz bar.o’ 在 ‘foo.o’ 之后但在 ‘bar.o’之前搜索库 ‘z’。 如果 ‘bar.o’ 引用 ‘z’ 中的函数,则可能无法加载这些函数。
The linker searches a standard list of directories for the library, which is actually a file named ‘liblibrary.a’
. The linker then uses this file as if it had been specified precisely by name.
链接器搜索库的标准目录列表,实际上是名为 ‘liblibrary.a’ 的文件库。然后,链接器使用此文件,就好像它已按名称精确指定一样。
The directories searched include several standard system directories plus any that you specify with ‘-L’
.
搜索的目录包括几个标准系统目录以及您使用 ‘-L’ 指定的任何目录。
Normally the files found this way are library files - archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an ‘-l’
option and specifying a file name is that ‘-l’
surrounds library with ‘lib’
and ‘.a’
and searches several directories.
通常情况下,这种方式发现的文件是库文件 - 存档文件的成员是对象文件。链接器通过扫描存档文件来处理存档文件,以查找迄今为止已引用但尚未定义的符号的成员。但是,如果发现的是一个普通的物体,它是以通常的方式联系在一起的。使用 ‘-l’ 选项和指定文件名之间的唯一区别是 ‘-l’ 围绕带有 ‘lib’ and ‘.a’ 的库并搜索多个目录。
-lobjc
You need this special case of the ‘-l’
option in order to link an Objective-C or Objective-C++ program.
您需要这个 ‘-l’ 选项的特殊情况才能链接 Objective-C 或 Objective-C++ 程序。
-s
Remove all symbol table and relocation information from the executable.
从可执行文件中删除所有符号表和重定位信息。
-static
On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.
在支持动态链接的系统上,这会阻止与共享库的链接。在其他系统上,此选项无效。
-shared
Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options used for compilation (‘-fpic’
, ‘-fPIC’
, or model suboptions) when you specify this linker option.1
生成一个共享对象,然后可以将其与其他对象链接以形成可执行文件。并非所有系统都支持此选项。对于可预测的结果,在指定此链接器选项时,还必须指定用于编译的相同选项集 (‘-fpic’, ‘-fPIC’, or model suboptions)。
1On some systems, ‘gcc -shared’
needs to build supplementary stub code for constructors to work. On multi-libbed systems, ‘gcc -shared’
must select the correct support libraries to link against. Failing to supply the correct flags may lead to subtle defects. Supplying them in cases where they are not necessary is innocuous.
在某些系统上, ‘gcc -shared’ 需要为构造函数构建补充存根代码才能工作。 在多库系统上, gcc -shared’ 必须选择要链接的正确支持库。 未能提供正确的标签可能会导致细微的缺陷。在没有必要的情况下提供它们是无害的。
stub code:桩代码
innocuous [ɪ'nɒkjʊəs]:adj. 无害的,无伤大雅的
stub [stʌb]:n. 存根,烟蒂,树桩,断株 vt. 踩熄,连根拔除
These options specify directories to search for header files, for libraries and for parts of the compiler:
这些选项指定用于搜索头文件,库和编译器部分的目录:
-Idir
Add the directory dir to the head of the list of directories to be searched for header files. This can be used to override a system header file, substituting your own version, since these directories are searched before the system header file directories. However, you should not use this option to add directories that contain vendor-supplied system header files (use ‘-isystem’
for that). If you use more than one ‘-I’
option, the directories are scanned in left-to-right order; the standard system directories come after.
将目录 dir 添加到要搜索的目录列表的头部以查找 header files。 这可以用于覆盖系统头文件,替换您自己的版本,因为这些目录在系统头文件目录之前被搜索。但是,您不应使用此选项添加包含供应商提供的系统头文件的目录 (use ‘-isystem’ for that)。 如果使用多个 ‘-I’ 选项,则按从左到右的顺序扫描目录,标准系统目录紧跟其后。
override [əʊvə'raɪd]:vt. 推翻,不顾,践踏 n. 代理佣金
substitute ['sʌbstɪtjuːt]:n. 代用品,代替者 vi. 替代 vt. 代替
If a standard system include directory, or a directory specified with ‘-isystem’
, is also specified with ‘-I’
, the ‘-I’
option is ignored. The directory is still searched but as a system directory at its normal position in the system include chain. This is to ensure that GCC’s procedure to fix buggy system headers and the ordering for the include_next
directive are not inadvertently changed.
如果标准系统包含目录,或者使用 ‘-isystem’ 指定的目录,也使用 ‘-I’ 指定,则忽略 ‘-I’ 选项。目录仍在搜索中,但作为系统目录在系统包含链中的正常位置。 这是为了确保 GCC 修复错误系统头的过程和 include_next 指令的顺序不会被无意中更改。
If you really need to change the search order for system directories, use the ‘-nostdinc’
and/or ‘-isystem’
options.
如果确实需要更改系统目录的搜索顺序,请使用 ‘-nostdinc’ and/or ‘-isystem’ 选项。
-iplugindir=dir
Set the directory to search for plugins that are passed by ‘-fplugin=name’
instead of ‘-fplugin=path/name.so’
. This option is not meant to be used by the user, but only passed by the driver.
设置目录以搜索由‘-fplugin=name’ 而不是 ‘-fplugin=path/name.so’传递的插件。此选项不是由用户使用,而是仅由驱动程序传递。
-iquotedir
Add the directory dir to the head of the list of directories to be searched for header files only for the case of #include "file"
; they are not searched for #include <file>
, otherwise just like ‘-I’
.
将目录 dir 添加到要搜索的目录列表的头部,仅针对 #include “file”,他们不会搜索 #include ,否则就像 ‘-I’ 一样。
-Ldir
Add directory dir to the list of directories to be searched for ‘-l’
.
将目录 dir 添加到要搜索 ‘-l’ 的目录列表中。
在 ‘-l’ 选项的搜索路径列表中添加 dir 目录。
These machine-independent options control the interface conventions used in code generation.
这些与机器无关的选项控制代码生成中使用的接口约定。
Most of them have both positive and negative forms; the negative form of ‘-ffoo’
is ‘-fno-foo’
. In the table below, only one of the forms is listed - the one that is not the default. You can figure out the other form by either removing ‘no-’
or adding it.
他们中的大多数都有正和负的形式。‘-ffoo’ 的否定形式是 ‘-fno-foo’。在下表中,仅列出了其中一个表单 - 非默认表单。 您可以通过删除 ‘no-’ 或添加它来确定其他形式。
-fpic
Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine. Such code accesses all constant addresses through a global offset table (GOT). The dynamic loader resolves the GOT entries when the program starts (the dynamic loader is not part of GCC; it is part of the operating system). If the GOT size for the linked executable exceeds a machine-specific maximum size, you get an error message from the linker indicating that ‘-fpic’
does not work; in that case, recompile with ‘-fPIC’
instead. (These maximums are 8k on the SPARC and 32k on the m68k and RS/6000. The x86 has no such limit.)
如果 target machine 支持,则生成适用于共享库的位置无关代码 (PIC)。这样的代码通过全局偏移表 (GOT) 访问所有常量地址。程序启动时动态加载程序解析 GOT 条目 (动态加载程序不是 GCC 的一部分,它是操作系统的一部分)。如果链接可执行文件的 GOT 大小超过计算机特定的最大大小,则会从链接器收到错误消息,指示 ‘-fpic’ 不起作用。在这种情况下,用 ‘-fPIC’ 重新编译。(These maximums are 8k on the SPARC and 32k on the m68k and RS/6000. The x86 has no such limit.)
Position-independent code requires special support, and therefore works only on certain machines. For the x86, GCC supports PIC for System V but not for the Sun 386i. Code generated for the IBM RS/6000 is always position-independent. When this flag is set, the macros __pic__
and __PIC__
are defined to 1.
与位置无关的代码需要特殊支持,因此仅适用于某些机器。
-fPIC
If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, PowerPC and SPARC.
Position-independent code requires special support, and therefore works only on certain machines.
When this flag is set, the macros __pic__
and __PIC__
are defined to 2.
如果 target machine 支持该选项,则生成与位置无关的代码,适用于动态链接并避免对全局偏移表的大小进行任何限制。此选项对 m68k, PowerPC and SPARC 产生影响。
与位置无关的代码需要特殊支持,因此仅适用于某些机器。
如果目标机器支持该选项,编译器就输出位置无关目标码。适用于动态连接 (dynamic linking),分支可以大范围转移.
machine-independent:adj. 与机器无关的,独立于机器的
global offset table,GOT
position-independent code,PIC
convention [kən'venʃ(ə)n]:n. 大会,惯例,约定,协定,习俗
Scalable Processor Architecture,SPARC:可扩展处理器结构