[Git][ghc/ghc][wip/romes/remove-toolchain-runtime-config] Configure -Wl,--no-as-needed
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Mon Jun 26 15:00:07 UTC 2023
Rodrigo Mesquita pushed to branch wip/romes/remove-toolchain-runtime-config at Glasgow Haskell Compiler / GHC
Commits:
53ea4e07 by Rodrigo Mesquita at 2023-06-26T15:59:51+01:00
Configure -Wl,--no-as-needed
To fixup, but this is one of the things we must now configure instead of
determine at runtime
Be sure to enumerate those in a bullet list
- - - - -
2 changed files:
- + m4/fp_link_supports_no_as_needed.m4
- m4/fptools_set_c_ld_flags.m4
Changes:
=====================================
m4/fp_link_supports_no_as_needed.m4
=====================================
@@ -0,0 +1,33 @@
+# FP_LINK_SUPPORTS_NO_AS_NEEDED
+# ----------------------------------
+# Set the Cc linker flag -Wl,--no-as-needed if it is supported
+# $1 is the name of the linker flags variable when linking with gcc
+# See also Note [ELF needed shared libs]
+AC_DEFUN([FP_LINK_SUPPORTS_NO_AS_NEEDED],
+[
+ AC_MSG_CHECKING([whether Cc linker supports -Wl,--no-as-needed])
+ echo 'int f(int a) {return 2*a;}' > conftest.a.c
+ echo 'int f(int a); int main(int argc, char **argv) {return f(0);}' > conftest.b.c
+ $CC -o conftest.a.o conftest.a.c
+ $CC -o conftest.b.o conftest.b.c
+ if "$CC" "$$1" -Wl,--no-as-needed -o conftest conftest.a.o conftest.b.o > /dev/null 2>&1
+ then
+ $1="$$1 -Wl,--no-as-needed"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ rm -f conftest*
+])
+
+# Note [ELF needed shared libs]
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Some distributions change the link editor's default handling of
+# ELF DT_NEEDED tags to include only those shared objects that are
+# needed to resolve undefined symbols. For Template Haskell we need
+# the last temporary shared library also if it is not needed for the
+# currently linked temporary shared library. We specify --no-as-needed
+# to override the default. This flag exists in GNU ld and GNU gold.
+#
+# The flag is only needed on ELF systems. On Windows (PE) and Mac OS X
+# (Mach-O) the flag is not needed.
=====================================
m4/fptools_set_c_ld_flags.m4
=====================================
@@ -17,6 +17,13 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
;;
esac
+ # See Note [ELF needed shared libs]
+ case $$1 in
+ *-linux|*-freebsd*)
+ FP_LINK_SUPPORTS_NO_AS_NEEDED([$3])
+ ;;
+ esac
+
case $$1 in
i386-unknown-mingw32)
$2="$$2 -march=i686"
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53ea4e07001bb6cc99c7360d91f05e07484b448b
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53ea4e07001bb6cc99c7360d91f05e07484b448b
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/20230626/836e5e80/attachment-0001.html>
More information about the ghc-commits
mailing list