[Git][ghc/ghc][wip/hadrian-windows-bindist-cross] 2 commits: hadrian: Add ghcToolchain to tool args list

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Mon Aug 21 09:54:34 UTC 2023



Matthew Pickering pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC


Commits:
e59bf0da by Matthew Pickering at 2023-08-21T10:50:56+01:00
hadrian: Add ghcToolchain to tool args list

This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.

- - - - -
2cb4425f by Matthew Pickering at 2023-08-21T10:51:49+01:00
ghc-toolchain: Normalise triple via config.sub

We were not normalising the target triple anymore like we did with the
old make build system.

TODO: Should the target prefix use the normalised or unnormalised
platform?

- - - - -


5 changed files:

- hadrian/src/Rules/ToolArgs.hs
- utils/ghc-toolchain/exe/Main.hs
- utils/ghc-toolchain/ghc-toolchain.cabal
- + utils/ghc-toolchain/src/GHC/Toolchain/NormaliseTriple.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Program.hs


Changes:

=====================================
hadrian/src/Rules/ToolArgs.hs
=====================================
@@ -159,6 +159,8 @@ toolTargets = [ binary
               , ghcBoot
               , ghcBootTh
               , ghcPlatform
+              , ghcToolchain
+              , ghcToolchainBin
               , ghcHeap
               , ghci
               , ghcPkg  -- # executable


=====================================
utils/ghc-toolchain/exe/Main.hs
=====================================
@@ -31,6 +31,7 @@ import GHC.Toolchain.Tools.Ranlib
 import GHC.Toolchain.Tools.Nm
 import GHC.Toolchain.Tools.MergeObjs
 import GHC.Toolchain.Tools.Readelf
+import GHC.Toolchain.NormaliseTriple (normaliseTriple)
 
 data Opts = Opts
     { optTriple    :: String
@@ -367,15 +368,17 @@ ldOverrideWhitelist a =
     _ -> False
 
 
+
 mkTarget :: Opts -> M Target
 mkTarget opts = do
+    normalised_triple <- normaliseTriple (optTriple opts)
     -- Use Llvm target if specified, otherwise use triple as llvm target
-    let tgtLlvmTarget = fromMaybe (optTriple opts) (optLlvmTriple opts)
+    let tgtLlvmTarget = fromMaybe normalised_triple (optLlvmTriple opts)
     cc0 <- findCc tgtLlvmTarget (optCc opts)
     cxx <- findCxx tgtLlvmTarget (optCxx opts)
     cpp <- findCpp (optCpp opts) cc0
     hsCpp <- findHsCpp (optHsCpp opts) cc0
-    (archOs, tgtVendor) <- parseTriple cc0 (optTriple opts)
+    (archOs, tgtVendor) <- parseTriple cc0 normalised_triple
     cc <- addPlatformDepCcFlags archOs cc0
     readelf <- optional $ findReadelf (optReadelf opts)
     ccLink <- findCcLink tgtLlvmTarget (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf


=====================================
utils/ghc-toolchain/ghc-toolchain.cabal
=====================================
@@ -17,6 +17,7 @@ library
                       GHC.Toolchain.Prelude,
                       GHC.Toolchain.Program,
                       GHC.Toolchain.ParseTriple,
+                      GHC.Toolchain.NormaliseTriple,
                       GHC.Toolchain.CheckArm,
                       GHC.Toolchain.Target,
                       GHC.Toolchain.Tools.Ar,


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/NormaliseTriple.hs
=====================================
@@ -0,0 +1,10 @@
+module GHC.Toolchain.NormaliseTriple where
+
+import GHC.Toolchain.Prelude
+import GHC.Toolchain.Program
+
+normaliseTriple :: String -> M String
+normaliseTriple triple = do
+  normalised_triple <- readProgramStdout shProgram ["config.sub", triple]
+  logInfo $ unwords ["Normalised triple:", triple, "~>", normalised_triple]
+  return normalised_triple


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Program.hs
=====================================
@@ -1,5 +1,6 @@
 module GHC.Toolchain.Program
     ( Program(..)
+    , shProgram
     , _prgPath
     , _prgFlags
     , addFlagIfNew
@@ -37,6 +38,9 @@ data Program = Program { prgPath :: FilePath
                        }
     deriving (Read, Eq, Ord)
 
+shProgram :: Program
+shProgram = Program "sh" []
+
 instance Show Program where
   -- Normalise filepaths before showing to aid with diffing the target files.
   show (Program p f) = unwords



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/405783aec573b35e099280e7968bec00212b2e82...2cb4425ff38c1ba3dccbf6da634ff55f16e0a16c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/405783aec573b35e099280e7968bec00212b2e82...2cb4425ff38c1ba3dccbf6da634ff55f16e0a16c
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/20230821/adf1bf3c/attachment-0001.html>


More information about the ghc-commits mailing list