[Git][ghc/ghc][wip/toolchain-selection] 3 commits: New host.target

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon Jul 10 13:03:44 UTC 2023



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


Commits:
1bde6995 by Rodrigo Mesquita at 2023-07-10T13:19:15+01:00
New host.target

- - - - -
4aafc880 by Rodrigo Mesquita at 2023-07-10T13:56:32+01:00
Try to parse the undefined fields

- - - - -
bc625fac by Rodrigo Mesquita at 2023-07-10T14:03:36+01:00
Configure Host toolchain with dummy options, hope they aren't used

- - - - -


9 changed files:

- configure.ac
- + default.host.target.in
- distrib/configure.ac.in
- hadrian/src/Base.hs
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Rules/BinaryDist.hs
- m4/ghc_toolchain.m4
- m4/prep_target_file.m4
- utils/ghc-toolchain/src/GHC/Toolchain/Target.hs


Changes:

=====================================
configure.ac
=====================================
@@ -1184,6 +1184,7 @@ AC_CONFIG_FILES(
   hadrian/ghci-stack
   docs/users_guide/ghc_config.py
   distrib/configure.ac
+  default.host.target
   default.target
 ])
 
@@ -1298,5 +1299,6 @@ For more information on how to configure your GHC build, see
    https://gitlab.haskell.org/ghc/ghc/wikis/building
 "]
 
-VALIDATE_GHC_TOOLCHAIN
+VALIDATE_GHC_TOOLCHAIN([default.host.target],[default.ghc-toolchain.host.target])
+VALIDATE_GHC_TOOLCHAIN([default.target],[default.ghc-toolchain.target])
 


=====================================
default.host.target.in
=====================================
@@ -0,0 +1,40 @@
+Target
+{ tgtArchOs = ArchOS {archOS_arch = @HaskellHostArch@, archOS_OS = @HaskellTargetOs@}
+, tgtVendor = @HostVendor_CPPMaybeStr@
+, tgtLocallyExecutable = True
+, 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 = False
+, ccLinkSupportsCompactUnwind = False
+, ccLinkSupportsFilelist = False
+, ccLinkIsGnu = False
+}
+
+, tgtAr = Ar
+{ arMkArchive = Program {prgPath = "@AR_STAGE0@", prgFlags = @AR_OPTS_STAGE0List@}
+, arIsGnu = False
+, arSupportsAtFile = @ArSupportsAtFile_STAGE0Bool@
+, arSupportsDashL = @ArSupportsDashL_STAGE0Bool@
+, arNeedsRanlib = False
+}
+
+, tgtRanlib = Nothing
+, tgtNm = Nm {nmProgram = Program {prgPath = "@NM@", prgFlags = []}}
+, tgtMergeObjs = Just (MergeObjs {mergeObjsProgram = Program {prgPath = "@LD_STAGE0@", prgFlags = ["-r"]}, mergeObjsSupportsResponseFiles = []})
+, tgtDllwrap = @DllWrapCmdMaybeProg@
+, tgtWindres = @WindresCmdMaybeProg@
+}


=====================================
distrib/configure.ac.in
=====================================
@@ -287,6 +287,7 @@ AC_SUBST(UseLibdw)
 FP_SETTINGS
 
 AC_CONFIG_FILES([config.mk])
+AC_CONFIG_FILES([default.host.target])
 AC_CONFIG_FILES([default.target])
 AC_OUTPUT
 
@@ -312,7 +313,8 @@ checkMake380 gmake
 # Toolchain target files
 PREP_TARGET_FILE
 FIND_GHC_TOOLCHAIN
-VALIDATE_GHC_TOOLCHAIN
+VALIDATE_GHC_TOOLCHAIN([default.host.target],[default.ghc-toolchain.host.target])
+VALIDATE_GHC_TOOLCHAIN([default.target],[default.ghc-toolchain.target])
 
 echo "****************************************************"
 echo "Configuration done, ready to 'make install'"


=====================================
hadrian/src/Base.hs
=====================================
@@ -83,12 +83,12 @@ configFile = configPath -/- "system.config"
 -- | The target configuration file generated by ghc-toolchain for the
 -- compilation build platform
 buildTargetFile :: FilePath
-buildTargetFile = "default.ghc-toolchain.host.target" -- ROMES:TODO: Not hardcode this value?
+buildTargetFile = "default.host.target" -- ROMES:TODO: Not hardcode this value?
 
 -- | The target configuration file generated by ghc-toolchain for the
 -- compilation host platform
 hostTargetFile :: FilePath
-hostTargetFile = "default.ghc-toolchain.host.target" -- ROMES:TODO: Not hardcode this value?
+hostTargetFile = "default.host.target" -- ROMES:TODO: Not hardcode this value?
 
 -- | The target configuration file generated by ghc-toolchain for the
 -- compilation target platform


=====================================
hadrian/src/Hadrian/Oracles/TextFile.hs
=====================================
@@ -27,6 +27,7 @@ import Development.Shake
 import Development.Shake.Classes
 import Development.Shake.Config
 import Base
+import Text.Read (readMaybe)
 
 import qualified GHC.Toolchain.Target as Toolchain
 
@@ -157,8 +158,10 @@ textFileOracle = do
     tf <- newCache $ \file -> do
         need [file]
         putVerbose $ "| TargetFile oracle: reading " ++ quote file ++ "..."
-        target <- read <$> readFile' file
-        return (target :: Toolchain.Target)
+        mtarget <- readMaybe <$> readFile' file
+        case mtarget of
+          Nothing -> error $ "Failed to read a Toolchain.Target from " ++ quote file
+          Just target -> return (target :: Toolchain.Target)
     void $ addOracleCache $ \(TargetFile file) -> tf file
 
 -- Orphan instances for (ShakeValue Toolchain.Target)


=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -259,6 +259,7 @@ bindistRules = do
                     (["configure", "Makefile"] ++ bindistInstallFiles)
           copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in")
           copyFile ("default.target.in") (bindistFilesDir -/- "default.target.in")
+          copyFile ("default.host.target.in") (bindistFilesDir -/- "default.host.target.in")
           forM_ bin_targets $ \(pkg, _) -> do
             needed_wrappers <- pkgToWrappers pkg
             forM_ needed_wrappers $ \wrapper_name -> do


=====================================
m4/ghc_toolchain.m4
=====================================
@@ -107,13 +107,6 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
 
     INVOKE_GHC_TOOLCHAIN()
 
-    echo "ROMES:RESULT: default.target"
-    cat default.target
-    echo "ROMES:RESULT: default.ghc-toolchain.host.target"
-    cat default.ghc-toolchain.host.target
-    echo "ROMES:RESULT: default.ghc-toolchain.target"
-    cat default.ghc-toolchain.target
-
     #rm -Rf acargs acghc-toolchain actmp-ghc-toolchain
 
     dnl ADD_GHC_TOOLCHAIN_ARG([hs-cpp-opt], [$HaskellCPPArgs])
@@ -131,15 +124,15 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
 ])
 
 
+dnl $1 like "default.target"
+dnl $2 like "default.ghc-toolchain.target"
 AC_DEFUN([VALIDATE_GHC_TOOLCHAIN],[
-    A="default.target"
-    B="default.ghc-toolchain.target"
-    diff_output=`diff "$A" "$B" 2>&1`
+    diff_output=`diff "$1" "$2" 2>&1`
     if test -z "$diff_output"; then
       true
     else
       AC_MSG_WARN([
-          There are some differences between the toolchain configured by "configure" ($A) and the toolchain configured by the "ghc-toolchain" program ($B).
+          There are some differences between the toolchain configured by "configure" ($1) and the toolchain configured by the "ghc-toolchain" program ($2).
           $diff_output
           Don't worry! This won't affect your ghc in any way.
           However, in a near future, we will move to configuring toolchains with "ghc-toolchain" by default, so you might have discovered a future bug!
@@ -148,6 +141,8 @@ AC_DEFUN([VALIDATE_GHC_TOOLCHAIN],[
       ])
     fi
 
-    echo "default.target printed:"
-    cat default.target
+    echo "$1:"
+    cat $1
+    echo "$2:"
+    cat $2
 ])


=====================================
m4/prep_target_file.m4
=====================================
@@ -131,10 +131,20 @@ AC_DEFUN([PREP_TARGET_FILE],[
     PREP_MAYBE_SIMPLE_PROGRAM([DllWrapCmd])
     PREP_MAYBE_SIMPLE_PROGRAM([WindresCmd])
     PREP_MAYBE_STRING([TargetVendor_CPP])
+    PREP_MAYBE_STRING([HostVendor_CPP])
     PREP_LIST([SettingsCPPFlags])
     PREP_LIST([SettingsCxxCompilerFlags])
     PREP_LIST([SettingsCCompilerFlags])
 
+    dnl Host-target
+    PREP_BOOLEAN([ArSupportsAtFile_STAGE0])
+    PREP_BOOLEAN([ArSupportsDashL_STAGE0])
+    PREP_LIST([AR_OPTS_STAGE0])
+    PREP_LIST([CONF_CC_OPTS_STAGE0])
+    PREP_LIST([CONF_CPP_OPTS_STAGE0])
+    PREP_LIST([CONF_CXX_OPTS_STAGE0])
+    PREP_LIST([CONF_GCC_LINKER_OPTS_STAGE0])
+
     dnl PREP_ENDIANNESS
     case "$TargetWordBigEndian" in
         YES)


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
=====================================
@@ -74,6 +74,23 @@ data Target = Target
     }
     deriving (Read, Eq, Ord)
 
+-- | The word size as an integer representing the number of bytes
+wordSize2Bytes :: WordSize -> Int
+wordSize2Bytes WS4 = 4
+wordSize2Bytes WS8 = 8
+
+-- | Reconstruct the platform triple from a toolchain target
+-- (specifically from tgtArchOs and tgtVendor)
+targetPlatformTriple :: Target -> String
+targetPlatformTriple Target{tgtArchOs, tgtVendor} =
+  let archStr = stringEncodeArch $ archOS_arch tgtArchOs
+      osStr   = stringEncodeOS $ archOS_OS tgtArchOs
+   in case tgtVendor of
+        Nothing -> archStr <> "-" <> osStr
+        Just vendor -> archStr <> "-" <> vendor <> "-" <> osStr
+
+-- | Handwritten Show instance to have have better diffs against the toolchain
+-- targets generated by configure
 instance Show Target where
   show Target{..} = unlines
     [ "Target"
@@ -103,18 +120,3 @@ instance Show Target where
     , ", tgtWindres = " ++ show tgtDllwrap
     , "}"
     ]
-
--- | The word size as an integer representing the number of bytes
-wordSize2Bytes :: WordSize -> Int
-wordSize2Bytes WS4 = 4
-wordSize2Bytes WS8 = 8
-
--- | Reconstruct the platform triple from a toolchain target
--- (specifically from tgtArchOs and tgtVendor)
-targetPlatformTriple :: Target -> String
-targetPlatformTriple Target{tgtArchOs, tgtVendor} =
-  let archStr = stringEncodeArch $ archOS_arch tgtArchOs
-      osStr   = stringEncodeOS $ archOS_OS tgtArchOs
-   in case tgtVendor of
-        Nothing -> archStr <> "-" <> osStr
-        Just vendor -> archStr <> "-" <> vendor <> "-" <> osStr



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2554fd247305874d0a747d1b27b5987ccf934a56...bc625facfac57e4df664f670b5d292b59a663d8b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2554fd247305874d0a747d1b27b5987ccf934a56...bc625facfac57e4df664f670b5d292b59a663d8b
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/b23a0528/attachment-0001.html>


More information about the ghc-commits mailing list