[Git][ghc/ghc][wip/darwin-fixes-2] Pass -Wl, -no_fixup_chains to ld64 when appropiate

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Sat Jan 7 11:32:31 UTC 2023



Matthew Pickering pushed to branch wip/darwin-fixes-2 at Glasgow Haskell Compiler / GHC


Commits:
cf1ee2ef by Matthew Pickering at 2023-01-07T11:32:21+00:00
Pass -Wl,-no_fixup_chains to ld64 when appropiate

Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default.
This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we
explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on
darwin. This results in a warning of the form:

ld: warning: -undefined dynamic_lookup may not work with chained fixups

The manual explains the incompatible nature of these two flags:

     -undefined treatment
             Specifies how undefined symbols are to be treated. Options are: error, warning,
             suppress, or dynamic_lookup.  The default is error. Note: dynamic_lookup that
             depends on lazy binding will not work with chained fixups.

A relevant ticket is #22429

Here are also a few other links which are relevant to the issue:

Official comment: https://developer.apple.com/forums/thread/719961

More relevant links:

https://openradar.appspot.com/radar?id=5536824084660224

https://github.com/python/cpython/issues/97524

Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas    e-notes

- - - - -


2 changed files:

- configure.ac
- + m4/fp_ld_no_fixup_chains.m4


Changes:

=====================================
configure.ac
=====================================
@@ -658,6 +658,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG
 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
 # Stage 3 won't be supported by cross-compilation
 
+FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS])
+FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0])
+FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1])
+FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2])
+
 GHC_LLVM_TARGET_SET_VAR
 # we intend to pass trough --targets to llvm as is.
 LLVMTarget_CPP=`    echo "$LlvmTarget"`


=====================================
m4/fp_ld_no_fixup_chains.m4
=====================================
@@ -0,0 +1,24 @@
+# FP_LD_NO_FIXUP_CHAINS
+# --------------------
+# See if whether we are using a version of ld64 on darwin platforms which
+# requires us to pass -no_fixup_chains
+#
+# $1 = the platform
+# $2 = the name of the linker flags variable when linking with $CC
+AC_DEFUN([FP_LD_NO_FIXUP_CHAINS], [
+    case $$1 in
+      *-darwin)
+      AC_MSG_CHECKING([whether ld64 requires -no_fixup_chains])
+      echo 'int main(void) {return 0;}' > conftest.c
+      if $CC -o conftest.o -Wl,-no_fixup_chains conftest.c > /dev/null 2>&1
+      then
+          $2="-Wl,-no_fixup_chains"
+          AC_MSG_RESULT([yes])
+      else
+          AC_MSG_RESULT([no])
+      fi
+      rm -f conftest.c conftest.o
+      ;;
+
+    esac
+])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf1ee2ef7161514e641dc29cbe6e44f48ff72c82

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf1ee2ef7161514e641dc29cbe6e44f48ff72c82
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230107/8667b88e/attachment-0001.html>


More information about the ghc-commits mailing list