public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "baker at usgs dot gov" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/54630] [4.8 Regression] GCC 4.8 --enable-languages=c build fails: Undefined symbols: ___cxa_guard_acquire and ___cxa_guard_release Date: Fri, 21 Sep 2012 18:58:00 -0000 [thread overview] Message-ID: <bug-54630-4-bQhGGG4wWF@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-54630-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54630 --- Comment #4 from Larry Baker <baker at usgs dot gov> 2012-09-21 18:56:20 UTC --- Richard, On both Mac OS X and Linux, the link step uses gcc. On Mac OS X, the link succeed; on Linux, the link fails. The LINKER is selected by the following logic in the gcc/Makefile: # The name of the compiler to use. COMPILER = $(CXX) COMPILER_FLAGS = $(CXXFLAGS) # If HOST_LIBS is set, then the user is controlling the libraries to # link against. In that case, link with $(CC) so that the -lstdc++ # library is not introduced. If HOST_LIBS is not set, link with # $(CXX) to pick up -lstdc++. ifeq ($(HOST_LIBS),) LINKER = $(CXX) LINKER_FLAGS = $(CXXFLAGS) else LINKER = $(CC) LINKER_FLAGS = $(CFLAGS) endif The reason LINKER is set to gcc on both systems is I use the configure --with-host-libstdcxx option: Mac OS X: --with-host-libstdcxx='-lstdc++ -lm' Linux: --with-host-libstdcxx='-static-libgcc -static-libstdc++ -lm' (I don't know why the -lm is there; I copied that from Sourcery's ColdFire uClinux SDK build script.) which defines HOST_LIBS in gcc/Makefile: # Libraries to use on the host. Mac OS X: HOST_LIBS = -lstdc++ -lm Linux: HOST_LIBS = -static-libgcc -static-libstdc++ -lm The original --with-host-libstdcxx from Sourcery (Mentor Graphics) ColdFire uClinux SDK build scripts was: --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' I guess Sourcery used '-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' so that the cross compilers would not have system library dependencies, and could be delivered in a tarball that would work on many Linux systems without introducing a shared-llibrary dependency. I altered that to use the more recent gcc option -static-libstdc++ in place of -Wl,-Bstatic,-lstdc++,-Bdynamic. I'm thinking a couple things are happening: • On Mac OS X, the link works because I do not use static libraries (Mac OS X does not support them), and -lstdc++ brings in the O/S version of guard.cc. • On CentOS Linux 6.3, gcc is too old to recognize -static-libstdc++. (I'm assuming a more recent gcc driver recognizes it; it may be that it is only recognized by the g++ driver.) I'll try to make a more recent HOST gcc that supports -static-libstdc++. (Anyone know which release added it?) However, I do not understand the logic of selecting gcc in the first place. --with-host-libstdcxx is described at http://gcc.gnu.org/install/configure.html: --with-host-libstdcxx=linker-args If you are linking with a static copy of PPL, you can use this option to specify how the linker should find the standard C++ library used internally by PPL. Typical values of linker-args might be `-lstdc++' or `-Wl,-Bstatic,-lstdc++,-Bdynamic -lm'. If you are linking with a shared copy of PPL, you probably do not need this option; shared library dependencies will cause the linker to search for the standard C++ library automatically. This implies two things to me: 1) This is the only way to pass linker args (that I could find) 2) This is for c++ (...-libstdcxx means c++, right?) The "linker-args" get turned into HOST_LIBS in gcc/Makefile, used to define LIBS and BACKENDLIBS: # How to link with both our special library facilities # and the system's installed libraries. LIBS = libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY) \ $(LIBDECNUMBER) $(HOST_LIBS) BACKENDLIBS = $(CLOOGLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \ $(ZLIB) which, to me, means something different than "linker-args". It seems to me that a main program compiled by g++ should be linked by g++. Linker args are a separate matter. In any case, the web page should probably be updated to warn that --with-host-libstdcxx causes ALL linking (at least for the compilers) to use gcc instead of g++. This matters now because GCC's implementation language changes from C to C++ with release 4.8.
next prev parent reply other threads:[~2012-09-21 18:58 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-09-19 21:15 [Bug libstdc++/54630] New: " baker at usgs dot gov 2012-09-20 11:37 ` [Bug middle-end/54630] [4.8 Regression] " rguenth at gcc dot gnu.org 2012-09-20 20:28 ` baker at usgs dot gov 2012-09-20 20:30 ` baker at usgs dot gov 2012-09-21 18:58 ` baker at usgs dot gov [this message] 2012-09-21 19:17 ` baker at usgs dot gov 2012-09-21 20:35 ` baker at usgs dot gov 2012-09-22 1:14 ` baker at usgs dot gov 2012-09-22 1:45 ` baker at usgs dot gov 2012-09-25 1:53 ` baker at usgs dot gov 2012-11-19 3:02 ` jason at gcc dot gnu.org 2012-11-19 13:44 ` jakub at gcc dot gnu.org 2012-11-20 9:24 ` jakub at gcc dot gnu.org 2012-11-20 19:58 ` baker at usgs dot gov 2012-11-20 20:20 ` jakub at gcc dot gnu.org 2012-11-20 22:25 ` baker at usgs dot gov 2012-11-21 11:20 ` redi at gcc dot gnu.org 2012-11-21 21:38 ` baker at usgs dot gov 2012-11-22 0:51 ` ian at airs dot com 2012-11-26 19:44 ` baker at usgs dot gov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-54630-4-bQhGGG4wWF@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).