diff mbox

[build,lto-plugin] Check for -static-libgcc before use (PR lto/60981)

Message ID yddppjg223h.fsf@lokon.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth May 14, 2014, 8:31 a.m. UTC
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.

Comments

Richard Biener May 14, 2014, 9:21 a.m. UTC | #1
On Wed, May 14, 2014 at 10:31 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> 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?

Ok if nobody else objects within 24h.

Thanks,
Richard.

>         Rainer
>
>
> 2014-05-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
>         PR lto/60981
>         * configure.ac: Check for -static-libgcc.
>         * configure: Regenerate.
>
>
>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University
>
diff mbox

Patch

# 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)