This fixes a regression since SVN r334523, where the object files built targeting MinGW were rejected by GNU binutils tools. Prior to that commit, we only put constants in comdat for MSVC configurations.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
include/llvm/CodeGen/TargetLoweringObjectFileImpl.h | ||
---|---|---|
137 ↗ | (On Diff #152770) | I'd prefer it if we didn't put this here, but instead put something in MCAsmInfo, like the existing HasCOFFAssociativeComdats. |
lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
1354–1356 ↗ | (On Diff #152770) | It'd be nicer to spell this as a positive check for a gnu or cygwin environment. |
include/llvm/CodeGen/TargetLoweringObjectFileImpl.h | ||
---|---|---|
137 ↗ | (On Diff #152770) | Ok, what'd be a sensible name for it - HasCOFFComdatConstantSections? |
lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
1354–1356 ↗ | (On Diff #152770) | Yes, it probably would. I matched the condition used in the other function moved in the commit that introduced the issue, but I can change it. |
I've pinned down the GNU bfd incompatibility to this:
$ cat const.s .section .rdata,"dr",discard,val .LCPI0_0: .byte 0 $ clang -target x86_64-w64-mingw32 -c const.s -o const.o -c $ x86_64-w64-mingw32-objdump -d const.o const.o: file format pe-x86-64 x86_64-w64-mingw32-objdump: const.o: Unrecognized storage class 0 for .rdata symbol `val' x86_64-w64-mingw32-objdump: failed to read symbol table from: const.o x86_64-w64-mingw32-objdump: error message was: File in wrong format
If I make the symbol val a proper symbol, either by adding a val: in the file, or a .globl val (changing the symbol table entry value from IMAGE_SYM_CLASS_NULL to something else).
I think this maybe even could use the existing flag HasCOFFAssociativeComdats instead of inventing a new one, since it seems to be pretty closely related to the same concept.
As @rnk doesn't seem to be active at the moment to give this the extra ack (and while this is pretty much what he suggested in the earlier review), I'll go ahead and commit this, since it fixes a regression.