[Git][ghc/ghc][wip/toolchain-selection] Configure Host toolchain with dummy options, hope they aren't used

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon Jul 10 15:11:02 UTC 2023



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


Commits:
7e33bddd by Rodrigo Mesquita at 2023-07-10T16:10:53+01:00
Configure Host toolchain with dummy options, hope they aren't used

- - - - -


6 changed files:

- default.host.target.in
- hadrian/cfg/system.config.in
- hadrian/src/Context.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Settings/Builders/Cabal.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Target.hs


Changes:

=====================================
default.host.target.in
=====================================
@@ -1,40 +1,40 @@
 Target
-{ tgtArchOs = ArchOS {archOS_arch = @HaskellHostArch@, archOS_OS = @HaskellTargetOs@}
+{ tgtArchOs = ArchOS {archOS_arch = @HaskellHostArch@, archOS_OS = @HaskellHostOs@}
 , tgtVendor = @HostVendor_CPPMaybeStr@
 , tgtLocallyExecutable = True
-, tgtSupportsGnuNonexecStack = undefined
-, tgtSupportsSubsectionsViaSymbols = undefined
-, tgtSupportsIdentDirective = undefined
-, tgtWordSize = undefined
-, tgtEndianness = undefined
-, tgtSymbolsHaveLeadingUnderscore = undefined
-, tgtLlvmTarget = undefined
-, tgtUnregisterised = undefined
-, tgtTablesNextToCode = undefined
-, tgtUseLibffiForAdjustors = undefined
+, tgtSupportsGnuNonexecStack = False
+, tgtSupportsSubsectionsViaSymbols = False
+, tgtSupportsIdentDirective = False
+, tgtWordSize = WS8
+, tgtEndianness = LittleEndian
+, tgtSymbolsHaveLeadingUnderscore = False
+, tgtLlvmTarget = "@HostPlatform@"
+, tgtUnregisterised = False
+, tgtTablesNextToCode = True
+, tgtUseLibffiForAdjustors = True
 , tgtCCompiler = Cc {ccProgram = Program {prgPath = "@CC_STAGE0@", prgFlags = @CONF_CC_OPTS_STAGE0List@}}
 , tgtCxxCompiler = Cxx {cxxProgram = Program {prgPath = "@CC_STAGE0@", prgFlags = @CONF_CXX_OPTS_STAGE0List@}}
 , tgtCPreprocessor = Cpp {cppProgram = Program {prgPath = "@CPPCmd_STAGE0@", prgFlags = @CONF_CPP_OPTS_STAGE0List@}}
 , tgtHsCPreprocessor = HsCpp {hsCppProgram = Program {prgPath = "@CC_STAGE0@", prgFlags = @SettingsHaskellCPPFlagsList@}}
 , tgtCCompilerLink = CcLink
 { ccLinkProgram = Program {prgPath = "@CC_STAGE0@", prgFlags = @CONF_GCC_LINKER_OPTS_STAGE0List@}
-, ccLinkSupportsNoPie = undefined
-, ccLinkSupportsCompactUnwind = undefined
-, ccLinkSupportsFilelist = undefined
-, ccLinkIsGnu = undefined
+, ccLinkSupportsNoPie = False
+, ccLinkSupportsCompactUnwind = False
+, ccLinkSupportsFilelist = False
+, ccLinkIsGnu = False
 }
 
 , tgtAr = Ar
 { arMkArchive = Program {prgPath = "@AR_STAGE0@", prgFlags = @AR_OPTS_STAGE0List@}
-, arIsGnu = undefined
+, arIsGnu = False
 , arSupportsAtFile = @ArSupportsAtFile_STAGE0Bool@
 , arSupportsDashL = @ArSupportsDashL_STAGE0Bool@
-, arNeedsRanlib = undefined
+, arNeedsRanlib = False
 }
 
-, tgtRanlib = undefined
-, tgtNm = undefined
-, tgtMergeObjs = Just (MergeObjs {mergeObjsProgram = Program {prgPath = "@LD_STAGE0@", prgFlags = undefined}, mergeObjsSupportsResponseFiles = undefined})
+, tgtRanlib = Nothing
+, tgtNm = Nm {nmProgram = Program {prgPath = "@NM@", prgFlags = []}}
+, tgtMergeObjs = Just (MergeObjs {mergeObjsProgram = Program {prgPath = "@LD_STAGE0@", prgFlags = ["-r"]}, mergeObjsSupportsResponseFiles = False})
 , tgtDllwrap = @DllWrapCmdMaybeProg@
 , tgtWindres = @WindresCmdMaybeProg@
 }


=====================================
hadrian/cfg/system.config.in
=====================================
@@ -48,10 +48,6 @@ ghc-source-path      = @hardtop@
 # Q: What is TargetPlatformFull?
 target-platform-full  = @TargetPlatformFull@
 
-# ROMES:TODO: Drop cross-compiling, when we configure all 3 targets based on configure flags
-# the three targets are always the three targets to use, regardless of them being the same or not
-cross-compiling       = @CrossCompiling@
-
 dynamic-extension     = @soext_target@
 
 ghc-version           = @GhcVersion@
@@ -78,9 +74,6 @@ project-git-commit-id  = @ProjectGitCommitId@
 # might become redundant.
 # See Note [tooldir: How GHC finds mingw on Windows]
 
-# ROMES:TODO: Get rid of some of these settings completely?
-# I think the only one which we might keep still is otool and install_name_tool
-# and touch and target has libm?
 settings-otool-command = @SettingsOtoolCommand@
 settings-install_name_tool-command = @SettingsInstallNameToolCommand@
 settings-touch-command = @SettingsTouchCommand@


=====================================
hadrian/src/Context.hs
=====================================
@@ -65,9 +65,9 @@ libPath Context {..} = buildRoot <&> (-/- (stageString stage -/- "lib"))
 distDir :: Stage -> Action FilePath
 distDir st = do
     version        <- ghcVersionStage st
-    hostOs         <- cabalOsString   . stringEncodeOS   . archOS_OS   . tgtArchOs <$> targetStage st
-    hostArch       <- cabalArchString . stringEncodeArch . archOS_arch . tgtArchOs <$> targetStage st
-    return $ hostArch ++ "-" ++ hostOs ++ "-ghc-" ++ version
+    targetOs       <- cabalOsString   . stringEncodeOS   . archOS_OS   . tgtArchOs <$> targetStage st
+    targetArch     <- cabalArchString . stringEncodeArch . archOS_arch . tgtArchOs <$> targetStage st
+    return $ targetArch ++ "-" ++ targetOs ++ "-ghc-" ++ version
 
 pkgFileName :: Context -> Package -> String -> String -> Action FilePath
 pkgFileName context package prefix suffix = do


=====================================
hadrian/src/Oracles/Setting.hs
=====================================
@@ -38,10 +38,7 @@ import GHC.Platform.ArchOS
 -- looks up the value of the setting and returns the string @"mingw32"@,
 -- tracking the result in the Shake database.
 --
--- ROMES:TODO: *Platform are passed to ghc-toolchain in --target
--- We can reconstruct the *Platform information from the toolchain (targetPlatformTriple)
---
--- * How to handle target-platform-full?
+-- * ROMES:TODO: How to handle target-platform-full?
 data Setting = CursesIncludeDir
              | CursesLibDir
              | DynamicExtension
@@ -82,8 +79,8 @@ data Setting = CursesIncludeDir
 -- This used to be defined by 'FP_SETTINGS' in aclocal.m4.
 --
 -- TODO: We should be able to drop this completely, after moving all the toolchain settings to ghc-toolchain
---
--- TODO: For the next person, move to ghc-toolchain and to the Target files generated by configure and ghc-toolchain
+-- Move to ghc-toolchain and to the Target files generated by configure and ghc-toolchain
+-- * First we will get rid of DistroMinGW when we fix the windows build
 data ToolchainSetting
     = ToolchainSetting_OtoolCommand
     | ToolchainSetting_InstallNameToolCommand
@@ -94,8 +91,6 @@ data ToolchainSetting
 
 -- | Look up the value of a 'Setting' in @cfg/system.config@, tracking the
 -- result.
--- ROMES:TODO: Things that are gotten from the toolchain configs will no longer
--- be part of settings, so they should be moved out.
 setting :: Setting -> Action String
 setting key = lookupSystemConfig $ case key of
     CursesIncludeDir   -> "curses-include-dir"
@@ -264,8 +259,8 @@ targetStage :: Stage -> Action Target
 -- TODO: We currently only support cross-compiling a stage1 compiler,
 -- but the cross compiler should really be stage2 (#19174)
 -- When we get there, we'll need to change the definition here.
-targetStage (Stage0 {}) = getBuildTarget
-targetStage (Stage1 {}) = getHostTarget
-targetStage (Stage2 {}) = getTargetTarget
-targetStage (Stage3 {}) = getTargetTarget
+targetStage (Stage0 {}) = getHostTarget   -- getBuildTarget
+targetStage (Stage1 {}) = getTargetTarget -- getHostTarget
+targetStage (Stage2 {}) = getTargetTarget -- getTargetTarget
+targetStage (Stage3 {}) = getTargetTarget -- Would only be available for runnable stage2s?
 


=====================================
hadrian/src/Settings/Builders/Cabal.hs
=====================================
@@ -175,7 +175,6 @@ configureStageArgs = do
           ]
 
 
--- TODO: LD_OPTS?
 configureArgs :: Args -> Args -> Args
 configureArgs cFlags' ldFlags' = do
 


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
=====================================
@@ -16,10 +16,6 @@ import GHC.Toolchain.Tools.Link
 import GHC.Toolchain.Tools.Nm
 import GHC.Toolchain.Tools.MergeObjs
 
-import GHC.Read
-import Text.ParserCombinators.ReadPrec (prec, reset, (<++))
-import Text.Read.Lex
-
 data WordSize = WS4 | WS8
     deriving (Show, Read, Eq, Ord)
 
@@ -29,7 +25,7 @@ data Endianness = LittleEndian | BigEndian
 -- ROMES:TODO: A target might also need
 -- * Llc command
 -- * Opt command
--- * DistroMinGW?
+-- * DistroMinGW? -- no, this should be configured with existing flags to point to the bindist mingw
 -- * Install_name_tool
 -- * Touch cmd
 -- * otool command
@@ -76,7 +72,7 @@ data Target = Target
     , tgtDllwrap :: Maybe Program
     , tgtWindres :: Maybe Program
     }
-    deriving (Eq, Ord)
+    deriving (Read, Eq, Ord)
 
 -- | The word size as an integer representing the number of bytes
 wordSize2Bytes :: WordSize -> Int
@@ -93,11 +89,8 @@ targetPlatformTriple Target{tgtArchOs, tgtVendor} =
         Nothing -> archStr <> "-" <> osStr
         Just vendor -> archStr <> "-" <> vendor <> "-" <> osStr
 
-{-
-  Handwritten Show and Read instances to have have better diffs and parse
-  toolchain targets generated by configure
--}
-
+-- | Handwritten Show instance to have have better diffs against the toolchain
+-- targets generated by configure
 instance Show Target where
   show Target{..} = unlines
     [ "Target"
@@ -127,64 +120,3 @@ instance Show Target where
     , ", tgtWindres = " ++ show tgtDllwrap
     , "}"
     ]
-
-instance Read GHC.Toolchain.Target.Target where
-  readPrec = parens $ prec 11 $ do
-      expectP (Ident "Target")
-      expectP (Punc "{")
-      tgtArchOs                        <- readFieldOrUndefined "tgtArchOs"
-      expectP (Punc ",")
-      tgtVendor                        <- readFieldOrUndefined "tgtVendor"
-      expectP (Punc ",")
-      tgtLocallyExecutable             <- readFieldOrUndefined "tgtLocallyExecutable"
-      expectP (Punc ",")
-      tgtSupportsGnuNonexecStack       <- readFieldOrUndefined "tgtSupportsGnuNonexecStack"
-      expectP (Punc ",")
-      tgtSupportsSubsectionsViaSymbols <- readFieldOrUndefined "tgtSupportsSubsectionsViaSymbols"
-      expectP (Punc ",")
-      tgtSupportsIdentDirective        <- readFieldOrUndefined "tgtSupportsIdentDirective"
-      expectP (Punc ",")
-      tgtWordSize                      <- readFieldOrUndefined "tgtWordSize"
-      expectP (Punc ",")
-      tgtEndianness                    <- readFieldOrUndefined "tgtEndianness"
-      expectP (Punc ",")
-      tgtSymbolsHaveLeadingUnderscore  <- readFieldOrUndefined "tgtSymbolsHaveLeadingUnderscore"
-      expectP (Punc ",")
-      tgtLlvmTarget                    <- readFieldOrUndefined "tgtLlvmTarget"
-      expectP (Punc ",")
-      tgtUnregisterised                <- readFieldOrUndefined "tgtUnregisterised"
-      expectP (Punc ",")
-      tgtTablesNextToCode              <- readFieldOrUndefined "tgtTablesNextToCode"
-      expectP (Punc ",")
-      tgtUseLibffiForAdjustors         <- readFieldOrUndefined "tgtUseLibffiForAdjustors"
-      expectP (Punc ",")
-      tgtCCompiler                     <- readFieldOrUndefined "tgtCCompiler"
-      expectP (Punc ",")
-      tgtCxxCompiler                   <- readFieldOrUndefined "tgtCxxCompiler"
-      expectP (Punc ",")
-      tgtCPreprocessor                 <- readFieldOrUndefined "tgtCPreprocessor"
-      expectP (Punc ",")
-      tgtHsCPreprocessor               <- readFieldOrUndefined "tgtHsCPreprocessor"
-      expectP (Punc ",")
-      tgtCCompilerLink                 <- readFieldOrUndefined "tgtCCompilerLink"
-      expectP (Punc ",")
-      tgtAr                            <- readFieldOrUndefined "tgtAr"
-      expectP (Punc ",")
-      tgtRanlib                        <- readFieldOrUndefined "tgtRanlib"
-      expectP (Punc ",")
-      tgtNm                            <- readFieldOrUndefined "tgtNm"
-      expectP (Punc ",")
-      tgtMergeObjs                     <- readFieldOrUndefined "tgtMergeObjs"
-      expectP (Punc ",")
-      tgtDllwrap                       <- readFieldOrUndefined "tgtDllwrap"
-      expectP (Punc ",")
-      tgtWindres                       <- readFieldOrUndefined "tgtWindres"
-      expectP (Punc "}")
-      return Target{..}
-    where
-      readFieldOrUndefined fieldName = do
-          expectP (Ident fieldName)
-          expectP (Punc "=")
-          ((reset (expectP (Ident "undefined")) >> return undefined) <++ reset readPrec)
-      {-# NOINLINE readFieldOrUndefined #-}
-



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

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


More information about the ghc-commits mailing list