Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ignore ghc compile bootstrap error, fix --remote-source-dist #1172

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dfordivam
Copy link
Collaborator

@dfordivam dfordivam commented Dec 9, 2024

fixes #1163
Also included in this

  • support of --patch with --remote-source-dist
  • support compilation of bootstrapped src tar with --remote-source-dist
    This does not contain boot file, and currently it results in following
[ Info  ] Unpacking: ghc-9.8.4-src.tar.xz to /home/divam/.ghcup/tmp/ghcup-7fbd043d844b981c
ghcup: user error (Pattern match failure in 'do' block at lib/GHCup/GHC.hs:874:11-20)

lib/GHCup/GHC.hs Outdated
let regex = [s|^(.*/)*boot$|] :: B.ByteString
[bootFile] <- liftIO $ findFilesDeep

let regex = [s|^(.*/)*compiler/ghc.cabal.in$|] :: B.ByteString
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is to fix the workdir retrieval. The bootstrapped src does not contain boot file.

finding the directory name using ghc.cabal.in seems to be better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this file will always exist in that place. If there is no boot file, then we can assume there is a configure file. And the topmost such configure file is what we need. We should depend on the files we actually use.

From what I understand findFilesDeep is breadth first, so we can just take the first find (possibly using the conduit functions to cut off early).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted back to boot file, the file gets renamed now in hadrian when making release builds.

      -- And move ./boot so we can't accidentally call it in CI                                                           
      moveFile (dest -/- "boot") (dest -/- "boot.source")       

lib/GHCup/GHC.hs Outdated Show resolved Hide resolved
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this belong outside of getGHCVer. The reason we run configure here (without any meaningful arguments) is because it creates the VERSION file, which we then use. So this is not the "proper" configure. The only reason we do this is to get the GHC version.

See GHCs configure.ac:

dnl Create the VERSION file, satisfying #22322.
printf "$ProjectVersion" > VERSION

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, in that case it does belong here, as the bootstrapped ghc will contain the VERSION file.

@dfordivam dfordivam force-pushed the dn-ghc-comp-bootstrap-error branch from 25d0798 to 7757dd2 Compare December 15, 2024 09:08
bootAndGenVersion tmpUnpack = do
let bootFile = fromGHCupPath tmpUnpack </> "boot"
hasBootFile <- liftIO $ doesFileExist bootFile
when hasBootFile $ do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. As in: if we have booted, does it mean there is always a VERSION file? From what I understand one has to run configure too.

@bgamari @AndreasPK

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boot file is being renamed to boot.source when doing hadrian build source-dist, so this is a scenario different from simply bootstrapped ghc. And as part of this build source-dist the VERSION is always being copied.

ref: https://gitlab.haskell.org/ghc/ghc/-/blob/master/hadrian/src/Rules/SourceDist.hs#L123-143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad error mode when ghc bootstrap fails during compile
2 participants