[PATCH] D48402: [mingw] Fix GCC ABI compatibility for comdat things

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 21 12:56:12 PDT 2018


mstorsjo added a comment.

In https://reviews.llvm.org/D48402#1139600, @rnk wrote:

> In https://reviews.llvm.org/D48402#1138925, @mstorsjo wrote:
>
> > Seems sensible to me. I've tested this change with LLD as linker as well, and it worked just fine for building Qt, and for a small test setup similar to the example in the issue report.
>
>
> Hm, I would expect LLD to do the wrong thing for .pdata and .xdata under this scheme.


Oh - I didn't actually test anything that uses that; I'm only using sjlj or dwarf for exception handling ATM, since libcxxabi doesn't support SEH exeptions yet.

> It looks like LLD is tossing the otherwise unreferenced .pdata and .xdata for the inline function that starts at RVA 0x001050.
> 
> If we want LLD to support linking mingw object files from GCC, we'll need to do some extra work in LLD.

Even if they're supposed to be interoperable, more or less, it's not completely compatible in all ways.

Currently, there's three different MinGW scenarios wrt compilation+linking that actually work:

1. Compiling with GCC, linking with ld.bfd (a completely traditional MinGW environment, normally together with libgcc and libstdc++)
2. Compiling with clang, linking with ld.bfd (just plugging in clang as compiler in an otherwise traditional MinGW environment, still using libgcc+libstdc++)
3. Compiling with clang, linking with LLD (using compiler-rt and libcxx)

The third setup is what I and Martell have been working on; the produced object files should otherwise be identical to the ones in case 2 (modulo any use of `-fdwarf-exceptions`). The fourth plausible combo, compiling with GCC but linking with LLD, most probably doesn't work right now - I haven't tried but would expect there to be lots of details missing in LLD.

If we make clang start producing this, how hard would it be to make LLD handle it gracefully? (I don't think I've touched the comdat handling in LLD significantly.)


https://reviews.llvm.org/D48402





More information about the llvm-commits mailing list