[Git][ghc/ghc][wip/toolchain-selection] 5 commits: Fix stack job
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Tue Jun 20 18:19:24 UTC 2023
Rodrigo Mesquita pushed to branch wip/toolchain-selection at Glasgow Haskell Compiler / GHC
Commits:
12216ec3 by Rodrigo Mesquita at 2023-06-20T15:11:15+01:00
Fix stack job
- - - - -
6131a50e by Rodrigo Mesquita at 2023-06-20T18:36:13+01:00
ghc-toolchain: Create default.target in the bindist
- - - - -
5272b0d0 by Rodrigo Mesquita at 2023-06-20T18:37:42+01:00
Part of -Wl,--no-as-needed saga
- - - - -
361f9bc9 by Rodrigo Mesquita at 2023-06-20T19:10:28+01:00
Support more targets and dont use llvmtarget
- - - - -
aebdaeb0 by Rodrigo Mesquita at 2023-06-20T19:10:45+01:00
fixup! Part of -Wl,--no-as-needed saga
- - - - -
9 changed files:
- distrib/configure.ac.in
- hadrian/bindist/config.mk.in
- hadrian/src/Rules/BinaryDist.hs
- hadrian/stack.yaml
- m4/fptools_set_c_ld_flags.m4
- m4/ghc_toolchain.m4
- utils/ghc-toolchain/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
Changes:
=====================================
distrib/configure.ac.in
=====================================
@@ -286,7 +286,7 @@ AC_SUBST(UseLibdw)
FP_SETTINGS
AC_CONFIG_FILES([config.mk])
-#ROMES:TODO AC_CONFIG_FILES([default.target])
+AC_CONFIG_FILES([default.target])
AC_OUTPUT
# We get caught by
=====================================
hadrian/bindist/config.mk.in
=====================================
@@ -255,6 +255,8 @@ TargetHasIdentDirective = @TargetHasIdentDirective@
TargetHasSubsectionsViaSymbols = @TargetHasSubsectionsViaSymbols@
TargetHasLibm = @TargetHasLibm@
TablesNextToCode = @TablesNextToCode@
+LeadingUnderscore = @LeadingUnderscore@
+LlvmTarget = @LlvmTarget@
SettingsCCompilerCommand = @SettingsCCompilerCommand@
SettingsCxxCompilerCommand = @SettingsCxxCompilerCommand@
=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -258,6 +258,7 @@ bindistRules = do
need $ map (bindistFilesDir -/-)
(["configure", "Makefile"] ++ bindistInstallFiles)
copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in")
+ copyFile ("default.target.in") (bindistFilesDir -/- "default.target.in")
forM_ bin_targets $ \(pkg, _) -> do
needed_wrappers <- pkgToWrappers pkg
forM_ needed_wrappers $ \wrapper_name -> do
=====================================
hadrian/stack.yaml
=====================================
@@ -2,7 +2,7 @@ resolver: lts-19.8
packages:
- '.'
-- 'utils/ghc-toolchain'
+- '../utils/ghc-toolchain'
nix:
enable: false
=====================================
m4/fptools_set_c_ld_flags.m4
=====================================
@@ -17,8 +17,9 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
;;
esac
+ -- ROMES:TODO: ELF, mention note
case $$1 in
- *-linux)
+ *-linux|*-freebsd*)
FP_LINK_SUPPORTS_NO_AS_NEEDED([$3])
;;
esac
=====================================
m4/ghc_toolchain.m4
=====================================
@@ -28,10 +28,9 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
utils/ghc-toolchain/Main.hs -o acghc-toolchain
rm -f acargs
- dnl TODO: LLVMTarget vs Target, which should go where?
- dnl echo "--triple=$target" >> acargs
- dnl For now, LlvmTarget matches the configure output.
- echo "--triple=$LlvmTarget" >> acargs
+
+ echo "--triple=$target" >> acargs
+ echo "--llvm-triple=$LlvmTarget" >> acargs
# echo "--cc=$CC" >> acargs
# ADD_GHC_TOOLCHAIN_ARG([cc-opt], [$CONF_CC_OPTS_STAGE1])
=====================================
utils/ghc-toolchain/Main.hs
=====================================
@@ -5,7 +5,7 @@ module Main where
import Control.Monad
import Data.Char (toUpper)
-import Data.Maybe (isNothing)
+import Data.Maybe (isNothing,fromMaybe)
import System.Exit
import System.Console.GetOpt
import System.Environment
@@ -33,6 +33,7 @@ import GHC.Toolchain.Tools.Readelf
data Opts = Opts
{ optTriple :: String
, optTargetPrefix :: Maybe String
+ , optLlvmTriple :: Maybe String
, optCc :: ProgOpt
, optCxx :: ProgOpt
, optCpp :: ProgOpt
@@ -57,6 +58,7 @@ emptyOpts :: Opts
emptyOpts = Opts
{ optTriple = ""
, optTargetPrefix = Nothing
+ , optLlvmTriple = Nothing
, optCc = po0
, optCxx = po0
, optCpp = po0
@@ -98,6 +100,9 @@ _optWindres = Lens optWindres (\x o -> o {optWindres=x})
_optTriple :: Lens Opts String
_optTriple = Lens optTriple (\x o -> o {optTriple=x})
+_optLlvmTriple :: Lens Opts (Maybe String)
+_optLlvmTriple = Lens optLlvmTriple (\x o -> o {optLlvmTriple=x})
+
_optTargetPrefix :: Lens Opts (Maybe String)
_optTargetPrefix = Lens optTargetPrefix (\x o -> o {optTargetPrefix=x})
@@ -123,6 +128,7 @@ options :: [OptDescr (Opts -> Opts)]
options =
[ tripleOpt
, targetPrefixOpt
+ , llvmTripleOpt
, verbosityOpt
, keepTempOpt
] ++
@@ -174,6 +180,7 @@ options =
]
tripleOpt = Option ['t'] ["triple"] (ReqArg (set _optTriple) "TRIPLE") "Target triple"
+ llvmTripleOpt = Option [] ["llvm-triple"] (ReqArg (set _optLlvmTriple . Just) "LLVMTRIPLE") "LLVM Target triple"
targetPrefixOpt = Option ['T'] ["target-prefix"] (ReqArg (set _optTargetPrefix . Just) "PREFIX")
"A target prefix which will be added to all tool names when searching for toolchain components"
@@ -297,7 +304,8 @@ archHasNativeAdjustors = \case
mkTarget :: Opts -> M Target
mkTarget opts = do
- let tgtLlvmTarget = optTriple opts
+ -- Use Llvm target if specified, otherwise use triple as llvm target
+ let tgtLlvmTarget = fromMaybe (optTriple opts) (optLlvmTriple opts)
cc0 <- findCc tgtLlvmTarget (optCc opts)
cxx <- findCxx tgtLlvmTarget (optCxx opts)
cpp <- findCpp (optCpp opts) cc0
=====================================
utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
=====================================
@@ -38,7 +38,7 @@ parseArch cc arch =
"s390x" -> pure ArchS390X
"arm" -> findArmIsa cc
_ | "armv" `isPrefixOf` arch -> findArmIsa cc
- "arm64" -> pure ArchAArch64 -- TODO Should we support this alias or does this cause confusion?
+ "arm64" -> pure ArchAArch64
"aarch64" -> pure ArchAArch64
"alpha" -> pure ArchAlpha
"mips" -> pure ArchMipseb
@@ -46,6 +46,7 @@ parseArch cc arch =
"mipsel" -> pure ArchMipsel
"riscv64" -> pure ArchRISCV64
"hppa" -> pure ArchUnknown
+ "wasm32" -> pure ArchWasm32
_ -> throwE $ "Unknown architecture " ++ arch
parseOs :: String -> String -> M OS
@@ -68,6 +69,7 @@ parseOs vendor os =
"nto-qnc" -> pure OSQNXNTO
"aix" -> pure OSAIX
"gnu" -> pure OSHurd
+ "wasi" -> pure OSWasi
_ -> throwE $ "Unknown vendor/operating system " ++ vendor ++ "-" ++ os
splitOn :: Char -> String -> [String]
=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
=====================================
@@ -126,6 +126,11 @@ checkSupportsNoPie ccLink = checking "whether the cc linker supports -no-pie" $
(code, out, _err) <- readProgram ccLink ["-no-pie", "-Werror", "-x", "c", test_c, "-o", test]
return (isSuccess code && not ("unrecognized" `isInfixOf` out))
+-- ROMES:TODO: This check is wrong here and in configure because with ld.gold parses "-n" "o_compact_unwind"
+-- TODO:
+-- * Check if compiling for darwin
+-- * Then do the check
+-- * Otherwise say its just not supported
checkSupportsCompactUnwind :: Cc -> Program -> M Bool
checkSupportsCompactUnwind cc ccLink = checking "whether the cc linker understands -no_compact_unwind" $
withTempDir $ \dir -> do
@@ -155,6 +160,7 @@ checkSupportsFilelist cc ccLink = checking "whether the cc linker understands -f
return (isSuccess exitCode)
+-- ROMES:TODO: Move to MergeTools, don't use neither of these, check that merging works with the @args.txt
checkSupportsResponseFiles :: Cc -> Program -> M Bool
checkSupportsResponseFiles cc ccLink = checking "whether the cc linker supports response files" $
withTempDir $ \dir -> do
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d179661ef6c07326c7c811376371065bbb9351b4...aebdaeb0f77e4f561ebdb19d4567bae20f608f98
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d179661ef6c07326c7c811376371065bbb9351b4...aebdaeb0f77e4f561ebdb19d4567bae20f608f98
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/20230620/41bd2be0/attachment-0001.html>
More information about the ghc-commits
mailing list