[Git][ghc/ghc][wip/toolchain-selection] ROMES: WIP

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon May 8 11:17:58 UTC 2023



Rodrigo Mesquita pushed to branch wip/toolchain-selection at Glasgow Haskell Compiler / GHC


Commits:
e0c7fdc8 by Rodrigo Mesquita at 2023-05-08T12:17:50+01:00
ROMES: WIP

- - - - -


20 changed files:

- hadrian/cfg/system.config.in
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Test.hs
- hadrian/src/Settings/Builders/RunTest.hs
- m4/fp_settings.m4
- m4/ghc_toolchain.m4
- utils/ghc-toolchain/src/GHC/Toolchain/Program.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Ar.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/MergeObjs.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Nm.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Ranlib.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Readelf.hs


Changes:

=====================================
hadrian/cfg/system.config.in
=====================================
@@ -131,6 +131,7 @@ conf-merge-objects-args-stage3  = @MergeObjsArgs@
 # might become redundant.
 # See Note [tooldir: How GHC finds mingw on Windows]
 
+gcc-extra-via-c-opts = @GccExtraViaCOpts@
 ld-has-no-compact-unwind = @LdHasNoCompactUnwind@
 ld-has-filelist = @LdHasFilelist@
 ld-supports-response-files = @LdSupportsResponseFiles@


=====================================
hadrian/src/Hadrian/Oracles/TextFile.hs
=====================================
@@ -1,4 +1,6 @@
+{-# OPTIONS_GHC -Wno-orphans #-} -- Orphan instances for Toolchain.Target
 {-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE StandaloneDeriving #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module     : Hadrian.Oracles.TextFile
@@ -13,7 +15,8 @@
 module Hadrian.Oracles.TextFile (
     lookupValue, lookupValueOrEmpty, lookupValueOrError, lookupSystemConfig, lookupValues,
     lookupValuesOrEmpty, lookupValuesOrError, lookupDependencies, textFileOracle,
-    getHostTargetConfig, getTargetTargetConfig
+    getHostTargetConfig, getTargetTargetConfig,
+    queryHostTargetConfig, queryTargetTargetConfig
     ) where
 
 import Control.Monad
@@ -97,6 +100,12 @@ getHostTargetConfig = getTargetConfig hostTargetFile
 getTargetTargetConfig :: Action Toolchain.Target
 getTargetTargetConfig = getTargetConfig targetTargetFile
 
+queryHostTargetConfig :: (Toolchain.Target -> String) -> Action String
+queryHostTargetConfig f = f <$> getHostTargetConfig
+
+queryTargetTargetConfig :: (Toolchain.Target -> String) -> Action String
+queryTargetTargetConfig f = f <$> getTargetTargetConfig
+
 newtype KeyValue = KeyValue (FilePath, String)
     deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
 type instance RuleResult KeyValue = Maybe String
@@ -143,21 +152,16 @@ textFileOracle = do
         putVerbose $ "| TargetFile oracle: reading " ++ quote file ++ "..."
         target <- read <$> readFile' file
         return (target :: Toolchain.Target)
-    void $ addOracle $ \(TargetFile file) -> tf file
+    void $ addOracleCache $ \(TargetFile file) -> tf file
 
--- ROMES:TODO: get back to this!!!!!!
-instance Eq Toolchain.Target where
-  (==) _ _ = True
+-- Orphan instances for (ShakeValue Toolchain.Target)
+instance Binary Toolchain.Target where
+  put = put  . show
+  get = read <$> get
 
-instance Ord Toolchain.Target where
-  (<=) _ _ = False
 instance Hashable Toolchain.Target where
-  hashWithSalt _ _ = 0
-instance Binary Toolchain.Target where
-  put _ = undefined
-  get   = undefined
+  hashWithSalt s = hashWithSalt s . show
 
 instance NFData Toolchain.Target where
-  rnf _ = ()
-
+  rnf = flip seq () -- ROMES:TODO: Is this a good enough instance?
 


=====================================
hadrian/src/Oracles/Flag.hs
=====================================
@@ -55,6 +55,9 @@ data FlagKey = SystemConfigKey String
 -- fragile, but some flags do behave like this.
 flag :: Flag -> Action Bool
 flag f = do
+    -- ROMES:TODO: Use queryToolchainConfig directly, which perhaps allows us
+    -- to get rid of the Oracle for the whole toolchain, which requires weak
+    -- orphan instances.
     let flagkey :: FlagKey = case f of
             ArSupportsAtFile     -> TargetTargetKey (Toolchain.arSupportsAtFile . tgtAr)
             ArSupportsDashL      -> TargetTargetKey (Toolchain.arSupportsDashL  . tgtAr)
@@ -100,7 +103,7 @@ getFlag = expr . flag
 -- when appropriate).
 platformSupportsGhciObjects :: Action Bool
 platformSupportsGhciObjects =
-    not . null <$> settingsFileSetting SettingsFileSetting_MergeObjectsCommand
+    not . null <$> settingsFileSetting ToolchainSetting_MergeObjectsCommand
 
 arSupportsDashL :: Stage -> Action Bool
 arSupportsDashL (Stage0 {}) = flag SystemArSupportsDashL


=====================================
hadrian/src/Oracles/Setting.hs
=====================================
@@ -3,7 +3,7 @@ module Oracles.Setting (
     -- * Settings
     Setting (..), SettingList (..), setting, settingList, getSetting,
     getSettingList,
-    SettingsFileSetting (..), settingsFileSetting,
+    ToolchainSetting (..), settingsFileSetting,
 
     -- * Helpers
     ghcCanonVersion, cmdLineLengthLimit, hostSupportsRPaths, topDirectory,
@@ -23,6 +23,9 @@ import Hadrian.Oracles.Path
 
 import Base
 
+import GHC.Toolchain
+import GHC.Toolchain.Program
+
 -- | Each 'Setting' comes from the file @hadrian/cfg/system.config@, generated
 -- by the @configure@ script from the input file @hadrian/cfg/system.config.in at .
 -- For example, the line
@@ -103,32 +106,32 @@ data SettingList = ConfCcArgs Stage
 -- from aclocal.m4 whenever they can be calculated from other variables
 -- already fed into Hadrian.
 
--- | Each 'SettingsFileSetting' is defined by 'FP_SETTINGS' in aclocal.m4.
--- Eventually much of that local can probably be computed just in Hadrian.
-data SettingsFileSetting
-    = SettingsFileSetting_CCompilerCommand
-    | SettingsFileSetting_CxxCompilerCommand
-    | SettingsFileSetting_HaskellCPPCommand
-    | SettingsFileSetting_HaskellCPPFlags
-    | SettingsFileSetting_CCompilerFlags
-    | SettingsFileSetting_CxxCompilerFlags
-    | SettingsFileSetting_CCompilerLinkFlags
-    | SettingsFileSetting_CCompilerSupportsNoPie
-    | SettingsFileSetting_LdCommand
-    | SettingsFileSetting_LdFlags
-    | SettingsFileSetting_MergeObjectsCommand
-    | SettingsFileSetting_MergeObjectsFlags
-    | SettingsFileSetting_ArCommand
-    | SettingsFileSetting_RanlibCommand
-    | SettingsFileSetting_OtoolCommand
-    | SettingsFileSetting_InstallNameToolCommand
-    | SettingsFileSetting_DllWrapCommand
-    | SettingsFileSetting_WindresCommand
-    | SettingsFileSetting_TouchCommand
-    | SettingsFileSetting_ClangCommand
-    | SettingsFileSetting_LlcCommand
-    | SettingsFileSetting_OptCommand
-    | SettingsFileSetting_DistroMinGW
+-- | All 'ToolchainSetting's are computed by the ghc-toolchain utility for configuring toolchains.
+-- This used to be defined by 'FP_SETTINGS' in aclocal.m4.
+data ToolchainSetting
+    = ToolchainSetting_CCompilerCommand
+    | ToolchainSetting_CxxCompilerCommand
+    | ToolchainSetting_HaskellCPPCommand
+    | ToolchainSetting_HaskellCPPFlags
+    | ToolchainSetting_CCompilerFlags
+    | ToolchainSetting_CxxCompilerFlags
+    | ToolchainSetting_CCompilerLinkFlags
+    | ToolchainSetting_CCompilerSupportsNoPie
+    | ToolchainSetting_LdCommand
+    | ToolchainSetting_LdFlags
+    | ToolchainSetting_MergeObjectsCommand
+    | ToolchainSetting_MergeObjectsFlags
+    | ToolchainSetting_ArCommand
+    | ToolchainSetting_RanlibCommand
+    | ToolchainSetting_OtoolCommand
+    | ToolchainSetting_InstallNameToolCommand
+    | ToolchainSetting_DllWrapCommand
+    | ToolchainSetting_WindresCommand
+    | ToolchainSetting_TouchCommand
+    | ToolchainSetting_ClangCommand
+    | ToolchainSetting_LlcCommand
+    | ToolchainSetting_OptCommand
+    | ToolchainSetting_DistroMinGW
 
 -- | Look up the value of a 'Setting' in @cfg/system.config@, tracking the
 -- result.
@@ -202,31 +205,36 @@ settingList key = fmap words $ lookupSystemConfig $ case key of
 -- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the
 -- result.
 -- See Note [tooldir: How GHC finds mingw on Windows]
-settingsFileSetting :: SettingsFileSetting -> Action String
-settingsFileSetting key = lookupSystemConfig $ case key of
-    SettingsFileSetting_CCompilerCommand -> "settings-c-compiler-command"
-    SettingsFileSetting_CxxCompilerCommand -> "settings-cxx-compiler-command"
-    SettingsFileSetting_HaskellCPPCommand -> "settings-haskell-cpp-command"
-    SettingsFileSetting_HaskellCPPFlags -> "settings-haskell-cpp-flags"
-    SettingsFileSetting_CCompilerFlags -> "settings-c-compiler-flags"
-    SettingsFileSetting_CxxCompilerFlags -> "settings-cxx-compiler-flags"
-    SettingsFileSetting_CCompilerLinkFlags -> "settings-c-compiler-link-flags"
-    SettingsFileSetting_CCompilerSupportsNoPie -> "settings-c-compiler-supports-no-pie"
-    SettingsFileSetting_LdCommand -> "settings-ld-command"
-    SettingsFileSetting_LdFlags -> "settings-ld-flags"
-    SettingsFileSetting_MergeObjectsCommand -> "settings-merge-objects-command"
-    SettingsFileSetting_MergeObjectsFlags -> "settings-merge-objects-flags"
-    SettingsFileSetting_ArCommand -> "settings-ar-command"
-    SettingsFileSetting_RanlibCommand -> "settings-ranlib-command"
-    SettingsFileSetting_OtoolCommand -> "settings-otool-command"
-    SettingsFileSetting_InstallNameToolCommand -> "settings-install_name_tool-command"
-    SettingsFileSetting_DllWrapCommand -> "settings-dll-wrap-command"
-    SettingsFileSetting_WindresCommand -> "settings-windres-command"
-    SettingsFileSetting_TouchCommand -> "settings-touch-command"
-    SettingsFileSetting_ClangCommand -> "settings-clang-command"
-    SettingsFileSetting_LlcCommand -> "settings-llc-command"
-    SettingsFileSetting_OptCommand -> "settings-opt-command"
-    SettingsFileSetting_DistroMinGW -> "settings-use-distro-mingw"
+settingsFileSetting :: ToolchainSetting -> Action String
+settingsFileSetting key = case key of
+    ToolchainSetting_CCompilerCommand       -> queryHostTargetConfig (cmd . ccProgram . tgtCCompiler)
+    ToolchainSetting_CxxCompilerCommand     -> queryHostTargetConfig (cmd . cxxProgram . tgtCxxCompiler)
+    ToolchainSetting_HaskellCPPCommand      -> queryHostTargetConfig (cmd . cppProgram . tgtCPreprocessor)
+    ToolchainSetting_HaskellCPPFlags        -> queryHostTargetConfig (flags . cppProgram . tgtCPreprocessor)
+    ToolchainSetting_CCompilerFlags         -> queryHostTargetConfig (flags . ccProgram . tgtCCompiler)
+    ToolchainSetting_CxxCompilerFlags       -> queryHostTargetConfig (flags . cxxProgram . tgtCxxCompiler)
+    ToolchainSetting_CCompilerLinkFlags     -> queryHostTargetConfig (flags . ccLinkProgram . tgtCCompilerLink)
+    ToolchainSetting_CCompilerSupportsNoPie -> queryHostTargetConfig (yesNo . ccLinkSupportsNoPie . tgtCCompilerLink)
+    -- ROMES:TODO: What's the difference between the Ld and CCLink?
+    ToolchainSetting_LdCommand              -> lookupSystemConfig "settings-ld-command"
+    ToolchainSetting_LdFlags                -> lookupSystemConfig "settings-ld-flags"
+    ToolchainSetting_MergeObjectsCommand    -> queryHostTargetConfig (maybe "" (cmd . mergeObjsProgram) . tgtMergeObjs)
+    ToolchainSetting_MergeObjectsFlags      -> queryHostTargetConfig (maybe "" (flags . mergeObjsProgram) . tgtMergeObjs)
+    ToolchainSetting_ArCommand              -> queryHostTargetConfig (cmd . arMkArchive . tgtAr)
+    ToolchainSetting_RanlibCommand          -> queryHostTargetConfig (maybe "" (cmd . ranlibProgram) . tgtRanlib)
+    ToolchainSetting_OtoolCommand           -> lookupSystemConfig "settings-otool-command"
+    ToolchainSetting_InstallNameToolCommand -> lookupSystemConfig "settings-install_name_tool-command"
+    ToolchainSetting_DllWrapCommand         -> queryHostTargetConfig (maybe "" cmd . tgtDllwrap)
+    ToolchainSetting_WindresCommand         -> queryHostTargetConfig (maybe "" cmd . tgtWindres)
+    ToolchainSetting_TouchCommand           -> lookupSystemConfig "settings-touch-command"
+    ToolchainSetting_ClangCommand           -> lookupSystemConfig "settings-clang-command"
+    ToolchainSetting_LlcCommand             -> lookupSystemConfig "settings-llc-command"
+    ToolchainSetting_OptCommand             -> lookupSystemConfig "settings-opt-command"
+    -- ROMES:TODO: affter handling DistroMinGW and aboves in ghc-toolchain, factor queryHostTargetConfig out
+    ToolchainSetting_DistroMinGW            -> lookupSystemConfig "settings-use-distro-mingw" -- ROMES:TODO: This option doesn't seem to be in ghc-toolchain yet
+    where
+      flags = unwords . prgFlags
+      cmd   = prgPath
 
 -- | An expression that looks up the value of a 'Setting' in @cfg/system.config@,
 -- tracking the result.


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -9,7 +9,7 @@ import qualified Data.Set as Set
 import Base
 import qualified Context
 import Expression
-import Hadrian.Oracles.TextFile (lookupSystemConfig)
+import Hadrian.Oracles.TextFile (lookupSystemConfig, queryHostTargetConfig)
 import Oracles.Flag
 import Oracles.ModuleFiles
 import Oracles.Setting
@@ -21,6 +21,9 @@ import Settings
 import Target
 import Utilities
 
+import qualified GHC.Toolchain as Toolchain
+import GHC.Toolchain.Program (prgFlags)
+
 -- | Track this file to rebuild generated files whenever it changes.
 trackGenerateHs :: Expr ()
 trackGenerateHs = expr $ need [sourcePath -/- "Rules/Generate.hs"]
@@ -411,32 +414,32 @@ generateSettings = do
     ctx <- getContext
     settings <- traverse sequence $
         [ ("GCC extra via C opts", expr $ lookupSystemConfig "gcc-extra-via-c-opts")
-        , ("C compiler command", expr $ settingsFileSetting SettingsFileSetting_CCompilerCommand)
-        , ("C compiler flags", expr $ settingsFileSetting SettingsFileSetting_CCompilerFlags)
-        , ("C++ compiler command", expr $ settingsFileSetting SettingsFileSetting_CxxCompilerCommand)
-        , ("C++ compiler flags", expr $ settingsFileSetting SettingsFileSetting_CxxCompilerFlags)
-        , ("C compiler link flags", expr $ settingsFileSetting SettingsFileSetting_CCompilerLinkFlags)
-        , ("C compiler supports -no-pie", expr $ settingsFileSetting SettingsFileSetting_CCompilerSupportsNoPie)
-        , ("Haskell CPP command", expr $ settingsFileSetting SettingsFileSetting_HaskellCPPCommand)
-        , ("Haskell CPP flags", expr $ settingsFileSetting SettingsFileSetting_HaskellCPPFlags)
-        , ("ld command", expr $ settingsFileSetting SettingsFileSetting_LdCommand)
-        , ("ld flags", expr $ settingsFileSetting SettingsFileSetting_LdFlags)
+        , ("C compiler command", expr $ settingsFileSetting ToolchainSetting_CCompilerCommand)
+        , ("C compiler flags", expr $ settingsFileSetting ToolchainSetting_CCompilerFlags)
+        , ("C++ compiler command", expr $ settingsFileSetting ToolchainSetting_CxxCompilerCommand)
+        , ("C++ compiler flags", expr $ settingsFileSetting ToolchainSetting_CxxCompilerFlags)
+        , ("C compiler link flags", expr $ settingsFileSetting ToolchainSetting_CCompilerLinkFlags)
+        , ("C compiler supports -no-pie", expr $ settingsFileSetting ToolchainSetting_CCompilerSupportsNoPie)
+        , ("Haskell CPP command", expr $ settingsFileSetting ToolchainSetting_HaskellCPPCommand)
+        , ("Haskell CPP flags", expr $ settingsFileSetting ToolchainSetting_HaskellCPPFlags)
+        , ("ld command", expr $ settingsFileSetting ToolchainSetting_LdCommand)
+        , ("ld flags", expr $ settingsFileSetting ToolchainSetting_LdFlags)
         , ("ld supports compact unwind", expr $ lookupSystemConfig "ld-has-no-compact-unwind")
         , ("ld supports filelist", expr $ lookupSystemConfig "ld-has-filelist")
         , ("ld supports response files", expr $ lookupSystemConfig "ld-supports-response-files")
         , ("ld is GNU ld", expr $ lookupSystemConfig "ld-is-gnu-ld")
-        , ("Merge objects command", expr $ settingsFileSetting SettingsFileSetting_MergeObjectsCommand)
-        , ("Merge objects flags", expr $ settingsFileSetting SettingsFileSetting_MergeObjectsFlags)
-        , ("ar command", expr $ settingsFileSetting SettingsFileSetting_ArCommand)
-        , ("ar flags", expr $ lookupSystemConfig "ar-args")
+        , ("Merge objects command", expr $ settingsFileSetting ToolchainSetting_MergeObjectsCommand)
+        , ("Merge objects flags", expr $ settingsFileSetting ToolchainSetting_MergeObjectsFlags)
+        , ("ar command", expr $ settingsFileSetting ToolchainSetting_ArCommand)
+        , ("ar flags", expr $ queryHostTargetConfig (unwords . prgFlags . Toolchain.arMkArchive . Toolchain.tgtAr))
         , ("ar supports at file", expr $ yesNo <$> flag ArSupportsAtFile)
         , ("ar supports -L", expr $ yesNo <$> flag ArSupportsDashL)
-        , ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand)
-        , ("otool command", expr $ settingsFileSetting SettingsFileSetting_OtoolCommand)
-        , ("install_name_tool command", expr $ settingsFileSetting SettingsFileSetting_InstallNameToolCommand)
-        , ("touch command", expr $ settingsFileSetting SettingsFileSetting_TouchCommand)
-        , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand)
-        , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand)
+        , ("ranlib command", expr $ settingsFileSetting ToolchainSetting_RanlibCommand)
+        , ("otool command", expr $ settingsFileSetting ToolchainSetting_OtoolCommand)
+        , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand)
+        , ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand)
+        , ("dllwrap command", expr $ settingsFileSetting ToolchainSetting_DllWrapCommand)
+        , ("windres command", expr $ settingsFileSetting ToolchainSetting_WindresCommand)
         , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit })))
         , ("cross compiling", expr $ yesNo <$> flag CrossCompiling)
         , ("target platform string", getSetting TargetPlatform)
@@ -451,10 +454,10 @@ generateSettings = do
         , ("target has libm", expr $  lookupSystemConfig "target-has-libm")
         , ("Unregisterised", expr $ yesNo <$> flag GhcUnregisterised)
         , ("LLVM target", getSetting LlvmTarget)
-        , ("LLVM llc command", expr $ settingsFileSetting SettingsFileSetting_LlcCommand)
-        , ("LLVM opt command", expr $ settingsFileSetting SettingsFileSetting_OptCommand)
-        , ("LLVM clang command", expr $ settingsFileSetting SettingsFileSetting_ClangCommand)
-        , ("Use inplace MinGW toolchain", expr $ settingsFileSetting SettingsFileSetting_DistroMinGW)
+        , ("LLVM llc command", expr $ settingsFileSetting ToolchainSetting_LlcCommand)
+        , ("LLVM opt command", expr $ settingsFileSetting ToolchainSetting_OptCommand)
+        , ("LLVM clang command", expr $ settingsFileSetting ToolchainSetting_ClangCommand)
+        , ("Use inplace MinGW toolchain", expr $ settingsFileSetting ToolchainSetting_DistroMinGW)
 
         , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter)
         , ("Support SMP", expr $ yesNo <$> targetSupportsSMP)


=====================================
hadrian/src/Rules/Test.hs
=====================================
@@ -229,8 +229,8 @@ testRules = do
               [ "--interactive", "-v0", "-ignore-dot-ghci"
               , "-fno-ghci-history"
               ]
-        ccPath          <- settingsFileSetting SettingsFileSetting_CCompilerCommand
-        ccFlags         <- settingsFileSetting SettingsFileSetting_CCompilerFlags
+        ccPath          <- settingsFileSetting ToolchainSetting_CCompilerCommand
+        ccFlags         <- settingsFileSetting ToolchainSetting_CCompilerFlags
 
         pythonPath      <- builderPath Python
 


=====================================
hadrian/src/Settings/Builders/RunTest.hs
=====================================
@@ -124,7 +124,7 @@ inTreeCompilerArgs stg = do
     platform    <- setting TargetPlatform
     wordsize    <- (show @Int . (*8) . read) <$> setting TargetWordSize
 
-    llc_cmd   <- settingsFileSetting SettingsFileSetting_LlcCommand
+    llc_cmd   <- settingsFileSetting ToolchainSetting_LlcCommand
     have_llvm <- liftIO (isJust <$> findExecutable llc_cmd)
 
     top         <- topDirectory


=====================================
m4/fp_settings.m4
=====================================
@@ -1,6 +1,7 @@
 # FP_SETTINGS
 # ----------------------------------
 # Set the variables used in the settings file
+# ROMES:TODO: Make this file obsolete
 AC_DEFUN([FP_SETTINGS],
 [
     SettingsUseDistroMINGW="$EnableDistroToolchain"


=====================================
m4/ghc_toolchain.m4
=====================================
@@ -14,7 +14,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
         -ilibraries/ghc-boot -iutils/ghc-toolchain/src \
         -XNoImplicitPrelude \
         -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
-        Main -o acghc-toolchain
+        utils/ghc-toolchain/Main.hs -o acghc-toolchain
 
     rm -f acargs
     echo "--triple=$target" >> acargs


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Program.hs
=====================================
@@ -28,7 +28,7 @@ import GHC.Toolchain.Utils
 data Program = Program { prgPath :: FilePath
                        , prgFlags :: [String]
                        }
-    deriving (Show, Read)
+    deriving (Show, Read, Eq, Ord)
 
 _prgPath :: Lens Program FilePath
 _prgPath = Lens prgPath (\x o -> o {prgPath = x})


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
=====================================
@@ -15,10 +15,10 @@ import GHC.Toolchain.Tools.Nm
 import GHC.Toolchain.Tools.MergeObjs
 
 data WordSize = WS4 | WS8
-    deriving (Show, Read)
+    deriving (Show, Read, Eq, Ord)
 
 data Endianness = LittleEndian | BigEndian
-    deriving (Show, Read)
+    deriving (Show, Read, Eq, Ord)
 
 -- | A 'Target' consists of:
 --
@@ -63,4 +63,5 @@ data Target = Target
     , tgtDllwrap :: Maybe Program
     , tgtWindres :: Maybe Program
     }
-    deriving (Show, Read)
+    deriving (Show, Read, Eq, Ord)
+


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Ar.hs
=====================================
@@ -17,7 +17,7 @@ data Ar = Ar { arMkArchive :: Program
              , arSupportsDashL :: Bool
              , arNeedsRanlib :: Bool
              }
-    deriving (Show, Read)
+    deriving (Show, Read, Eq, Ord)
 
 findAr :: ProgOpt -> M Ar
 findAr progOpt = checking "for 'ar'" $ do


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs
=====================================
@@ -19,9 +19,9 @@ import GHC.Toolchain.Prelude
 import GHC.Toolchain.Utils
 import GHC.Toolchain.Program
 
-data Cc = Cc { ccProgram :: Program
-             }
-    deriving (Show, Read)
+newtype Cc = Cc { ccProgram :: Program
+                }
+    deriving (Show, Read, Eq, Ord)
 
 _ccProgram :: Lens Cc Program
 _ccProgram = Lens ccProgram (\x o -> o{ccProgram=x})


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
=====================================
@@ -9,9 +9,9 @@ import GHC.Toolchain.Program
 
 import GHC.Toolchain.Tools.Cc
 
-data Cpp = Cpp { cppProgram :: Program
-               }
-    deriving (Show, Read)
+newtype Cpp = Cpp { cppProgram :: Program
+                  }
+    deriving (Show, Read, Eq, Ord)
 
 findCpp :: ProgOpt -> Cc -> M Cpp
 findCpp progOpt cc


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs
=====================================
@@ -8,9 +8,9 @@ module GHC.Toolchain.Tools.Cxx
 import GHC.Toolchain.Prelude
 import GHC.Toolchain.Program
 
-data Cxx = Cxx { cxxProgram :: Program
-               }
-    deriving (Show, Read)
+newtype Cxx = Cxx { cxxProgram :: Program
+                  }
+    deriving (Show, Read, Eq, Ord)
 
 findCxx :: ProgOpt -> M Cxx
 findCxx progOpt = checking "for C++ compiler" $ do


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
=====================================
@@ -20,7 +20,7 @@ import GHC.Toolchain.Tools.Readelf
 data CcLink = CcLink { ccLinkProgram :: Program
                      , ccLinkSupportsNoPie :: Bool
                      }
-    deriving (Show, Read)
+    deriving (Show, Read, Eq, Ord)
 
 findCcLink :: ProgOpt -> Maybe Bool -> ArchOS -> Cc -> Maybe Readelf -> M CcLink
 findCcLink progOpt ldOverride archOs cc readelf = checking "for C compiler for linking command" $ do


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/MergeObjs.hs
=====================================
@@ -17,9 +17,9 @@ import GHC.Toolchain.Tools.Link
 import GHC.Toolchain.Tools.Nm
 
 -- | Configuration on how the C compiler can be used to link
-data MergeObjs = MergeObjs { mergeObjsProgram :: Program
-                           }
-    deriving (Show, Read)
+newtype MergeObjs = MergeObjs { mergeObjsProgram :: Program
+                              }
+    deriving (Show, Read, Eq, Ord)
 
 findMergeObjs :: ProgOpt -> Cc -> CcLink -> Nm -> M MergeObjs
 findMergeObjs progOpt cc ccLink nm = checking "for linker for merging objects" $ do


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Nm.hs
=====================================
@@ -8,9 +8,9 @@ import Control.Monad
 import GHC.Toolchain.Prelude
 import GHC.Toolchain.Program
 
-data Nm = Nm { nmProgram :: Program
-             }
-    deriving (Show, Read)
+newtype Nm = Nm { nmProgram :: Program
+                }
+    deriving (Show, Read, Eq, Ord)
 
 findNm :: ProgOpt -> M Nm
 findNm progOpt = checking "for 'nm'" $ do


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Ranlib.hs
=====================================
@@ -8,9 +8,9 @@ module GHC.Toolchain.Tools.Ranlib
 import GHC.Toolchain.Prelude
 import GHC.Toolchain.Program
 
-data Ranlib = Ranlib { ranlibProgram :: Program
-                     }
-    deriving (Show, Read)
+newtype Ranlib = Ranlib { ranlibProgram :: Program
+                        }
+    deriving (Show, Read, Eq, Ord)
 
 findRanlib :: ProgOpt -> M Ranlib
 findRanlib progOpt = checking "for 'ranlib'" $ do


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Readelf.hs
=====================================
@@ -8,8 +8,8 @@ import Control.Monad
 import GHC.Toolchain.Prelude
 import GHC.Toolchain.Program
 
-data Readelf = Readelf { readelfProgram :: Program
-                       }
+newtype Readelf = Readelf { readelfProgram :: Program
+                          }
     deriving (Show, Read)
 
 -- | Readelf is only needed by 'GHC.Toolchain.Tools.Link.checkBfdCopyBug'.



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0c7fdc84f685dd884d0133b4290636136606f02

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0c7fdc84f685dd884d0133b4290636136606f02
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/70b6c459/attachment-0001.html>


More information about the ghc-commits mailing list