From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1075 invoked by alias); 21 Sep 2012 18:58:46 -0000 Received: (qmail 32238 invoked by uid 48); 21 Sep 2012 18:56:21 -0000 From: "baker at usgs dot gov" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: blocker X-Bugzilla-Who: baker at usgs dot gov X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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/msg01736.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D54630 --- Comment #4 from Larry Baker 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 =3D $(CXX) COMPILER_FLAGS =3D $(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 =3D $(CXX) LINKER_FLAGS =3D $(CXXFLAGS) else LINKER =3D $(CC) LINKER_FLAGS =3D $(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=3D'-lstdc++ -lm' Linux: --with-host-libstdcxx=3D'-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 =3D -lstdc++ -lm Linux: HOST_LIBS =3D -static-libgcc -static-libstdc++ -lm The original --with-host-libstdcxx from Sourcery (Mentor Graphics) ColdFire uClinux SDK build scripts was: --with-host-libstdcxx=3D'-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 co= uld 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: =E2=80=A2 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. =E2=80=A2 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=3Dlinker-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 cop= y of PPL, you probably do not need this option; shared library dependencies will cause the linker to search for the standard C++ library automatically.=20 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 =3D libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY) \ $(LIBDECNUMBER) $(HOST_LIBS) BACKENDLIBS =3D $(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++.= =20 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.