[commit: ghc] ghc-8.2: configure: Check for binutils #17166 (21cd772)

git at git.haskell.org git at git.haskell.org
Fri Jun 30 02:26:21 UTC 2017


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

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/21cd77200d52e2baa15e318efc7495d4fd34b7c0/ghc

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

commit 21cd77200d52e2baa15e318efc7495d4fd34b7c0
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Thu Jun 29 19:37:03 2017 -0400

    configure: Check for binutils #17166
    
    This bug affects bfd ld on ARMv7, causing ld to incorrectly emit
    R_REL_COPY relocations, breaking tables-next-to-code. We've known about
    it for several years now and there is not yet a fix upstream. Previously
    we would simply force use of ld.gold on ARM. However, given the rework
    of linking configuration, I thought a more principled solution was in
    order.
    
    Test Plan: Validate on armv7
    
    Reviewers: austin, hvr
    
    Subscribers: angerman, rwbarton, thomie, erikd
    
    GHC Trac Issues: #4210
    
    Differential Revision: https://phabricator.haskell.org/D3676
    
    (cherry picked from commit 6171b0b326e52221a0631cf75eb4866b36abe631)


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

21cd77200d52e2baa15e318efc7495d4fd34b7c0
 aclocal.m4 | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/aclocal.m4 b/aclocal.m4
index 2b12c0f..88af689 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2090,6 +2090,65 @@ AC_DEFUN([FIND_LD],[
             $1="$LD"
             ;;
     esac
+    CHECK_LD_COPY_BUG($1)
+])
+
+# CHECK_LD_COPY_BUG()
+# -------------------
+# Check for binutils bug #16177 present in some versions of the bfd ld
+# implementation affecting ARM relocations.
+# https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+#
+# $1 = the platform
+#
+AC_DEFUN([CHECK_LD_COPY_BUG],[
+    case $1 in
+      arm*linux*)
+        AC_CHECK_TARGET_TOOL([READELF], [readelf])
+        AC_CHECK_TARGET_TOOL([AS], [as])
+        AC_MSG_CHECKING([for ld bug 16177])
+        cat >actest.s <<-EOF
+          .globl _start
+          .p2align 4
+        _start:
+          bkpt
+
+        .data
+          .globl data_object
+        object_reference:
+          .long data_object
+          .size object_reference, 4
+EOF
+
+        cat >aclib.s <<-EOF 
+          .data
+          .globl data_object
+          .type data_object, %object
+          .size data_object, 4
+        data_object:
+            .long 123
+EOF
+
+        $AS -o aclib.o aclib.s
+        $LD -shared -o aclib.so aclib.o
+
+        $AS -o actest.o actest.s
+        $LD -o actest actest.o aclib.so
+
+        if $READELF -r actest | grep R_ARM_COPY > /dev/null; then
+            AC_MSG_RESULT([affected])
+            AC_MSG_ERROR(
+              [Your linker is affected by binutils #16177, which
+               critically breaks linkage of GHC objects. Please either upgrade
+               binutils or supply a different linker with the LD environment
+               variable.])
+        else
+            AC_MSG_RESULT([unaffected])
+        fi
+        ;;
+      *)
+        ;;
+    esac
 ])
 
 # FIND_GHC_BOOTSTRAP_PROG()



More information about the ghc-commits mailing list