aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-09-10 14:36:26 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2024-09-10 18:23:30 +0100
commitfc7a1fb0238e379d466316aa219734ac61f4bc0e (patch)
treea8dfcc736e6b8e81ec42e3998138659d2c7e34f7
parentc07cf418fdde0c192e370a8d76a991cc7215e9c4 (diff)
downloadgcc-fc7a1fb0238e379d466316aa219734ac61f4bc0e.zip
gcc-fc7a1fb0238e379d466316aa219734ac61f4bc0e.tar.gz
gcc-fc7a1fb0238e379d466316aa219734ac61f4bc0e.tar.bz2
libstdc++: Only use std::ios_base_library_init() for ELF [PR116159]
The undefined std::ios_base_library_init() symbol that is referenced by <iostream> is only supposed to be used for targets where symbol versioning is supported. The mingw-w64 target defaults to --enable-symvers=gnu due to using GNU ld but doesn't actually support symbol versioning. This means it tries to emit references to the std::ios_base_library_init() symbol, which isn't really defined in the library. This causes problems when using lld to link user binaries. Disable the undefined symbol reference for non-ELF targets. libstdc++-v3/ChangeLog: PR libstdc++/116159 * include/std/iostream (ios_base_library_init): Only define for ELF targets. * src/c++98/ios_init.cc (ios_base_library_init): Likewise.
-rw-r--r--libstdc++-v3/include/std/iostream2
-rw-r--r--libstdc++-v3/src/c++98/ios_init.cc2
2 files changed, 2 insertions, 2 deletions
diff --git a/libstdc++-v3/include/std/iostream b/libstdc++-v3/include/std/iostream
index 4f4fa68..4a6dc58 100644
--- a/libstdc++-v3/include/std/iostream
+++ b/libstdc++-v3/include/std/iostream
@@ -78,7 +78,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if !(_GLIBCXX_USE_INIT_PRIORITY_ATTRIBUTE \
&& __has_attribute(__init_priority__))
static ios_base::Init __ioinit;
-#elif defined(_GLIBCXX_SYMVER_GNU)
+#elif defined(_GLIBCXX_SYMVER_GNU) && defined(__ELF__)
__extension__ __asm (".globl _ZSt21ios_base_library_initv");
#endif
diff --git a/libstdc++-v3/src/c++98/ios_init.cc b/libstdc++-v3/src/c++98/ios_init.cc
index 1422e20..6e2e501 100644
--- a/libstdc++-v3/src/c++98/ios_init.cc
+++ b/libstdc++-v3/src/c++98/ios_init.cc
@@ -199,7 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __ret;
}
-#ifdef _GLIBCXX_SYMVER_GNU
+#if defined(_GLIBCXX_SYMVER_GNU) && defined(__ELF__)
#pragma GCC diagnostic ignored "-Wattribute-alias"
void ios_base_library_init (void)