Skip to content

Commit

Permalink
Move boot and configure out from getGHCVer; check python3 exists befo…
Browse files Browse the repository at this point in the history
…re boot

This removes the catchAllE from the bootstrap step, such that error in
bootstrap is not silently ignored
  • Loading branch information
dfordivam committed Dec 9, 2024
1 parent bcc3e98 commit 25d0798
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions lib/GHCup/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
tmpDownload <- lift withGHCupTmpDir
tmpUnpack <- lift mkGhcupTmpDir
tar <- liftE $ download uri Nothing Nothing Nothing (fromGHCupPath tmpDownload) Nothing False
(workdir, tver) <- liftE $ cleanUpOnError @'[UnknownArchive, ArchiveResult, ProcessError, PatchFailed, DownloadFailed, DigestError, ContentLengthError, GPGError] tmpUnpack $ do
(workdir, tver) <- liftE $ cleanUpOnError @'[UnknownArchive, ArchiveResult, ProcessError, PatchFailed, DownloadFailed, DigestError, ContentLengthError, GPGError, NotFoundInPATH] tmpUnpack $ do
liftE $ unpackToDir (fromGHCupPath tmpUnpack) tar

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

liftE $ applyAnyPatch patches (fromGHCupPath workdir)

-- bootstrap, if necessary
liftE $ bootAndConfigure workdir

tver <- liftE $ catchAllE @_ @'[ProcessError, ParseError, NotFoundInPATH] @'[] (\_ -> pure Nothing) $ fmap Just $ getGHCVer workdir
pure (workdir, tver)

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

-- bootstrap
liftE $ bootAndConfigure tmpUnpack

tver <- liftE $ catchAllE @_ @'[ProcessError, ParseError, NotFoundInPATH] @'[] (\_ -> pure Nothing) $ fmap Just $ getGHCVer
tmpUnpack
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
Expand Down Expand Up @@ -1037,6 +1042,24 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
pure installVer

where
bootAndConfigure :: ( MonadReader env m
, HasSettings env
, HasDirs env
, HasLog env
, MonadIO m
, MonadThrow m
)
=> GHCupPath
-> Excepts '[ProcessError, NotFoundInPATH] m ()
bootAndConfigure tmpUnpack = do
let bootFile = fromGHCupPath tmpUnpack </> "boot"
hasBootFile <- liftIO $ doesFileExist bootFile
when hasBootFile $ do
lift $ logDebug "Doing ghc-bootstrap"
python3 <- liftE $ makeAbsolute "python3"
lEM $ execLogged python3 ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" Nothing
liftE $ configureWithGhcBoot Nothing [] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"

getGHCVer :: ( MonadReader env m
, HasSettings env
, HasDirs env
Expand All @@ -1047,8 +1070,6 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
=> GHCupPath
-> Excepts '[ProcessError, ParseError, NotFoundInPATH] m Version
getGHCVer tmpUnpack = do
lEM $ execLogged "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" Nothing
liftE $ configureWithGhcBoot Nothing [] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
let versionFile = fromGHCupPath tmpUnpack </> "VERSION"
hasVersionFile <- liftIO $ doesFileExist versionFile
if hasVersionFile
Expand Down

0 comments on commit 25d0798

Please sign in to comment.