[Git][ghc/ghc][wip/hadrian-windows-bindist-cross] 2 commits: ghc-toolchain: Add loongarch64 to parseArch
Matthew Pickering (@mpickering)
gitlab at gitlab.haskell.org
Tue Aug 22 15:56:26 UTC 2023
Matthew Pickering pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC
Commits:
b84ae3db by Matthew Pickering at 2023-08-21T13:26:52+01:00
ghc-toolchain: Add loongarch64 to parseArch
- - - - -
c5b9fe24 by Matthew Pickering at 2023-08-22T16:56:04+01:00
WIP: Add same LD hack to ghc-toolchain
- - - - -
5 changed files:
- configure.ac
- m4/ghc_toolchain.m4
- utils/ghc-toolchain/exe/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
Changes:
=====================================
configure.ac
=====================================
@@ -55,6 +55,8 @@ USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2"
USER_CONF_CXX_OPTS_STAGE2="$CONF_CXX_OPTS_STAGE2"
USER_CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2"
+USER_LD="$LD"
+
dnl ----------------------------------------------------------
dnl ** Find unixy sort and find commands,
dnl ** which are needed by FP_SETUP_PROJECT_VERSION
=====================================
m4/ghc_toolchain.m4
=====================================
@@ -106,6 +106,10 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
echo "--readelf=$READELF" >> acargs
echo "--windres=$WindresCmd" >> acargs
+ if test -n "$USER_LD"; then
+ echo "--ld=$USER_LD" >> acargs
+ fi
+
ENABLE_GHC_TOOLCHAIN_NOT_ARG([locally-executable], [$CrossCompiling])
ENABLE_GHC_TOOLCHAIN_ARG([unregisterised], [$Unregisterised])
ENABLE_GHC_TOOLCHAIN_ARG([tables-next-to-code], [$TablesNextToCode])
=====================================
utils/ghc-toolchain/exe/Main.hs
=====================================
@@ -50,6 +50,9 @@ data Opts = Opts
, optReadelf :: ProgOpt
, optMergeObjs :: ProgOpt
, optWindres :: ProgOpt
+ -- Note we don't actually configure LD into anything but
+ -- see #23857 and #22550 for the very unfortunate story.
+ , optLd :: ProgOpt
, optUnregisterised :: Maybe Bool
, optTablesNextToCode :: Maybe Bool
, optUseLibFFIForAdjustors :: Maybe Bool
@@ -92,6 +95,7 @@ emptyOpts = Opts
, optReadelf = po0
, optMergeObjs = po0
, optWindres = po0
+ , optLd = po0
, optUnregisterised = Nothing
, optTablesNextToCode = Nothing
, optUseLibFFIForAdjustors = Nothing
@@ -116,6 +120,7 @@ _optNm = Lens optNm (\x o -> o {optNm=x})
_optReadelf = Lens optReadelf (\x o -> o {optReadelf=x})
_optMergeObjs = Lens optMergeObjs (\x o -> o {optMergeObjs=x})
_optWindres = Lens optWindres (\x o -> o {optWindres=x})
+_optLd = Lens optLd (\x o -> o {optLd= x})
_optTriple :: Lens Opts String
_optTriple = Lens optTriple (\x o -> o {optTriple=x})
@@ -170,6 +175,7 @@ options =
, progOpts "readelf" "readelf utility" _optReadelf
, progOpts "merge-objs" "linker for merging objects" _optMergeObjs
, progOpts "windres" "windres utility" _optWindres
+ , progOpts "ld" "linker" _optLd
]
where
progOpts :: String -> String -> Lens Opts ProgOpt -> [OptDescr (Opts -> Opts)]
@@ -381,7 +387,7 @@ mkTarget opts = do
(archOs, tgtVendor) <- parseTriple cc0 normalised_triple
cc <- addPlatformDepCcFlags archOs cc0
readelf <- optional $ findReadelf (optReadelf opts)
- ccLink <- findCcLink tgtLlvmTarget (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf
+ ccLink <- findCcLink tgtLlvmTarget (optLd opts) (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf
ar <- findAr tgtVendor (optAr opts)
-- TODO: We could have
=====================================
utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
=====================================
@@ -54,6 +54,7 @@ parseArch cc arch =
"hppa" -> pure ArchUnknown
"wasm32" -> pure ArchWasm32
"javascript" -> pure ArchJavaScript
+ "loongarch64" -> pure ArchLoongArch64
_ -> throwE $ "Unknown architecture " ++ arch
parseOs :: String -> M OS
=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
=====================================
@@ -42,17 +42,20 @@ _ccLinkProgram :: Lens CcLink Program
_ccLinkProgram = Lens ccLinkProgram (\x o -> o{ccLinkProgram=x})
findCcLink :: String -- ^ The llvm target to use if CcLink supports --target
+ -> ProgOpt
-> ProgOpt
-> Bool -- ^ Whether we should search for a more efficient linker
-> ArchOS -> Cc -> Maybe Readelf -> M CcLink
-findCcLink target progOpt ldOverride archOs cc readelf = checking "for C compiler for linking command" $ do
+findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C compiler for linking command" $ do
-- Use the specified linker or try using the C compiler
rawCcLink <- findProgram "C compiler for linking" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) [])
- ccLinkProgram <- case poFlags progOpt of
- Just _ ->
+ ccLinkProgram <- case (poPath ld, poFlags progOpt) of
+ (_, Just _) ->
-- If the user specified linker flags don't second-guess them
pure rawCcLink
- Nothing -> do
+ (Just {}, _) ->
+ pure rawCcLink
+ _ -> do
-- If not then try to find decent linker flags
findLinkFlags ldOverride cc rawCcLink <|> pure rawCcLink
ccLinkProgram <- linkSupportsTarget archOs cc target ccLinkProgram
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65bc9cbeee221ab4fe6f82eb0504d18a825f7e11...c5b9fe24ebbb195ac58dec1fc0fe7f443f9ecec3
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65bc9cbeee221ab4fe6f82eb0504d18a825f7e11...c5b9fe24ebbb195ac58dec1fc0fe7f443f9ecec3
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/20230822/071fadae/attachment-0001.html>
More information about the ghc-commits
mailing list