aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/17_intro
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-11-16 08:53:51 -0500
committerPatrick Palka <ppalka@redhat.com>2022-11-16 08:53:51 -0500
commitec59848074ba8c4310cbadb603822bfaeff03a32 (patch)
tree137b51eb3c81cb951f57c7665fb74c2712c756fc /libstdc++-v3/testsuite/17_intro
parentc5e8c6c193d9a1ab80ef1a05e5158ddf35d54009 (diff)
downloadgcc-ec59848074ba8c4310cbadb603822bfaeff03a32.zip
gcc-ec59848074ba8c4310cbadb603822bfaeff03a32.tar.gz
gcc-ec59848074ba8c4310cbadb603822bfaeff03a32.tar.bz2
libstdc++: Fix stream initialization with static library [PR107701]
When linking with a static library, the linker seems to discard a constituent .o object (including its global initializers) if nothing defined in the object is referenced by the program (unless e.g. --whole-archive is used). This behavior breaks iostream with static libstdc++.a (on systems that support init priorities) because we define the global initializer for the standard stream objects in a separate TU (ios_init.cc) from the stream object definitions (globals_io.cc). This patch fixes this by moving the stream initialization object into the same TU that defines the stream objects, so that any use of the streams prevents the linker from discarding this global initializer. PR libstdc++/107701 libstdc++-v3/ChangeLog: * include/std/iostream (__ioinit): Adjust comment. * src/c++98/globals_io.cc: Include "io_base_init.h" here instead of ... * src/c++98/ios_init.cc: ... here. * src/c++98/ios_base_init.h (__ioinit): More comments. * testsuite/17_intro/static.cc: dg-do run instead of just link.
Diffstat (limited to 'libstdc++-v3/testsuite/17_intro')
-rw-r--r--libstdc++-v3/testsuite/17_intro/static.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/libstdc++-v3/testsuite/17_intro/static.cc b/libstdc++-v3/testsuite/17_intro/static.cc
index ffa7ecb..a0d6ed0 100644
--- a/libstdc++-v3/testsuite/17_intro/static.cc
+++ b/libstdc++-v3/testsuite/17_intro/static.cc
@@ -1,4 +1,4 @@
-// { dg-do link { target c++11 } }
+// { dg-do run { target c++11 } }
// { dg-require-static-libstdcxx }
// { dg-options "-static-libstdc++" }