[Git][ghc/ghc][wip/supersven/add-LLVMAS-target] WIP: Select LLVMAS target in configure tools

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Fri Aug 2 07:52:54 UTC 2024



Sven Tennie pushed to branch wip/supersven/add-LLVMAS-target at Glasgow Haskell Compiler / GHC


Commits:
42fe0568 by Sven Tennie at 2024-08-02T09:52:39+02:00
WIP: Select LLVMAS target in configure tools

- - - - -


9 changed files:

- compiler/GHC/Settings/IO.hs
- configure.ac
- hadrian/cfg/default.host.target.in
- hadrian/cfg/default.target.in
- hadrian/src/Rules/Generate.hs
- m4/fp_settings.m4
- m4/prep_target_file.m4
- utils/ghc-toolchain/exe/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Target.hs


Changes:

=====================================
compiler/GHC/Settings/IO.hs
=====================================
@@ -167,6 +167,7 @@ initSettings top_dir = do
   lc_prog <- getSetting "LLVM llc command"
   lo_prog <- getSetting "LLVM opt command"
   las_prog <- getSetting "LLVM llvm-as command"
+  las_args <- getSetting "LLVM llvm-as flags"
 
   let iserv_prog = libexec "ghc-iserv"
 
@@ -234,7 +235,7 @@ initSettings top_dir = do
       , toolSettings_opt_windres = []
       , toolSettings_opt_lo      = []
       , toolSettings_opt_lc      = []
-      , toolSettings_opt_las     = ["--target=" ++ llvmTarget]
+      , toolSettings_opt_las     = las_args
       , toolSettings_opt_i       = []
 
       , toolSettings_extraGccViaCFlags = extraGccViaCFlags


=====================================
configure.ac
=====================================
@@ -390,6 +390,8 @@ fi
 AC_SUBST(CrossCompiling)
 AC_SUBST(TargetPlatformFull)
 
+FP_PROG_LLVM_AS_ARGS()
+
 dnl ** Which gcc to use?
 dnl --------------------------------------------------------------
 


=====================================
hadrian/cfg/default.host.target.in
=====================================
@@ -9,6 +9,7 @@ Target
 , tgtEndianness = LittleEndian
 , tgtSymbolsHaveLeadingUnderscore = False
 , tgtLlvmTarget = "@HostPlatform@"
+, tgtLlvmAsArgs = @LlvmAsArgsHostList@
 , tgtUnregisterised = False
 , tgtTablesNextToCode = True
 , tgtUseLibffiForAdjustors = True


=====================================
hadrian/cfg/default.target.in
=====================================
@@ -9,6 +9,7 @@ Target
 , tgtEndianness = @TargetEndianness@
 , tgtSymbolsHaveLeadingUnderscore = @LeadingUnderscoreBool@
 , tgtLlvmTarget = "@LlvmTarget@"
+, tgtLlvmAsArgs = @LlvmAsArgsTargetList@
 , tgtUnregisterised = @UnregisterisedBool@
 , tgtTablesNextToCode = @TablesNextToCodeBool@
 , tgtUseLibffiForAdjustors = @UseLibffiForAdjustorsBool@


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -490,7 +490,8 @@ generateSettings settingsFile = do
         , ("LLVM target", queryTarget tgtLlvmTarget)
         , ("LLVM llc command", expr $ settingsFileSetting ToolchainSetting_LlcCommand)
         , ("LLVM opt command", expr $ settingsFileSetting ToolchainSetting_OptCommand)
-        , ("LLVM llvm-as command", expr $ settingsFileSetting ToolchainSetting_LlvmAsCommand)
+        , ("LLVM llvm-as command flags", queryTarget llvmAsFlags)
+        , ("LLVM llvm-as flags", expr $ settingsFileSetting ToolchainSetting_LlvmAsCommand)
         , ("Use inplace MinGW toolchain", expr $ settingsFileSetting ToolchainSetting_DistroMinGW)
 
         , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter)
@@ -537,6 +538,7 @@ generateSettings settingsFile = do
     arSupportsDashL' = yesNo . arSupportsDashL . tgtAr
     ranlibPath  = maybe "" (prgPath . ranlibProgram) . tgtRanlib
     mergeObjsSupportsResponseFiles' = maybe "NO" (yesNo . mergeObjsSupportsResponseFiles) . tgtMergeObjs
+    llvmAsFlags = escapeArgs . tgtLlvmAsArgs
 
 isBigEndian, wordSize :: Toolchain.Target -> String
 isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness


=====================================
m4/fp_settings.m4
=====================================
@@ -128,6 +128,7 @@ AC_DEFUN([FP_SETTINGS],
     SettingsOptCommand="$OptCmd"
 
     SettingsLlvmAsCommand="$LlvmAsCmd"
+    SettingsLlvmAsArgs="$LlvmAsArgs"
 
     # Mac-only tools
     if test -z "$OtoolCmd"; then
@@ -168,4 +169,5 @@ AC_DEFUN([FP_SETTINGS],
     AC_SUBST(SettingsOptCommand)
     AC_SUBST(SettingsLlvmAsCommand)
     AC_SUBST(SettingsUseDistroMINGW)
+    AC_SUBST(SettingsLlvmAsArgs)
 ])


=====================================
m4/prep_target_file.m4
=====================================
@@ -154,6 +154,8 @@ AC_DEFUN([PREP_TARGET_FILE],[
     PREP_LIST([CONF_CPP_OPTS_STAGE2])
     PREP_LIST([CONF_CXX_OPTS_STAGE2])
     PREP_LIST([CONF_CC_OPTS_STAGE2])
+    PREP_LIST([LlvmAsArgsHost])
+    PREP_LIST([LlvmAsArgsTarget])
 
     dnl Host target
     PREP_BOOLEAN([ArSupportsAtFile_STAGE0])


=====================================
utils/ghc-toolchain/exe/Main.hs
=====================================
@@ -392,6 +392,7 @@ mkTarget opts = do
     normalised_triple <- normaliseTriple (optTriple opts)
     -- Use Llvm target if specified, otherwise use triple as llvm target
     let tgtLlvmTarget = fromMaybe normalised_triple (optLlvmTriple opts)
+        tgtLlvmAsArgs = ["--target=" <> tgtLlvmTarget]
 
     (archOs, tgtVendor) <- do
       cc0 <- findBasicCc (optCc opts)
@@ -478,6 +479,7 @@ mkTarget opts = do
                    , tgtSupportsIdentDirective
                    , tgtSupportsGnuNonexecStack
                    , tgtLlvmTarget
+                   , tgtLlvmAsArgs
                    }
     return t
 


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
=====================================
@@ -48,6 +48,7 @@ data Target = Target
     , tgtEndianness :: Endianness
     , tgtSymbolsHaveLeadingUnderscore :: Bool
     , tgtLlvmTarget :: String
+    , tgtLlvmAsArgs :: [String]
 
       -- GHC capabilities
     , tgtUnregisterised :: Bool
@@ -107,6 +108,7 @@ instance Show Target where
     , ", tgtEndianness = " ++ show tgtEndianness
     , ", tgtSymbolsHaveLeadingUnderscore = " ++ show tgtSymbolsHaveLeadingUnderscore
     , ", tgtLlvmTarget = " ++ show tgtLlvmTarget
+    , ", tgtLlvmAsArgs = " ++ show tgtLlvmAsArgs
     , ", tgtUnregisterised = " ++ show tgtUnregisterised
     , ", tgtTablesNextToCode = " ++ show tgtTablesNextToCode
     , ", tgtUseLibffiForAdjustors = " ++ show tgtUseLibffiForAdjustors



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/42fe0568418196da0b6ab8b97bcea9e49d692d4e
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/20240802/4ea3d2f8/attachment-0001.html>


More information about the ghc-commits mailing list