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,10 +1630,12 @@ 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
liftE $ installPackedGHC bindist
(Just $ RegexDir "ghc-.*") forM_ mBindist $ \bindist -> do
ghcdir liftE $ installPackedGHC bindist
(tver ^. tvVersion) (Just $ RegexDir "ghc-.*")
ghcdir
(tver ^. tvVersion)
liftIO $ B.writeFile (ghcdir </> ghcUpSrcBuiltFile) bmk liftIO $ B.writeFile (ghcdir </> ghcUpSrcBuiltFile) bmk
@ -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,8 +1715,9 @@ 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
++ fmap T.unpack aargs ++ fmap T.unpack aargs
) )
@ -1731,30 +1736,35 @@ 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)
lift $ $(logInfo) [i|Creating bindist...|] if | isCross tver -> do
lEM $ make ["binary-dist"] (Just workdir) lift $ $(logInfo) [i|Installing cross toolchain...|]
[tar] <- liftIO $ findFiles lEM $ make ["install"] (Just workdir)
workdir pure Nothing
(makeRegexOpts compExtended | otherwise -> do
execBlank lift $ $(logInfo) [i|Creating bindist...|]
([s|^ghc-.*\.tar\..*$|] :: ByteString) lEM $ make ["binary-dist"] (Just workdir)
) [tar] <- liftIO $ findFiles
c <- liftIO $ BL.readFile (workdir </> tar) workdir
cDigest <- (makeRegexOpts compExtended
fmap (T.take 8) execBlank
. lift ([s|^ghc-.*\.tar\..*$|] :: ByteString)
. throwEither )
. E.decodeUtf8' c <- liftIO $ BL.readFile (workdir </> tar)
. B16.encode cDigest <-
. SHA256.hashlazy fmap (T.take 8)
$ c . lift
cTime <- liftIO getCurrentTime . throwEither
let tarName = makeValid [i|ghc-#{tVerToText tver}-#{pfReqToString pfreq}-#{iso8601Show cTime}-#{cDigest}.tar#{takeExtension tar}|] . E.decodeUtf8'
let tarPath = cacheDir </> tarName . B16.encode
handleIO (throwE . CopyError . show) $ liftIO $ copyFile (workdir </> tar) . SHA256.hashlazy
tarPath $ c
lift $ $(logInfo) [i|Copied bindist to #{tarPath}|] cTime <- liftIO getCurrentTime
pure tarPath let tarName = makeValid [i|ghc-#{tVerToText tver}-#{pfReqToString pfreq}-#{iso8601Show cTime}-#{cDigest}.tar#{takeExtension tar}|]
let tarPath = cacheDir </> tarName
handleIO (throwE . CopyError . show) $ liftIO $ copyFile (workdir </> tar)
tarPath
lift $ $(logInfo) [i|Copied bindist to #{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