Skip to content

Commit 25d0798

Browse files
committed
Move boot and configure out from getGHCVer; check python3 exists before boot
This removes the catchAllE from the bootstrap step, such that error in bootstrap is not silently ignored
1 parent bcc3e98 commit 25d0798

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

lib/GHCup/GHC.hs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
868868
tmpDownload <- lift withGHCupTmpDir
869869
tmpUnpack <- lift mkGhcupTmpDir
870870
tar <- liftE $ download uri Nothing Nothing Nothing (fromGHCupPath tmpDownload) Nothing False
871-
(workdir, tver) <- liftE $ cleanUpOnError @'[UnknownArchive, ArchiveResult, ProcessError, PatchFailed, DownloadFailed, DigestError, ContentLengthError, GPGError] tmpUnpack $ do
871+
(workdir, tver) <- liftE $ cleanUpOnError @'[UnknownArchive, ArchiveResult, ProcessError, PatchFailed, DownloadFailed, DigestError, ContentLengthError, GPGError, NotFoundInPATH] tmpUnpack $ do
872872
liftE $ unpackToDir (fromGHCupPath tmpUnpack) tar
873873

874874
let regex = [s|^(.*/)*compiler/ghc.cabal.in$|] :: B.ByteString
@@ -882,6 +882,9 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
882882

883883
liftE $ applyAnyPatch patches (fromGHCupPath workdir)
884884

885+
-- bootstrap, if necessary
886+
liftE $ bootAndConfigure workdir
887+
885888
tver <- liftE $ catchAllE @_ @'[ProcessError, ParseError, NotFoundInPATH] @'[] (\_ -> pure Nothing) $ fmap Just $ getGHCVer workdir
886889
pure (workdir, tver)
887890

@@ -936,6 +939,8 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
936939
liftE $ applyAnyPatch patches (fromGHCupPath tmpUnpack)
937940

938941
-- bootstrap
942+
liftE $ bootAndConfigure tmpUnpack
943+
939944
tver <- liftE $ catchAllE @_ @'[ProcessError, ParseError, NotFoundInPATH] @'[] (\_ -> pure Nothing) $ fmap Just $ getGHCVer
940945
tmpUnpack
941946
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
@@ -1037,6 +1042,24 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
10371042
pure installVer
10381043

10391044
where
1045+
bootAndConfigure :: ( MonadReader env m
1046+
, HasSettings env
1047+
, HasDirs env
1048+
, HasLog env
1049+
, MonadIO m
1050+
, MonadThrow m
1051+
)
1052+
=> GHCupPath
1053+
-> Excepts '[ProcessError, NotFoundInPATH] m ()
1054+
bootAndConfigure tmpUnpack = do
1055+
let bootFile = fromGHCupPath tmpUnpack </> "boot"
1056+
hasBootFile <- liftIO $ doesFileExist bootFile
1057+
when hasBootFile $ do
1058+
lift $ logDebug "Doing ghc-bootstrap"
1059+
python3 <- liftE $ makeAbsolute "python3"
1060+
lEM $ execLogged python3 ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" Nothing
1061+
liftE $ configureWithGhcBoot Nothing [] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
1062+
10401063
getGHCVer :: ( MonadReader env m
10411064
, HasSettings env
10421065
, HasDirs env
@@ -1047,8 +1070,6 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
10471070
=> GHCupPath
10481071
-> Excepts '[ProcessError, ParseError, NotFoundInPATH] m Version
10491072
getGHCVer tmpUnpack = do
1050-
lEM $ execLogged "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" Nothing
1051-
liftE $ configureWithGhcBoot Nothing [] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
10521073
let versionFile = fromGHCupPath tmpUnpack </> "VERSION"
10531074
hasVersionFile <- liftIO $ doesFileExist versionFile
10541075
if hasVersionFile

0 commit comments

Comments
 (0)