[Git][ghc/ghc][wip/romes/remove-toolchain-runtime-config] 3 commits: Configure -Wl,--no-as-needed
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Mon Jun 26 15:53:50 UTC 2023
Rodrigo Mesquita pushed to branch wip/romes/remove-toolchain-runtime-config at Glasgow Haskell Compiler / GHC
Commits:
6b16eb91 by Rodrigo Mesquita at 2023-06-26T16:53:31+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
- - - - -
e5e045aa by Rodrigo Mesquita at 2023-06-26T16:53:39+01:00
fstackcheck
- - - - -
35a2d172 by Rodrigo Mesquita at 2023-06-26T16:53:39+01:00
Fixes
- - - - -
3 changed files:
- compiler/GHC/Driver/DynFlags.hs
- + m4/fp_link_supports_no_as_needed.m4
- m4/fptools_set_c_ld_flags.m4
Changes:
=====================================
compiler/GHC/Driver/DynFlags.hs
=====================================
@@ -116,7 +116,6 @@ import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Reader (ReaderT)
import Control.Monad.Trans.Writer (WriterT)
-import Data.IORef
import System.IO
import System.IO.Error (catchIOError)
import System.Environment (lookupEnv)
=====================================
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 -c -o conftest.a.o conftest.a.c > /dev/null 2>&1
+ $CC -c -o conftest.b.o conftest.b.c > /dev/null 2>&1
+ 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,9 +17,19 @@ 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"
+ # Emit stack checks
+ # See Note [Windows stack allocations]
+ $3="$$3 -fstack-check"
;;
i386-portbld-freebsd*)
$2="$$2 -march=i686"
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0794e273f1ea4468b3bf288e4bcefa2986bc80c4...35a2d172f4366a6efce223805901c5fbc8783329
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0794e273f1ea4468b3bf288e4bcefa2986bc80c4...35a2d172f4366a6efce223805901c5fbc8783329
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/7042e423/attachment-0001.html>
More information about the ghc-commits
mailing list