@@ -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          --  bootstrapped ghc renames boot to boot.source
@@ -883,6 +883,9 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
883883
884884          liftE $  applyAnyPatch patches (fromGHCupPath workdir)
885885
886+           --  bootstrap, if necessary
887+           liftE $  bootAndGenVersion workdir
888+ 
886889          tver <-  liftE $  catchAllE @ _  @ '[ProcessError , ParseError , NotFoundInPATH ] @ '[]  (\ _ ->  pure  Nothing ) $  fmap  Just  $  getGHCVer workdir
887890          pure  (workdir, tver)
888891
@@ -937,6 +940,8 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
937940          liftE $  applyAnyPatch patches (fromGHCupPath tmpUnpack)
938941
939942          --  bootstrap
943+           liftE $  bootAndGenVersion tmpUnpack
944+ 
940945          tver <-  liftE $  catchAllE @ _  @ '[ProcessError , ParseError , NotFoundInPATH ] @ '[]  (\ _ ->  pure  Nothing ) $  fmap  Just  $  getGHCVer
941946            tmpUnpack
942947          liftE $  catchWarn $  lEM @ _  @ '[ProcessError ] $  darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
@@ -1038,6 +1043,24 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
10381043    pure  installVer
10391044
10401045 where 
1046+   bootAndGenVersion  ::  ( MonadReader  env  m 
1047+                       , HasSettings  env 
1048+                       , HasDirs  env 
1049+                       , HasLog  env 
1050+                       , MonadIO  m 
1051+                       , MonadThrow  m 
1052+                       )
1053+                    =>  GHCupPath 
1054+                    ->  Excepts  '[ProcessError , NotFoundInPATH ] m  () 
1055+   bootAndGenVersion tmpUnpack =  do 
1056+     let  bootFile =  fromGHCupPath tmpUnpack </>  " boot" 
1057+     hasBootFile <-  liftIO $  doesFileExist bootFile
1058+     when hasBootFile $  do 
1059+       lift $  logDebug " Doing ghc-bootstrap" 
1060+       lEM $  execLogged " python3" " ./boot" Just  $  fromGHCupPath tmpUnpack) " ghc-bootstrap" Nothing 
1061+       --  This configure is to generate VERSION file
1062+       liftE $  configureWithGhcBoot Nothing  []  (Just  $  fromGHCupPath tmpUnpack) " ghc-bootstrap" 
1063+ 
10411064  getGHCVer  ::  ( MonadReader  env  m 
10421065               , HasSettings  env 
10431066               , HasDirs  env 
@@ -1048,8 +1071,6 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
10481071            =>  GHCupPath 
10491072            ->  Excepts  '[ProcessError , ParseError , NotFoundInPATH ] m  Version 
10501073  getGHCVer tmpUnpack =  do 
1051-     lEM $  execLogged " python3" " ./boot" Just  $  fromGHCupPath tmpUnpack) " ghc-bootstrap" Nothing 
1052-     liftE $  configureWithGhcBoot Nothing  []  (Just  $  fromGHCupPath tmpUnpack) " ghc-bootstrap" 
10531074    let  versionFile =  fromGHCupPath tmpUnpack </>  " VERSION" 
10541075    hasVersionFile <-  liftIO $  doesFileExist versionFile
10551076    if  hasVersionFile
0 commit comments