[Git][ghc/ghc][wip/hadrian-windows-bindist-cross] 2 commits: configure: Check whether -no-pie works when the C compiler is used as a linker
Matthew Pickering (@mpickering)
gitlab at gitlab.haskell.org
Fri Aug 25 10:27:20 UTC 2023
Matthew Pickering pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC
Commits:
b97ed852 by Matthew Pickering at 2023-08-25T11:20:47+01:00
configure: Check whether -no-pie works when the C compiler is used as a linker
`-no-pie` is a flag we pass when using the C compiler as a linker (see
pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
compiler used as a linker supports the flag, rather than just the C
compiler.
- - - - -
c0f8a817 by Matthew Pickering at 2023-08-25T11:26:28+01:00
ghc-toolchain: Remove javascript special case for --target detection
emcc when used as a linker seems to ignore the --target flag, and for
consistency with configure which now tests for --target, we remove this
special case.
- - - - -
2 changed files:
- m4/fp_gcc_supports_no_pie.m4
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
Changes:
=====================================
m4/fp_gcc_supports_no_pie.m4
=====================================
@@ -7,8 +7,9 @@ AC_DEFUN([FP_GCC_SUPPORTS_NO_PIE],
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([whether CC supports -no-pie])
echo 'int main() { return 0; }' > conftest.c
+ "$CC" $CONF_GCC_CC_OPTS_STAGE2 -c conftest.c
# Some GCC versions only warn when passed an unrecognized flag.
- if $CC -no-pie -Werror -x c conftest.c -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then
+ if "$CC" $CONF_GCC_LINKER_OPTS_STAGE2 -no-pie -Werror conftest.o -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then
CONF_GCC_SUPPORTS_NO_PIE=YES
AC_MSG_RESULT([yes])
else
=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
=====================================
@@ -58,7 +58,7 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp
_ -> do
-- If not then try to find decent linker flags
findLinkFlags ldOverride cc rawCcLink <|> pure rawCcLink
- ccLinkProgram <- linkSupportsTarget archOs cc target ccLinkProgram
+ ccLinkProgram <- linkSupportsTarget cc target ccLinkProgram
ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram
ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram
ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram
@@ -90,13 +90,10 @@ findLinkFlags enableOverride cc ccLink
| otherwise =
return ccLink
-linkSupportsTarget :: ArchOS -> Cc -> String -> Program -> M Program
+linkSupportsTarget :: Cc -> String -> Program -> M Program
-- Javascript toolchain provided by emsdk just ignores --target flag so
-- we have this special case to match with ./configure (#23744)
-linkSupportsTarget archOS _ _ c
- | ArchJavaScript <- archOS_arch archOS
- = return c
-linkSupportsTarget _ cc target link
+linkSupportsTarget cc target link
= checking "whether cc linker supports --target" $
supportsTarget (Lens id const) (checkLinkWorks cc) target link
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2a7c4fc845ef9b9f4edcb23a8f3d442437463e1...c0f8a8171817ab10b58d811509fc8d4143c9c6a9
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2a7c4fc845ef9b9f4edcb23a8f3d442437463e1...c0f8a8171817ab10b58d811509fc8d4143c9c6a9
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/20230825/fe1569e1/attachment-0001.html>
More information about the ghc-commits
mailing list