libstdc++: Only use std::ios_base_library_init() for ELF [PR116159]
commitfc7a1fb0238e379d466316aa219734ac61f4bc0e
authorJonathan Wakely <jwakely@redhat.com>
Tue, 10 Sep 2024 13:36:26 +0000 (10 14:36 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 10 Sep 2024 17:23:30 +0000 (10 18:23 +0100)
treea8dfcc736e6b8e81ec42e3998138659d2c7e34f7
parentc07cf418fdde0c192e370a8d76a991cc7215e9c4
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.
libstdc++-v3/include/std/iostream
libstdc++-v3/src/c++98/ios_init.cc