This option when combined with -mgpopt and -membedded-data places all
uninitialized constant variables in the read-only section.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Address review comment.
lib/Driver/ToolChains/Clang.cpp | ||
---|---|---|
1523 ↗ | (On Diff #108359) | Yes, it warns that it's unused. |
Do you actually need a new flag for this? "-fno-common" will ensure clang doesn't generate globals with common linkage.
cfe/trunk/lib/CodeGen/TargetInfo.cpp | ||
---|---|---|
6666 | Also, this change is clearly unacceptable; among other things, messing with the linkage of static local variables is likely to lead to link errors. |
It's required for feature parity with GCC.
-fno-common will place globals into the bss section which uses memory at runtime. The -membedded-data and -muninit-const-in-rodata options are for reducing RAM usage in some embedded environments.
LLVM never puts constant data into the BSS. See isSuitableForBSS in lib/Target/TargetLoweringObjectFile.cpp.
(gcc's behavior is just weird... apparently, whether or not constant data is placed in the BSS with -fno-common depends on the syntactic form of the initializer?)
cfe/trunk/lib/CodeGen/TargetInfo.cpp | ||
---|---|---|
6666 | I will fix that. |
I don't see any reason why zero-initialised constants should be emitted in BSS. I know that GCC does that and I just fixed bugs in that because created wrong section flags for it. So yes, I'd prefer to revert this and fix the real problem.
Also, this change is clearly unacceptable; among other things, messing with the linkage of static local variables is likely to lead to link errors.