[英]GCC flags during linking
Is there any situation in which flags such as -ansi, -Wall, and -pedantic might be relevant during the linking part of the process? 在过程的链接过程中,是否存在与-ansi,-Wall和-pedantic等标记相关的情况?
What about the -O optimization flags? -O优化标志呢? Are they only relevant during the compile steps or are they also relevant during linking?
它们仅在编译步骤中相关,还是在链接期间相关?
Thanks! 谢谢!
In practice, no - but in theory, -ansi
is a dialect option, so it could conceivably affect linking. 实际上,没有
-ansi
是一种方言选项,但从理论上讲,它可能会影响链接。 I've seen similar behaviour with older versions of clang that use libc++ or libstdc++, when using C++11 or C++03 respectively. 当分别使用C ++ 11或C ++ 03时,我已经看到使用libc ++或libstdc ++的旧版clang的类似行为。 I find it easier to put these flags in the
CC
variable: CC = gcc -std=c99
or CC = gcc -std=c90
(ansi). 我发现将这些标志放在
CC
变量中比较容易: CC = gcc -std=c99
或CC = gcc -std=c90
(ansi)。
I just invoke C++ (or C) with $CXX
or $CC
out of habit. 我只是出于习惯用
$CXX
或$CC
调用C ++(或C)。 And they are passed by default to configure scripts. 并且默认情况下会传递它们以配置脚本。
I'm not aware of this being an issue with C, as long as the ABI and calling conventions haven't changed. 只要ABI和调用约定没有更改,我就不会意识到这是C的问题。 C++, on the other hand, requires changes to the C++ runtime to support new language features.
另一方面,C ++需要更改C ++运行时以支持新的语言功能。 In either case, it's the compiler that invokes the linker with the relevant libraries.
无论哪种情况,都是由编译器调用相关库的链接器。
There is link-time optimization in gcc: gcc中有链接时间优化:
-flto[=n]
This option runs the standard link-time optimizer. When invoked
with source code, it generates GIMPLE (one of GCC's internal
representations) and writes it to special ELF sections in the
object file. When the object files are linked together, all the
function bodies are read from these ELF sections and instantiated
as if they had been part of the same translation unit.
To use the link-time optimizer, -flto needs to be specified at
compile time and during the final link.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.