https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110572

--- Comment #12 from Martin Storsjö <martin at martin dot st> ---
(In reply to Jonathan Wakely from comment #11)
> CC Martin Storsjo to see if changing Clang would be possible, or if he has a
> better idea for the preprocessor check suggested in comment 9.
> 
> It might be that Clang can't pre-define this macro because it has different
> values for different mingw/mingw-w64/w64devkit toolchains, and clang
> wouldn't know which one to be compatible with a priori.

Thanks for looping me in!


In this case, as this seems to be a fixed configuration for libstdc++ (as
gcc/config/i386/cygming.h hardcodes __GXX_TYPEINFO_EQUALITY_INLINE=0), I don't
see a problem with adding this define to Clang. Clang does have a couple of
__GXX_* defines from before, but none that are target specific like this.

Next to this one, in gcc/config/i386/cygming.h, I also see
__GXX_MERGED_TYPEINFO_NAMES=0, I presume we should add that too, if we add
__GXX_TYPEINFO_EQUALITY_INLINE.


For Clang/libstdc++ interop on mingw in general, there are a couple of other
longstanding issues, where Clang defaults to -fno-emulated-tls, while GCC
defaults to -femulated-tls, and libstdc++ exposes a couple of TLS symbols
directly in the library ABI surface, e.g. in __once_callable - see e.g.
https://github.com/msys2/MINGW-packages/issues/8706. If those TLS symbols were
to be moved out of headers, accessed only through accessor functions, this
wouldn't be an issue (at the cost of a little bit of extra
performance/indirection - although cross-translation unit access of TLS
variables is more complex than for TLS variables marked static).

For that particular issue, I've raised the question whether Clang should switch
to emulated TLS by default, but the general opinion I've gathered (among e.g.
msys2 users) is that we shouldn't. There's also been talks about getting native
TLS implemented in GCC.

Msys2 works around this issue by patching LLVM, for the environments that
operate with libstdc++:
https://github.com/msys2/MINGW-packages/blob/f6e5319a54f9657ee190f9e0ea1c8d59b7d77a62/mingw-w64-llvm/0004-enable-emutls-for-mingw.patch
https://github.com/msys2/MINGW-packages/blob/f6e5319a54f9657ee190f9e0ea1c8d59b7d77a62/mingw-w64-llvm/PKGBUILD#L140-L144

Similarly, there's also an issue around whether pthreads is a default-linked
library or not. As GCC can be built either with win32 or posix thread model,
both scenarios are common, so msys2 also carries such an optional patch for
making pthreads automatically linked in, in the relevant msys2 environments.


But back to the topic of __GXX_TYPEINFO_EQUALITY_INLINE - as this seems to not
vary across known configurations, I think it should be doable to add the
definition to Clang.

Reply via email to