From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8418 invoked by alias); 4 Sep 2012 16:51:58 -0000 Received: (qmail 8407 invoked by uid 22791); 4 Sep 2012 16:51:56 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KAM_STOCKGEN X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 04 Sep 2012 16:51:44 +0000 From: "simonb at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/54482] New: catch-22 in static linking with libstdc++ fails Date: Tue, 04 Sep 2012 16:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simonb at google dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-09/txt/msg00262.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54482 Bug #: 54482 Summary: catch-22 in static linking with libstdc++ fails Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: simonb@google.com Libstdc++ uses '#ifdef PIC' as a proxy for deciding when to include versioned symbols. However, libtool will set -DPIC if -fPIC, even if the code being built is not destined for a shared library. This leads to versioned symbols being compiled into libstdc++.a, and the resulting static libstdc++ can then fail to link. Can be triggered by 'configure --with-pic=yes ...' recommended by __cxxabiv1::__forced_unwind. See also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28811#c19 Example, using current 4.8 head at r190920: $ cat /tmp/hello-world.cc #include void func() { std::cout << "Hello, world" << std::endl; } $ configure --disable-bootstrap --enable-languages=c,c++ --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu $ make..., make install... g++ -shared -fPIC -static-libstdc++ -Wl,-whole-archive -o /dev/null /tmp/hello-world.cc /usr/bin/ld: /usr/local/google/home/simonb/install_clean/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../lib64/libstdc++.a(compatibility.o): relocation R_X86_64_32 against `_ZTIN10__cxxabiv115__forced_unwindE' can not be used when making a shared object; recompile with -fPIC $ configure --with-pic=yes --disable-bootstrap --enable-languages=c,c++ --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu $ make..., make install... $ ../install/bin/g++ -shared -fPIC -static-libstdc++ -Wl,-whole-archive -o /dev/null /tmp/hello-world.cc /usr/bin/ld: /dev/null: version node not found for symbol _ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv@GLIBCXX_3.4