Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
83ee7b78
by Ben Gamari at 2025-06-24T05:02:07-04:00
-
9329c9e1
by Ben Gamari at 2025-06-24T05:02:07-04:00
-
25f5c998
by Ben Gamari at 2025-06-24T05:02:08-04:00
-
51d150dd
by Rodrigo Mesquita at 2025-06-24T05:02:08-04:00
-
dcf68a83
by Rodrigo Mesquita at 2025-06-24T05:02:08-04:00
13 changed files:
- distrib/configure.ac.in
- hadrian/cfg/default.host.target.in
- hadrian/cfg/default.target.in
- hadrian/cfg/system.config.in
- hadrian/src/Builder.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Settings/Builders/RunTest.hs
- m4/fp_settings.m4
- m4/ghc_toolchain.m4
- m4/prep_target_file.m4
- utils/ghc-toolchain/exe/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
Changes:
| ... | ... | @@ -216,7 +216,7 @@ AC_SUBST([LlvmAsCmd]) |
| 216 | 216 | |
| 217 | 217 | dnl We know that `clang` supports `--target` and it is necessary to pass it
|
| 218 | 218 | dnl lest we see #25793.
|
| 219 | -if test -z "$LlvmAsFlags" ; then
|
|
| 219 | +if test -z "$LlvmAsFlags" && ! test -z "$LlvmTarget"; then
|
|
| 220 | 220 | LlvmAsFlags="--target=$LlvmTarget"
|
| 221 | 221 | fi
|
| 222 | 222 | AC_SUBST([LlvmAsFlags])
|
| ... | ... | @@ -38,5 +38,10 @@ Target |
| 38 | 38 | , tgtRanlib = Nothing
|
| 39 | 39 | , tgtNm = Nm {nmProgram = Program {prgPath = "", prgFlags = []}}
|
| 40 | 40 | , tgtMergeObjs = Just (MergeObjs {mergeObjsProgram = Program {prgPath = "@LD_STAGE0@", prgFlags = ["-r"]}, mergeObjsSupportsResponseFiles = False})
|
| 41 | +, tgtLlc = Nothing
|
|
| 42 | +, tgtOpt = Nothing
|
|
| 43 | +, tgtLlvmAs = Nothing
|
|
| 41 | 44 | , tgtWindres = Nothing
|
| 45 | +, tgtOtool = Nothing
|
|
| 46 | +, tgtInstallNameTool = Nothing
|
|
| 42 | 47 | } |
| ... | ... | @@ -38,5 +38,10 @@ Target |
| 38 | 38 | , tgtRanlib = Just (Ranlib {ranlibProgram = Program {prgPath = "@RanlibCmd@", prgFlags = []}})
|
| 39 | 39 | , tgtNm = Nm {nmProgram = Program {prgPath = "@NmCmd@", prgFlags = []}}
|
| 40 | 40 | , tgtMergeObjs = @MergeObjsCmdMaybe@
|
| 41 | +, tgtLlc = @LlcCmdMaybeProg@
|
|
| 42 | +, tgtOpt = @OptCmdMaybeProg@
|
|
| 43 | +, tgtLlvmAs = @LlvmAsCmdMaybeProg@
|
|
| 41 | 44 | , tgtWindres = @WindresCmdMaybeProg@
|
| 45 | +, tgtOtool = @OtoolCmdMaybeProg@
|
|
| 46 | +, tgtInstallNameTool = @InstallNameToolCmdMaybeProg@
|
|
| 42 | 47 | } |
| ... | ... | @@ -79,13 +79,6 @@ project-git-commit-id = @ProjectGitCommitId@ |
| 79 | 79 | # generated by configure, to generated being by the build system. Many of these
|
| 80 | 80 | # might become redundant.
|
| 81 | 81 | # See Note [tooldir: How GHC finds mingw on Windows]
|
| 82 | - |
|
| 83 | -settings-otool-command = @SettingsOtoolCommand@
|
|
| 84 | -settings-install_name_tool-command = @SettingsInstallNameToolCommand@
|
|
| 85 | -settings-llc-command = @SettingsLlcCommand@
|
|
| 86 | -settings-opt-command = @SettingsOptCommand@
|
|
| 87 | -settings-llvm-as-command = @SettingsLlvmAsCommand@
|
|
| 88 | -settings-llvm-as-flags = @SettingsLlvmAsFlags@
|
|
| 89 | 82 | settings-use-distro-mingw = @SettingsUseDistroMINGW@
|
| 90 | 83 | |
| 91 | 84 | target-has-libm = @TargetHasLibm@
|
| ... | ... | @@ -34,7 +34,6 @@ import Base |
| 34 | 34 | import Context
|
| 35 | 35 | import Oracles.Flag
|
| 36 | 36 | import Oracles.Setting (setting, Setting(..))
|
| 37 | -import Oracles.Setting (settingsFileSetting, ToolchainSetting(..))
|
|
| 38 | 37 | import Packages
|
| 39 | 38 | |
| 40 | 39 | import GHC.IO.Encoding (getFileSystemEncoding)
|
| ... | ... | @@ -240,7 +239,7 @@ instance H.Builder Builder where |
| 240 | 239 | Ghc _ st -> do
|
| 241 | 240 | root <- buildRoot
|
| 242 | 241 | unlitPath <- builderPath Unlit
|
| 243 | - distro_mingw <- settingsFileSetting ToolchainSetting_DistroMinGW
|
|
| 242 | + distro_mingw <- lookupSystemConfig "settings-use-distro-mingw"
|
|
| 244 | 243 | libffi_adjustors <- useLibffiForAdjustors
|
| 245 | 244 | use_system_ffi <- flag UseSystemFfi
|
| 246 | 245 |
| ... | ... | @@ -2,7 +2,6 @@ module Oracles.Setting ( |
| 2 | 2 | configFile,
|
| 3 | 3 | -- * Settings
|
| 4 | 4 | Setting (..), setting, getSetting,
|
| 5 | - ToolchainSetting (..), settingsFileSetting,
|
|
| 6 | 5 | |
| 7 | 6 | -- * Helpers
|
| 8 | 7 | ghcCanonVersion, cmdLineLengthLimit, targetSupportsRPaths, topDirectory,
|
| ... | ... | @@ -75,25 +74,6 @@ data Setting = CursesIncludeDir |
| 75 | 74 | | BourneShell
|
| 76 | 75 | | EmsdkVersion
|
| 77 | 76 | |
| 78 | --- TODO compute solely in Hadrian, removing these variables' definitions
|
|
| 79 | --- from aclocal.m4 whenever they can be calculated from other variables
|
|
| 80 | --- already fed into Hadrian.
|
|
| 81 | - |
|
| 82 | --- | All 'ToolchainSetting's are computed by the ghc-toolchain utility for configuring toolchains.
|
|
| 83 | --- This used to be defined by 'FP_SETTINGS' in aclocal.m4.
|
|
| 84 | ---
|
|
| 85 | --- TODO: We should be able to drop this completely, after moving all the toolchain settings to ghc-toolchain
|
|
| 86 | --- Move to ghc-toolchain and to the Target files generated by configure and ghc-toolchain
|
|
| 87 | --- * First we will get rid of DistroMinGW when we fix the windows build
|
|
| 88 | -data ToolchainSetting
|
|
| 89 | - = ToolchainSetting_OtoolCommand
|
|
| 90 | - | ToolchainSetting_InstallNameToolCommand
|
|
| 91 | - | ToolchainSetting_LlcCommand
|
|
| 92 | - | ToolchainSetting_OptCommand
|
|
| 93 | - | ToolchainSetting_LlvmAsCommand
|
|
| 94 | - | ToolchainSetting_LlvmAsFlags
|
|
| 95 | - | ToolchainSetting_DistroMinGW
|
|
| 96 | - |
|
| 97 | 77 | -- | Look up the value of a 'Setting' in @cfg/system.config@, tracking the
|
| 98 | 78 | -- result.
|
| 99 | 79 | setting :: Setting -> Action String
|
| ... | ... | @@ -134,20 +114,6 @@ setting key = lookupSystemConfig $ case key of |
| 134 | 114 | BourneShell -> "bourne-shell"
|
| 135 | 115 | EmsdkVersion -> "emsdk-version"
|
| 136 | 116 | |
| 137 | --- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the
|
|
| 138 | --- result.
|
|
| 139 | --- See Note [tooldir: How GHC finds mingw on Windows]
|
|
| 140 | --- ROMES:TODO: This should be queryTargetTargetConfig
|
|
| 141 | -settingsFileSetting :: ToolchainSetting -> Action String
|
|
| 142 | -settingsFileSetting key = lookupSystemConfig $ case key of
|
|
| 143 | - ToolchainSetting_OtoolCommand -> "settings-otool-command"
|
|
| 144 | - ToolchainSetting_InstallNameToolCommand -> "settings-install_name_tool-command"
|
|
| 145 | - ToolchainSetting_LlcCommand -> "settings-llc-command"
|
|
| 146 | - ToolchainSetting_OptCommand -> "settings-opt-command"
|
|
| 147 | - ToolchainSetting_LlvmAsCommand -> "settings-llvm-as-command"
|
|
| 148 | - ToolchainSetting_LlvmAsFlags -> "settings-llvm-as-flags"
|
|
| 149 | - ToolchainSetting_DistroMinGW -> "settings-use-distro-mingw" -- ROMES:TODO: This option doesn't seem to be in ghc-toolchain yet. It corresponds to EnableDistroToolchain
|
|
| 150 | - |
|
| 151 | 117 | -- | An expression that looks up the value of a 'Setting' in @cfg/system.config@,
|
| 152 | 118 | -- tracking the result.
|
| 153 | 119 | getSetting :: Setting -> Expr c b String
|
| ... | ... | @@ -424,7 +424,7 @@ bindistRules = do |
| 424 | 424 | , interpolateSetting "LlvmMinVersion" LlvmMinVersion
|
| 425 | 425 | , interpolateVar "LlvmTarget" $ getTarget tgtLlvmTarget
|
| 426 | 426 | , interpolateSetting "ProjectVersion" ProjectVersion
|
| 427 | - , interpolateVar "SettingsUseDistroMINGW" $ settingsFileSetting ToolchainSetting_DistroMinGW
|
|
| 427 | + , interpolateVar "SettingsUseDistroMINGW" $ lookupSystemConfig "settings-use-distro-mingw"
|
|
| 428 | 428 | , interpolateVar "TablesNextToCode" $ yesNo <$> getTarget tgtTablesNextToCode
|
| 429 | 429 | , interpolateVar "TargetHasLibm" $ lookupSystemConfig "target-has-libm"
|
| 430 | 430 | , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple
|
| ... | ... | @@ -508,9 +508,9 @@ generateSettings settingsFile = do |
| 508 | 508 | , ("ar flags", queryTarget arFlags)
|
| 509 | 509 | , ("ar supports at file", queryTarget arSupportsAtFile')
|
| 510 | 510 | , ("ar supports -L", queryTarget arSupportsDashL')
|
| 511 | - , ("ranlib command", queryTarget ranlibPath)
|
|
| 512 | - , ("otool command", expr $ settingsFileSetting ToolchainSetting_OtoolCommand)
|
|
| 513 | - , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand)
|
|
| 511 | + , ("ranlib command", queryTarget ranlibPath)
|
|
| 512 | + , ("otool command", queryTarget otoolPath)
|
|
| 513 | + , ("install_name_tool command", queryTarget installNameToolPath)
|
|
| 514 | 514 | , ("windres command", queryTarget (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me.
|
| 515 | 515 | , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit })))
|
| 516 | 516 | , ("cross compiling", expr $ yesNo <$> flag CrossCompiling)
|
| ... | ... | @@ -525,11 +525,11 @@ generateSettings settingsFile = do |
| 525 | 525 | , ("target has libm", expr $ lookupSystemConfig "target-has-libm")
|
| 526 | 526 | , ("Unregisterised", queryTarget (yesNo . tgtUnregisterised))
|
| 527 | 527 | , ("LLVM target", queryTarget tgtLlvmTarget)
|
| 528 | - , ("LLVM llc command", expr $ settingsFileSetting ToolchainSetting_LlcCommand)
|
|
| 529 | - , ("LLVM opt command", expr $ settingsFileSetting ToolchainSetting_OptCommand)
|
|
| 530 | - , ("LLVM llvm-as command", expr $ settingsFileSetting ToolchainSetting_LlvmAsCommand)
|
|
| 531 | - , ("LLVM llvm-as flags", expr $ settingsFileSetting ToolchainSetting_LlvmAsFlags)
|
|
| 532 | - , ("Use inplace MinGW toolchain", expr $ settingsFileSetting ToolchainSetting_DistroMinGW)
|
|
| 528 | + , ("LLVM llc command", queryTarget llcPath)
|
|
| 529 | + , ("LLVM opt command", queryTarget optPath)
|
|
| 530 | + , ("LLVM llvm-as command", queryTarget llvmAsPath)
|
|
| 531 | + , ("LLVM llvm-as flags", queryTarget llvmAsFlags)
|
|
| 532 | + , ("Use inplace MinGW toolchain", expr $ lookupSystemConfig "settings-use-distro-mingw")
|
|
| 533 | 533 | |
| 534 | 534 | , ("target RTS linker only supports shared libraries", expr $ yesNo <$> targetRTSLinkerOnlySupportsSharedLibs)
|
| 535 | 535 | , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter (predStage stage))
|
| ... | ... | @@ -571,10 +571,16 @@ generateSettings settingsFile = do |
| 571 | 571 | linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink
|
| 572 | 572 | linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink
|
| 573 | 573 | linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink
|
| 574 | + llcPath = maybe "" prgPath . tgtLlc
|
|
| 575 | + optPath = maybe "" prgPath . tgtOpt
|
|
| 576 | + llvmAsPath = maybe "" prgPath . tgtLlvmAs
|
|
| 577 | + llvmAsFlags = escapeArgs . maybe [] prgFlags . tgtLlvmAs
|
|
| 574 | 578 | arPath = prgPath . arMkArchive . tgtAr
|
| 575 | 579 | arFlags = escapeArgs . prgFlags . arMkArchive . tgtAr
|
| 576 | 580 | arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr
|
| 577 | 581 | arSupportsDashL' = yesNo . arSupportsDashL . tgtAr
|
| 582 | + otoolPath = maybe "" prgPath . tgtOtool
|
|
| 583 | + installNameToolPath = maybe "" prgPath . tgtInstallNameTool
|
|
| 578 | 584 | ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib
|
| 579 | 585 | mergeObjsSupportsResponseFiles' = maybe "NO" (yesNo . mergeObjsSupportsResponseFiles) . tgtMergeObjs
|
| 580 | 586 |
| ... | ... | @@ -127,9 +127,9 @@ inTreeCompilerArgs stg = do |
| 127 | 127 | platform <- queryTargetTarget targetPlatformTriple
|
| 128 | 128 | wordsize <- show @Int . (*8) <$> queryTargetTarget (wordSize2Bytes . tgtWordSize)
|
| 129 | 129 | |
| 130 | - llc_cmd <- settingsFileSetting ToolchainSetting_LlcCommand
|
|
| 131 | - llvm_as_cmd <- settingsFileSetting ToolchainSetting_LlvmAsCommand
|
|
| 132 | - have_llvm <- liftIO (all isJust <$> mapM findExecutable [llc_cmd, llvm_as_cmd])
|
|
| 130 | + llc_cmd <- queryTargetTarget tgtLlc
|
|
| 131 | + llvm_as_cmd <- queryTargetTarget tgtLlvmAs
|
|
| 132 | + let have_llvm = all isJust [llc_cmd, llvm_as_cmd]
|
|
| 133 | 133 | |
| 134 | 134 | top <- topDirectory
|
| 135 | 135 |
| ... | ... | @@ -136,14 +136,7 @@ AC_DEFUN([FP_SETTINGS], |
| 136 | 136 | fi
|
| 137 | 137 | |
| 138 | 138 | # Mac-only tools
|
| 139 | - if test -z "$OtoolCmd"; then
|
|
| 140 | - OtoolCmd="otool"
|
|
| 141 | - fi
|
|
| 142 | 139 | SettingsOtoolCommand="$OtoolCmd"
|
| 143 | - |
|
| 144 | - if test -z "$InstallNameToolCmd"; then
|
|
| 145 | - InstallNameToolCmd="install_name_tool"
|
|
| 146 | - fi
|
|
| 147 | 140 | SettingsInstallNameToolCommand="$InstallNameToolCmd"
|
| 148 | 141 | |
| 149 | 142 | SettingsCCompilerSupportsNoPie="$CONF_GCC_SUPPORTS_NO_PIE"
|
| ... | ... | @@ -107,6 +107,9 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN], |
| 107 | 107 | echo "--merge-objs=$MergeObjsCmd" >> acargs
|
| 108 | 108 | echo "--readelf=$READELF" >> acargs
|
| 109 | 109 | echo "--windres=$WindresCmd" >> acargs
|
| 110 | + echo "--llc=$LlcCmd" >> acargs
|
|
| 111 | + echo "--opt=$OptCmd" >> acargs
|
|
| 112 | + echo "--llvm-as=$LlvmAsCmd" >> acargs
|
|
| 110 | 113 | |
| 111 | 114 | if test -n "$USER_LD"; then
|
| 112 | 115 | echo "--ld=$USER_LD" >> acargs
|
| ... | ... | @@ -10,6 +10,38 @@ |
| 10 | 10 | # This toolchain will additionally be used to validate the one generated by
|
| 11 | 11 | # ghc-toolchain. See Note [ghc-toolchain consistency checking].
|
| 12 | 12 | |
| 13 | +# PREP_LIST
|
|
| 14 | +# ============
|
|
| 15 | +#
|
|
| 16 | +# Issue a substitution with ["list","of","args"] of [$1List] when $1 is a
|
|
| 17 | +# space-separated list of args
|
|
| 18 | +# i.e.
|
|
| 19 | +# "arg1 arg2 arg3"
|
|
| 20 | +# ==>
|
|
| 21 | +# ["arg1","arg2","arg3"]
|
|
| 22 | +#
|
|
| 23 | +# $1 = list variable to substitute
|
|
| 24 | +dnl In autoconf, '@<:@' stands for '[', and '@:>@' for ']'.
|
|
| 25 | +AC_DEFUN([PREP_LIST],[
|
|
| 26 | + # shell array
|
|
| 27 | + set -- $$1
|
|
| 28 | + $1List="@<:@"
|
|
| 29 | + if test "[$]#" -eq 0; then
|
|
| 30 | + # no arguments
|
|
| 31 | + true
|
|
| 32 | + else
|
|
| 33 | + $1List="${$1List}\"[$]1\""
|
|
| 34 | + shift # drop first elem
|
|
| 35 | + for arg in "[$]@"
|
|
| 36 | + do
|
|
| 37 | + $1List="${$1List},\"$arg\""
|
|
| 38 | + done
|
|
| 39 | + fi
|
|
| 40 | + $1List="${$1List}@:>@"
|
|
| 41 | + |
|
| 42 | + AC_SUBST([$1List])
|
|
| 43 | +])
|
|
| 44 | + |
|
| 13 | 45 | # PREP_MAYBE_SIMPLE_PROGRAM
|
| 14 | 46 | # =========================
|
| 15 | 47 | #
|
| ... | ... | @@ -27,6 +59,25 @@ AC_DEFUN([PREP_MAYBE_SIMPLE_PROGRAM],[ |
| 27 | 59 | AC_SUBST([$1MaybeProg])
|
| 28 | 60 | ])
|
| 29 | 61 | |
| 62 | +# PREP_MAYBE_PROGRAM
|
|
| 63 | +# =========================
|
|
| 64 | +#
|
|
| 65 | +# Introduce a substitution [$1MaybeProg] with
|
|
| 66 | +# * Nothing, if $$1 is empty
|
|
| 67 | +# * Just (Program {prgPath = "$$1", prgFlags = [elements of $$2]}), otherwise
|
|
| 68 | +#
|
|
| 69 | +# $1 = optional program path
|
|
| 70 | +# $2 = program arguments
|
|
| 71 | +AC_DEFUN([PREP_MAYBE_PROGRAM],[
|
|
| 72 | + if test -z "$$1"; then
|
|
| 73 | + $1MaybeProg=Nothing
|
|
| 74 | + else
|
|
| 75 | + PREP_LIST([$2])
|
|
| 76 | + $1MaybeProg="Just (Program {prgPath = \"$$1\", prgFlags = $$2List})"
|
|
| 77 | + fi
|
|
| 78 | + AC_SUBST([$1MaybeProg])
|
|
| 79 | +])
|
|
| 80 | + |
|
| 30 | 81 | # PREP_MAYBE_STRING
|
| 31 | 82 | # =========================
|
| 32 | 83 | #
|
| ... | ... | @@ -86,38 +137,6 @@ AC_DEFUN([PREP_NOT_BOOLEAN],[ |
| 86 | 137 | AC_SUBST([Not$1Bool])
|
| 87 | 138 | ])
|
| 88 | 139 | |
| 89 | -# PREP_LIST
|
|
| 90 | -# ============
|
|
| 91 | -#
|
|
| 92 | -# Issue a substitution with ["list","of","args"] of [$1List] when $1 is a
|
|
| 93 | -# space-separated list of args
|
|
| 94 | -# i.e.
|
|
| 95 | -# "arg1 arg2 arg3"
|
|
| 96 | -# ==>
|
|
| 97 | -# ["arg1","arg2","arg3"]
|
|
| 98 | -#
|
|
| 99 | -# $1 = list variable to substitute
|
|
| 100 | -dnl In autoconf, '@<:@' stands for '[', and '@:>@' for ']'.
|
|
| 101 | -AC_DEFUN([PREP_LIST],[
|
|
| 102 | - # shell array
|
|
| 103 | - set -- $$1
|
|
| 104 | - $1List="@<:@"
|
|
| 105 | - if test "[$]#" -eq 0; then
|
|
| 106 | - # no arguments
|
|
| 107 | - true
|
|
| 108 | - else
|
|
| 109 | - $1List="${$1List}\"[$]1\""
|
|
| 110 | - shift # drop first elem
|
|
| 111 | - for arg in "[$]@"
|
|
| 112 | - do
|
|
| 113 | - $1List="${$1List},\"$arg\""
|
|
| 114 | - done
|
|
| 115 | - fi
|
|
| 116 | - $1List="${$1List}@:>@"
|
|
| 117 | - |
|
| 118 | - AC_SUBST([$1List])
|
|
| 119 | -])
|
|
| 120 | - |
|
| 121 | 140 | # Eventually: PREP_BUILD_TARGET_FILE, PREP_HOST_TARGET_FILE, PREP_TARGET_TARGET_FILE
|
| 122 | 141 | # Prepares required substitutions to generate the target file
|
| 123 | 142 | AC_DEFUN([PREP_TARGET_FILE],[
|
| ... | ... | @@ -148,7 +167,12 @@ AC_DEFUN([PREP_TARGET_FILE],[ |
| 148 | 167 | PREP_LIST([JavaScriptCPPArgs])
|
| 149 | 168 | PREP_LIST([CmmCPPArgs])
|
| 150 | 169 | PREP_LIST([CmmCPPArgs_STAGE0])
|
| 170 | + PREP_MAYBE_SIMPLE_PROGRAM([LlcCmd])
|
|
| 171 | + PREP_MAYBE_SIMPLE_PROGRAM([OptCmd])
|
|
| 172 | + PREP_MAYBE_PROGRAM([LlvmAsCmd], [LlvmAsFlags])
|
|
| 151 | 173 | PREP_MAYBE_SIMPLE_PROGRAM([WindresCmd])
|
| 174 | + PREP_MAYBE_SIMPLE_PROGRAM([OtoolCmd])
|
|
| 175 | + PREP_MAYBE_SIMPLE_PROGRAM([InstallNameToolCmd])
|
|
| 152 | 176 | PREP_MAYBE_STRING([TargetVendor_CPP])
|
| 153 | 177 | PREP_MAYBE_STRING([HostVendor_CPP])
|
| 154 | 178 | PREP_LIST([CONF_CPP_OPTS_STAGE2])
|
| ... | ... | @@ -52,7 +52,12 @@ data Opts = Opts |
| 52 | 52 | , optNm :: ProgOpt
|
| 53 | 53 | , optReadelf :: ProgOpt
|
| 54 | 54 | , optMergeObjs :: ProgOpt
|
| 55 | + , optLlc :: ProgOpt
|
|
| 56 | + , optOpt :: ProgOpt
|
|
| 57 | + , optLlvmAs :: ProgOpt
|
|
| 55 | 58 | , optWindres :: ProgOpt
|
| 59 | + , optOtool :: ProgOpt
|
|
| 60 | + , optInstallNameTool :: ProgOpt
|
|
| 56 | 61 | -- Note we don't actually configure LD into anything but
|
| 57 | 62 | -- see #23857 and #22550 for the very unfortunate story.
|
| 58 | 63 | , optLd :: ProgOpt
|
| ... | ... | @@ -99,8 +104,13 @@ emptyOpts = Opts |
| 99 | 104 | , optNm = po0
|
| 100 | 105 | , optReadelf = po0
|
| 101 | 106 | , optMergeObjs = po0
|
| 107 | + , optLlc = po0
|
|
| 108 | + , optOpt = po0
|
|
| 109 | + , optLlvmAs = po0
|
|
| 102 | 110 | , optWindres = po0
|
| 103 | 111 | , optLd = po0
|
| 112 | + , optOtool = po0
|
|
| 113 | + , optInstallNameTool = po0
|
|
| 104 | 114 | , optUnregisterised = Nothing
|
| 105 | 115 | , optTablesNextToCode = Nothing
|
| 106 | 116 | , optUseLibFFIForAdjustors = Nothing
|
| ... | ... | @@ -112,7 +122,8 @@ emptyOpts = Opts |
| 112 | 122 | po0 = emptyProgOpt
|
| 113 | 123 | |
| 114 | 124 | _optCc, _optCxx, _optCpp, _optHsCpp, _optJsCpp, _optCmmCpp, _optCcLink, _optAr,
|
| 115 | - _optRanlib, _optNm, _optReadelf, _optMergeObjs, _optWindres, _optLd
|
|
| 125 | + _optRanlib, _optNm, _optReadelf, _optMergeObjs, _optLlc, _optOpt, _optLlvmAs,
|
|
| 126 | + _optWindres, _optLd, _optOtool, _optInstallNameTool
|
|
| 116 | 127 | :: Lens Opts ProgOpt
|
| 117 | 128 | _optCc = Lens optCc (\x o -> o {optCc=x})
|
| 118 | 129 | _optCxx = Lens optCxx (\x o -> o {optCxx=x})
|
| ... | ... | @@ -126,8 +137,13 @@ _optRanlib = Lens optRanlib (\x o -> o {optRanlib=x}) |
| 126 | 137 | _optNm = Lens optNm (\x o -> o {optNm=x})
|
| 127 | 138 | _optReadelf = Lens optReadelf (\x o -> o {optReadelf=x})
|
| 128 | 139 | _optMergeObjs = Lens optMergeObjs (\x o -> o {optMergeObjs=x})
|
| 140 | +_optLlc = Lens optLlc (\x o -> o {optLlc=x})
|
|
| 141 | +_optOpt = Lens optOpt (\x o -> o {optOpt=x})
|
|
| 142 | +_optLlvmAs = Lens optLlvmAs (\x o -> o {optLlvmAs=x})
|
|
| 129 | 143 | _optWindres = Lens optWindres (\x o -> o {optWindres=x})
|
| 130 | -_optLd = Lens optLd (\x o -> o {optLd= x})
|
|
| 144 | +_optLd = Lens optLd (\x o -> o {optLd=x})
|
|
| 145 | +_optOtool = Lens optOtool (\x o -> o {optOtool=x})
|
|
| 146 | +_optInstallNameTool = Lens optInstallNameTool (\x o -> o {optInstallNameTool=x})
|
|
| 131 | 147 | |
| 132 | 148 | _optTriple :: Lens Opts (Maybe String)
|
| 133 | 149 | _optTriple = Lens optTriple (\x o -> o {optTriple=x})
|
| ... | ... | @@ -183,8 +199,13 @@ options = |
| 183 | 199 | , progOpts "nm" "nm archiver" _optNm
|
| 184 | 200 | , progOpts "readelf" "readelf utility" _optReadelf
|
| 185 | 201 | , progOpts "merge-objs" "linker for merging objects" _optMergeObjs
|
| 202 | + , progOpts "llc" "LLVM llc utility" _optLlc
|
|
| 203 | + , progOpts "opt" "LLVM opt utility" _optOpt
|
|
| 204 | + , progOpts "llvm-as" "Assembler used for LLVM backend (typically clang)" _optLlvmAs
|
|
| 186 | 205 | , progOpts "windres" "windres utility" _optWindres
|
| 187 | 206 | , progOpts "ld" "linker" _optLd
|
| 207 | + , progOpts "otool" "otool utility" _optOtool
|
|
| 208 | + , progOpts "install-name-tool" "install-name-tool utility" _optInstallNameTool
|
|
| 188 | 209 | ]
|
| 189 | 210 | where
|
| 190 | 211 | progOpts :: String -> String -> Lens Opts ProgOpt -> [OptDescr (Opts -> Opts)]
|
| ... | ... | @@ -436,6 +457,11 @@ mkTarget opts = do |
| 436 | 457 | when (isNothing mergeObjs && not (arSupportsDashL ar)) $
|
| 437 | 458 | throwE "Neither a object-merging tool (e.g. ld -r) nor an ar that supports -L is available"
|
| 438 | 459 | |
| 460 | + -- LLVM toolchain
|
|
| 461 | + llc <- optional $ findProgram "llc" (optLlc opts) ["llc"]
|
|
| 462 | + opt <- optional $ findProgram "opt" (optOpt opts) ["opt"]
|
|
| 463 | + llvmAs <- optional $ findProgram "llvm assembler" (optLlvmAs opts) ["clang"]
|
|
| 464 | + |
|
| 439 | 465 | -- Windows-specific utilities
|
| 440 | 466 | windres <-
|
| 441 | 467 | case archOS_OS archOs of
|
| ... | ... | @@ -444,6 +470,15 @@ mkTarget opts = do |
| 444 | 470 | return (Just windres)
|
| 445 | 471 | _ -> return Nothing
|
| 446 | 472 | |
| 473 | + -- Darwin-specific utilities
|
|
| 474 | + (otool, installNameTool) <-
|
|
| 475 | + case archOS_OS archOs of
|
|
| 476 | + OSDarwin -> do
|
|
| 477 | + otool <- findProgram "otool" (optOtool opts) ["otool"]
|
|
| 478 | + installNameTool <- findProgram "install_name_tool" (optInstallNameTool opts) ["install_name_tool"]
|
|
| 479 | + return (Just otool, Just installNameTool)
|
|
| 480 | + _ -> return (Nothing, Nothing)
|
|
| 481 | + |
|
| 447 | 482 | -- various other properties of the platform
|
| 448 | 483 | tgtWordSize <- checkWordSize cc
|
| 449 | 484 | tgtEndianness <- checkEndianness cc
|
| ... | ... | @@ -480,7 +515,12 @@ mkTarget opts = do |
| 480 | 515 | , tgtRanlib = ranlib
|
| 481 | 516 | , tgtNm = nm
|
| 482 | 517 | , tgtMergeObjs = mergeObjs
|
| 518 | + , tgtLlc = llc
|
|
| 519 | + , tgtOpt = opt
|
|
| 520 | + , tgtLlvmAs = llvmAs
|
|
| 483 | 521 | , tgtWindres = windres
|
| 522 | + , tgtOtool = otool
|
|
| 523 | + , tgtInstallNameTool = installNameTool
|
|
| 484 | 524 | , tgtWordSize
|
| 485 | 525 | , tgtEndianness
|
| 486 | 526 | , tgtUnregisterised
|
| ... | ... | @@ -22,15 +22,6 @@ data WordSize = WS4 | WS8 |
| 22 | 22 | data Endianness = LittleEndian | BigEndian
|
| 23 | 23 | deriving (Show, Read, Eq, Ord)
|
| 24 | 24 | |
| 25 | --- TODO(#23674): Move the remaining relevant `settings-xxx` to Target:
|
|
| 26 | --- * llc command
|
|
| 27 | --- * opt command
|
|
| 28 | --- * install_name_tool
|
|
| 29 | --- * otool command
|
|
| 30 | ---
|
|
| 31 | --- Those are all things that are put into GHC's settings, and that might be
|
|
| 32 | --- different across targets
|
|
| 33 | - |
|
| 34 | 25 | -- | A 'Target' consists of:
|
| 35 | 26 | --
|
| 36 | 27 | -- * a target architecture and operating system
|
| ... | ... | @@ -72,8 +63,18 @@ data Target = Target |
| 72 | 63 | , tgtMergeObjs :: Maybe MergeObjs
|
| 73 | 64 | -- ^ We don't need a merge objects tool if we @Ar@ supports @-L@
|
| 74 | 65 | |
| 66 | + -- LLVM backend toolchain
|
|
| 67 | + , tgtLlc :: Maybe Program
|
|
| 68 | + , tgtOpt :: Maybe Program
|
|
| 69 | + , tgtLlvmAs :: Maybe Program
|
|
| 70 | + -- ^ assembler used to assemble LLVM backend output; typically @clang@
|
|
| 71 | + |
|
| 75 | 72 | -- Windows-specific tools
|
| 76 | 73 | , tgtWindres :: Maybe Program
|
| 74 | + |
|
| 75 | + -- Darwin-specific tools
|
|
| 76 | + , tgtOtool :: Maybe Program
|
|
| 77 | + , tgtInstallNameTool :: Maybe Program
|
|
| 77 | 78 | }
|
| 78 | 79 | deriving (Read, Eq, Ord)
|
| 79 | 80 | |
| ... | ... | @@ -121,6 +122,11 @@ instance Show Target where |
| 121 | 122 | , ", tgtRanlib = " ++ show tgtRanlib
|
| 122 | 123 | , ", tgtNm = " ++ show tgtNm
|
| 123 | 124 | , ", tgtMergeObjs = " ++ show tgtMergeObjs
|
| 125 | + , ", tgtLlc = " ++ show tgtLlc
|
|
| 126 | + , ", tgtOpt = " ++ show tgtOpt
|
|
| 127 | + , ", tgtLlvmAs = " ++ show tgtLlvmAs
|
|
| 124 | 128 | , ", tgtWindres = " ++ show tgtWindres
|
| 129 | + , ", tgtOtool = " ++ show tgtOtool
|
|
| 130 | + , ", tgtInstallNameTool = " ++ show tgtInstallNameTool
|
|
| 125 | 131 | , "}"
|
| 126 | 132 | ] |