[commit: ghc] ghc-8.2: Add -fuse-ld flag to CFLAGS during configure (0798908)

git at git.haskell.org git at git.haskell.org
Tue Jul 4 00:16:53 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/0798908f1729629c2d90a56baae06919874b42a4/ghc

>---------------------------------------------------------------

commit 0798908f1729629c2d90a56baae06919874b42a4
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Mon Jul 3 19:09:39 2017 -0400

    Add -fuse-ld flag to CFLAGS during configure
    
    The decisions made by configure later in the script may depend upon the
    linker used. Consequently, it is important that configure uses the same
    linker as GHC will eventually use.
    
    For instance, on Nix I found that a program requiring `libpthread` would
    link fine with only `-lrt` when linked with BFD ld. However, with gold
    we needed to explicitly provide the `-lpthread` dependency. Presumably
    the former would happily loaded any `NEEDED` libraries whereas the
    latter wants them explicitly given. Regardless, since `configure`'s
    `NEED_PTHREAD_LIB` check didn't use the `-fuse-ld` flag that GHC would
    eventually use, we inferred the wrong value, resulting in link errors
    later in the build.
    
    Test Plan: Validate
    
    Reviewers: austin, hvr
    
    Subscribers: rwbarton, thomie, erikd
    
    GHC Trac Issues: #13541
    
    Differential Revision: https://phabricator.haskell.org/D3694
    
    (cherry picked from commit 960918bd1f7e3811845a525ba85bbd390ddf28c8)


>---------------------------------------------------------------

0798908f1729629c2d90a56baae06919874b42a4
 configure.ac            | 1 +
 distrib/configure.ac.in | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configure.ac b/configure.ac
index 27d879d..bad688a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -501,6 +501,7 @@ FIND_LD([$target],[GccUseLdOpt])
 CONF_GCC_LINKER_OPTS_STAGE1="$CONF_GCC_LINKER_OPTS_STAGE1 $GccUseLdOpt"
 CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2 $GccUseLdOpt"
 LdCmd="$LD"
+CFLAGS="$CFLAGS $GccUseLdOpt"
 AC_SUBST([LdCmd])
 
 dnl ** Which nm to use?
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index ee9a105..3d2d90d 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -121,6 +121,7 @@ FIND_LD([$target],[GccUseLdOpt])
 CONF_GCC_LINKER_OPTS_STAGE1="$CONF_GCC_LINKER_OPTS_STAGE1 $GccUseLdOpt"
 CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2 $GccUseLdOpt"
 LdCmd="$LD"
+CFLAGS="$CFLAGS $GccUseLdOpt"
 AC_SUBST([LdCmd])
 
 FP_PROG_LD_IS_GNU



More information about the ghc-commits mailing list