Compilation time

Karel Gardas karel.gardas at centrum.cz
Sat Jul 8 06:47:35 UTC 2017


On 07/ 8/17 01:33 AM, Ben Gamari wrote:
> 8.2 will prefer both gold and lld over bfd ld. However two conditions
> must hold for these to be used,
>
>   * The ld.lld/ld.gold executable must be in $PATH (or explicitly named
>     by passing the LD variable to configure)
>
>   * $CC must understand the `-fuse-ld={gold,lld}` option. For (IMHO quite
>     silly) political reasons, gcc doesn't support `-fuse-ld=lld`. Debian
>     happens to patch gcc to add support but I don't know how common this
>     is in other distributions.
>
> Unfortunately, some earlier `gcc` versions didn't fail if given a
> `-fuse-ld` option that they didn't understand. Sadly we have no reliable
> way to detect this, so in this case we may end up passing a `-fuse-ld`
> option that gcc simply ignores.

I've run into this issue too, but it looks like the issue is not in gcc, 
but in ghc's aclocal.m4 (one '$' missing). Attached patch solves this on 
OpenBSD 6.1-current where HEAD fails building on linker error. It passes 
build-id option to the gcc's linker (bfd ld) which does not support it 
as configure detects lld is presented on this system too.

Sorry for not being able to push that through usual arc.

Thanks,
Karel

-------------- next part --------------
diff --git a/aclocal.m4 b/aclocal.m4
index 677c0e77bc..921f137b95 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2278,6 +2278,7 @@ AC_DEFUN([FIND_LD],[
       [enable_ld_override=yes])
 
     if test "x$enable_ld_override" = "xyes"; then
+        BACKUP_LD="$LD"
         AC_CHECK_TARGET_TOOLS([LD], [ld.gold ld.lld ld])
         UseLd=''
 
@@ -2288,8 +2289,13 @@ AC_DEFUN([FIND_LD],[
           "LLD"*)      FP_CC_LINKER_FLAG_TRY(lld, $2) ;;
           *) AC_MSG_NOTICE([unknown linker version $out]) ;;
         esac
-        if test "z$2" = "z"; then
+        if test "z$$2" = "z"; then
             AC_MSG_NOTICE([unable to convince '$CC' to use linker '$LD'])
+            # disable ld override and recheck with just ld
+            enable_ld_override=no
+            LD="$BACKUP_LD"
+            unset ac_cv_prog_ac_ct_LD
+            AC_CHECK_TARGET_TOOL([LD], [ld])
         fi
    else
         AC_CHECK_TARGET_TOOL([LD], [ld])


More information about the ghc-devs mailing list