From 4e6c8f1d30b8516fc7205bbcc97a78a728215512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 24 Jun 2024 14:02:28 +0300 Subject: [clang] [MinGW] Set a predefined __GXX_TYPEINFO_EQUALITY_INLINE=0 for MinGW targets (#96062) libstdc++ requires this define to match what is predefined in GCC for the ABI of this platform; GCC hardcodes this define for all mingw configurations in gcc/config/i386/cygming.h. (It also defines __GXX_MERGED_TYPEINFO_NAMES=0, but that happens to match the defaults in libstdc++ headers, so there's no similar need to define it in Clang.) This fixes a Clang/libstdc++ interop issue discussed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110572. --- clang/lib/Frontend/InitPreprocessor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/lib/Frontend/InitPreprocessor.cpp') diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 2d5c94c..55ec460 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -934,6 +934,12 @@ static void InitializePredefinedMacros(const TargetInfo &TI, if (LangOpts.GNUCVersion && LangOpts.CPlusPlus11) Builder.defineMacro("__GXX_EXPERIMENTAL_CXX0X__"); + if (TI.getTriple().isWindowsGNUEnvironment()) { + // Set ABI defining macros for libstdc++ for MinGW, where the + // default in libstdc++ differs from the defaults for this target. + Builder.defineMacro("__GXX_TYPEINFO_EQUALITY_INLINE", "0"); + } + if (LangOpts.ObjC) { if (LangOpts.ObjCRuntime.isNonFragile()) { Builder.defineMacro("__OBJC2__"); -- cgit v1.1