Fix cross installation

See https://gitlab.haskell.org/ghc/ghc/-/issues/14297
This commit is contained in:
Julian Ospald 2021-07-15 20:30:33 +02:00
parent 7e14fd4a08
commit bc85a7d9c3
Signed by: hasufell
GPG Key ID: 3786C5262ECB4A3F

View File

@ -1618,11 +1618,11 @@ compileGHC targetGhc ov bstrap jobs mbuildConfig patchdir aargs
Right g -> pure $ Right g Right g -> pure $ Right g
Left bver -> pure $ Left ("ghc-" <> (T.unpack . prettyVer $ bver) <> exeExt) Left bver -> pure $ Left ("ghc-" <> (T.unpack . prettyVer $ bver) <> exeExt)
(bindist, bmk) <- liftE $ runBuildAction (mBindist, bmk) <- liftE $ runBuildAction
tmpUnpack tmpUnpack
Nothing Nothing
(do (do
b <- compileBindist bghc tver workdir b <- compileBindist bghc tver workdir ghcdir
bmk <- liftIO $ B.readFile (build_mk workdir) bmk <- liftIO $ B.readFile (build_mk workdir)
pure (b, bmk) pure (b, bmk)
) )
@ -1630,6 +1630,8 @@ compileGHC targetGhc ov bstrap jobs mbuildConfig patchdir aargs
when alreadyInstalled $ do when alreadyInstalled $ do
lift $ $(logInfo) [i|Deleting existing installation|] lift $ $(logInfo) [i|Deleting existing installation|]
liftE $ rmGHCVer tver liftE $ rmGHCVer tver
forM_ mBindist $ \bindist -> do
liftE $ installPackedGHC bindist liftE $ installPackedGHC bindist
(Just $ RegexDir "ghc-.*") (Just $ RegexDir "ghc-.*")
ghcdir ghcdir
@ -1670,11 +1672,12 @@ HADDOCK_DOCS = YES|]
=> Either FilePath FilePath => Either FilePath FilePath
-> GHCTargetVersion -> GHCTargetVersion
-> FilePath -> FilePath
-> FilePath
-> Excepts -> Excepts
'[FileDoesNotExistError, InvalidBuildConfig, PatchFailed, ProcessError, NotFoundInPATH, CopyError] '[FileDoesNotExistError, InvalidBuildConfig, PatchFailed, ProcessError, NotFoundInPATH, CopyError]
m m
FilePath -- ^ output path of bindist (Maybe FilePath) -- ^ output path of bindist, None for cross
compileBindist bghc tver workdir = do compileBindist bghc tver workdir ghcdir = do
lift $ $(logInfo) [i|configuring build|] lift $ $(logInfo) [i|configuring build|]
liftE checkBuildConfig liftE checkBuildConfig
@ -1695,6 +1698,7 @@ HADDOCK_DOCS = YES|]
("./configure" : maybe mempty ("./configure" : maybe mempty
(\x -> ["--target=" <> T.unpack x]) (\x -> ["--target=" <> T.unpack x])
(_tvTarget tver) (_tvTarget tver)
++ ["--prefix=" <> ghcdir]
#if defined(IS_WINDOWS) #if defined(IS_WINDOWS)
++ ["--enable-tarballs-autodownload"] ++ ["--enable-tarballs-autodownload"]
#endif #endif
@ -1711,6 +1715,7 @@ HADDOCK_DOCS = YES|]
++ maybe mempty ++ maybe mempty
(\x -> ["--target=" <> T.unpack x]) (\x -> ["--target=" <> T.unpack x])
(_tvTarget tver) (_tvTarget tver)
++ ["--prefix=" <> ghcdir]
#if defined(IS_WINDOWS) #if defined(IS_WINDOWS)
++ ["--enable-tarballs-autodownload"] ++ ["--enable-tarballs-autodownload"]
#endif #endif
@ -1731,6 +1736,11 @@ HADDOCK_DOCS = YES|]
lift $ $(logInfo) [i|Building (this may take a while)...|] lift $ $(logInfo) [i|Building (this may take a while)...|]
lEM $ make (maybe [] (\j -> ["-j" <> fS (show j)]) jobs) (Just workdir) lEM $ make (maybe [] (\j -> ["-j" <> fS (show j)]) jobs) (Just workdir)
if | isCross tver -> do
lift $ $(logInfo) [i|Installing cross toolchain...|]
lEM $ make ["install"] (Just workdir)
pure Nothing
| otherwise -> do
lift $ $(logInfo) [i|Creating bindist...|] lift $ $(logInfo) [i|Creating bindist...|]
lEM $ make ["binary-dist"] (Just workdir) lEM $ make ["binary-dist"] (Just workdir)
[tar] <- liftIO $ findFiles [tar] <- liftIO $ findFiles
@ -1754,7 +1764,7 @@ HADDOCK_DOCS = YES|]
handleIO (throwE . CopyError . show) $ liftIO $ copyFile (workdir </> tar) handleIO (throwE . CopyError . show) $ liftIO $ copyFile (workdir </> tar)
tarPath tarPath
lift $ $(logInfo) [i|Copied bindist to #{tarPath}|] lift $ $(logInfo) [i|Copied bindist to #{tarPath}|]
pure tarPath pure $ Just tarPath
build_mk workdir = workdir </> "mk" </> "build.mk" build_mk workdir = workdir </> "mk" </> "build.mk"
@ -1781,6 +1791,9 @@ HADDOCK_DOCS = YES|]
) )
_ -> pure () _ -> pure ()
isCross :: GHCTargetVersion -> Bool
isCross = isJust . _tvTarget