[Git][ghc/ghc][wip/toolchain-selection] 2 commits: Re-introduce flags in hadrian config
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Mon May 8 12:59:35 UTC 2023
Rodrigo Mesquita pushed to branch wip/toolchain-selection at Glasgow Haskell Compiler / GHC
Commits:
db50d45e by Rodrigo Mesquita at 2023-05-08T13:31:08+01:00
Re-introduce flags in hadrian config
- - - - -
c8a95b77 by Rodrigo Mesquita at 2023-05-08T13:59:30+01:00
ROMES WIP
- - - - -
4 changed files:
- hadrian/bindist/config.mk.in
- hadrian/cfg/system.config.in
- hadrian/src/Builder.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
Changes:
=====================================
hadrian/bindist/config.mk.in
=====================================
@@ -234,16 +234,28 @@ GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64 s390x), at UseL
# might become redundant.
# See Note [tooldir: How GHC finds mingw on Windows]
+GccExtraViaCOpts = @GccExtraViaCOpts@
LdHasFilelist = @LdHasFilelist@
LdSupportsResponseFiles = @LdSupportsResponseFiles@
LdHasBuildId = @LdHasBuildId@
LdHasFilelist = @LdHasFilelist@
LdIsGNULd = @LdIsGNULd@
LdHasNoCompactUnwind = @LdHasNoCompactUnwind@
+ArArgs = @ArArgs@
+ArSupportsAtFile = @ArSupportsAtFile@
+ArSupportsDashL = @ArSupportsDashL@
HaskellHostOs = @HaskellHostOs@
HaskellHostArch = @HaskellHostArch@
+HaskellTargetOs = @HaskellTargetOs@
+HaskellTargetArch = @HaskellTargetArch@
+TargetWordSize = @TargetWordSize@
+TargetWordBigEndian = @TargetWordBigEndian@
+TargetHasGnuNonexecStack = @TargetHasGnuNonexecStack@
+TargetHasIdentDirective = @TargetHasIdentDirective@
+TargetHasSubsectionsViaSymbols = @TargetHasSubsectionsViaSymbols@
TargetHasRTSLinker = @TargetHasRTSLinker@
TargetHasLibm = @TargetHasLibm@
+TablesNextToCode = @TablesNextToCode@
SettingsCCompilerCommand = @SettingsCCompilerCommand@
SettingsCxxCompilerCommand = @SettingsCxxCompilerCommand@
=====================================
hadrian/cfg/system.config.in
=====================================
@@ -39,7 +39,9 @@ python = @PythonCmd@
# Information about builders:
#============================
+ar-supports-at-file = @ArSupportsAtFile@
system-ar-supports-at-file = @ArSupportsAtFile_STAGE0@
+ar-supports-dash-l = @ArSupportsDashL@
system-ar-supports-dash-l = @ArSupportsDashL_STAGE0@
cc-llvm-backend = @CcLlvmBackend@
hs-cpp-args = @HaskellCPPArgs@
@@ -47,8 +49,11 @@ hs-cpp-args = @HaskellCPPArgs@
# Build options:
#===============
+ghc-unregisterised = @Unregisterised@
+tables-next-to-code = @TablesNextToCode@
use-libffi-for-adjustors = @UseLibffiForAdjustors@
ghc-source-path = @hardtop@
+leading-underscore = @LeadingUnderscore@
# Information about build, host and target systems:
#==================================================
@@ -136,6 +141,7 @@ ld-has-no-compact-unwind = @LdHasNoCompactUnwind@
ld-has-filelist = @LdHasFilelist@
ld-supports-response-files = @LdSupportsResponseFiles@
ld-is-gnu-ld = @LdIsGNULd@
+ar-args = @ArArgs@
settings-c-compiler-command = @SettingsCCompilerCommand@
settings-cxx-compiler-command = @SettingsCxxCompilerCommand@
=====================================
hadrian/src/Builder.hs
=====================================
@@ -43,6 +43,10 @@ import qualified Data.ByteString as BS
import qualified GHC.Foreign as GHC
import GHC.ResponseFile
+import GHC.Toolchain (Target(..))
+import qualified GHC.Toolchain as Toolchain
+import GHC.Toolchain.Program
+
-- | C compiler can be used in two different modes:
-- * Compile or preprocess a source file.
-- * Extract source dependencies by passing @-MM@ command line argument.
@@ -415,18 +419,18 @@ isOptional = \case
systemBuilderPath :: Builder -> Action FilePath
systemBuilderPath builder = case builder of
Alex -> fromKey "alex"
- Ar _ (Stage0 {})-> fromKey "system-ar"
- Ar _ _ -> fromKey "ar"
+ Ar _ (Stage0 {})-> fromHostTC "system-ar" (Toolchain.arMkArchive . tgtAr)
+ Ar _ _ -> fromTargetTC "ar" (Toolchain.arMkArchive . tgtAr)
Autoreconf _ -> stripExe =<< fromKey "autoreconf"
- Cc _ (Stage0 {}) -> fromKey "system-cc"
- Cc _ _ -> fromKey "cc"
+ Cc _ (Stage0 {}) -> fromHostTC "system-cc" (Toolchain.ccProgram . tgtCCompiler)
+ Cc _ _ -> fromTargetTC "cc" (Toolchain.ccProgram . tgtCCompiler)
-- We can't ask configure for the path to configure!
Configure _ -> return "configure"
Ghc _ (Stage0 {}) -> fromKey "system-ghc"
GhcPkg _ (Stage0 {}) -> fromKey "system-ghc-pkg"
Happy -> fromKey "happy"
HsCpp -> fromKey "hs-cpp"
- Ld _ -> fromKey "ld"
+ Ld _ -> fromTargetTC "ld" (Toolchain.ccLinkProgram . tgtCCompilerLink) -- ROMES:TODO ld vs cLink
-- MergeObjects Stage0 is a special case in case of
-- cross-compiling. We're building stage1, e.g. code which will be
-- executed on the host and hence we need to use host's merge
@@ -435,15 +439,15 @@ systemBuilderPath builder = case builder of
-- parameters. E.g. building a cross-compiler on and for x86_64
-- which will target ppc64 means that MergeObjects Stage0 will use
-- x86_64 linker and MergeObject _ will use ppc64 linker.
- MergeObjects (Stage0 {}) -> fromKey "system-merge-objects"
- MergeObjects _ -> fromKey "merge-objects"
+ MergeObjects (Stage0 {}) -> fromHostTC "system-merge-objects" (maybeProg Toolchain.mergeObjsProgram . tgtMergeObjs)
+ MergeObjects _ -> fromTargetTC "merge-objects" (maybeProg Toolchain.mergeObjsProgram . tgtMergeObjs)
Make _ -> fromKey "make"
Makeinfo -> fromKey "makeinfo"
- Nm -> fromKey "nm"
+ Nm -> fromTargetTC "nm" (Toolchain.nmProgram . tgtNm)
Objdump -> fromKey "objdump"
Patch -> fromKey "patch"
Python -> fromKey "python"
- Ranlib -> fromKey "ranlib"
+ Ranlib -> fromTargetTC "ranlib" (maybeProg Toolchain.ranlibProgram . tgtRanlib)
Testsuite _ -> fromKey "python"
Sphinx _ -> fromKey "sphinx-build"
Tar _ -> fromKey "tar"
@@ -459,10 +463,23 @@ systemBuilderPath builder = case builder of
let unpack = fromMaybe . error $ "Cannot find path to builder "
++ quote key ++ inCfg ++ " Did you skip configure?"
path <- unpack <$> lookupValue configFile key
+ validate key path
+
+ -- Get program from the host's target configuration
+ fromHostTC keyname key = do
+ path <- queryHostTargetConfig (prgPath . key)
+ validate keyname path
+
+ -- Get program from the target's target configuration
+ fromTargetTC keyname key = do
+ path <- queryTargetTargetConfig (prgPath . key)
+ validate keyname path
+
+ validate keyname path = do
if null path
then do
unless (isOptional builder) . error $ "Non optional builder "
- ++ quote key ++ " is not specified" ++ inCfg
+ ++ quote keyname ++ " is not specified" ++ inCfg
return "" -- TODO: Use a safe interface.
else do
-- angerman: I find this lookupInPath rather questionable.
@@ -488,6 +505,8 @@ systemBuilderPath builder = case builder of
exists <- doesFileExist s
if exists then return s else return sNoExt
+ maybeProg = maybe (Program "" [])
+
-- | Was the path to a given system 'Builder' specified in configuration files?
isSpecified :: Builder -> Action Bool
=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
=====================================
@@ -48,14 +48,14 @@ data Target = Target
-- C toolchain
, tgtCCompiler :: Cc
, tgtCxxCompiler :: Cxx
- , tgtCPreprocessor :: Cpp
+ , tgtCPreprocessor :: Cpp -- ROMES:TODO: Is this hs-cpp or cpp? Do I need both?
, tgtCCompilerLink :: CcLink
-- , tgtLd :: Program -- needed?
-- , tgtLdSupportsCompactUnwind :: Bool
-- , tgtLdSupportsFilelist :: Bool
-- , tgtLdIsGnuLd :: Bool -- needed?
, tgtAr :: Ar
- , tgtRanlib :: Maybe Ranlib
+ , tgtRanlib :: Maybe Ranlib -- why is this marked as maybe?
, tgtNm :: Nm
, tgtMergeObjs :: Maybe MergeObjs
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e0c7fdc84f685dd884d0133b4290636136606f02...c8a95b770fa4b1f4eba4ff4c3479f62a1168a4e1
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e0c7fdc84f685dd884d0133b4290636136606f02...c8a95b770fa4b1f4eba4ff4c3479f62a1168a4e1
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/20230508/0e99bcc1/attachment-0001.html>
More information about the ghc-commits
mailing list