This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[build, lto-plugin] Check for -static-libgcc before use (PR lto/60981)
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Paolo Bonzini <bonzini at gnu dot org>
- Date: Wed, 14 May 2014 10:31:30 +0200
- Subject: [build, lto-plugin] Check for -static-libgcc before use (PR lto/60981)
- Authentication-results: sourceware.org; auth=none
As reported in the PR, the lto-plugin may fail to link if the host
compiler defines __GNUC__, but doesn't accept -static-libgcc (like
recent versions of clang do).
The following patch fixes this by explicitly checking for -static-libgcc
instead of relying on __GNUC__/$GNUC.
Tested by configuring lto-plugin with Studio cc (which doesn't define
__GNUC__) and gcc. The submitter also verified that the patch fixes his
problem.
Ok for mainline and the 4.9 branch?
Rainer
2014-05-13 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR lto/60981
* configure.ac: Check for -static-libgcc.
* configure: Regenerate.
# HG changeset patch
# Parent bde9dfb664a2e0b4b142432eb8f79f82660e7ab2
Check for -static-libgcc before use (PR lto/60981)
diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
--- a/lto-plugin/configure.ac
+++ b/lto-plugin/configure.ac
@@ -7,9 +7,21 @@ AM_MAINTAINER_MODE
AC_PROG_CC
AC_SYS_LARGEFILE
ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_lto_plugin_warn_cflags])
+
+# Check whether -static-libgcc is supported.
+saved_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -static-libgcc"
+AC_MSG_CHECKING([for -static-libgcc])
+AC_LINK_IFELSE([
+ int main() {}], [have_static_libgcc=yes], [have_static_libgcc=no])
+AC_MSG_RESULT($have_static_libgcc);
+LDFLAGS="$saved_LDFLAGS"
# Need -Wc to get it through libtool.
-if test "x$GCC" = xyes; then ac_lto_plugin_ldflags="-Wc,-static-libgcc"; fi
+if test "x$have_static_libgcc" = xyes; then
+ ac_lto_plugin_ldflags="-Wc,-static-libgcc"
+fi
AC_SUBST(ac_lto_plugin_ldflags)
+
AM_PROG_LIBTOOL
ACX_LT_HOST_FLAGS
AC_SUBST(target_noncanonical)
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University