-
Notifications
You must be signed in to change notification settings - Fork 0
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
Build GHC with cabal-install and a Makefile #3
base: master
Are you sure you want to change the base?
Conversation
Current status: it builds some ghc program in |
Ah, I need to pass some environment variable to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @hsyl20 this looks like a great start!
Makefile
Outdated
@@ -0,0 +1,67 @@ | |||
HADRIAN_SETTINGS_STAGE0 := $(shell ghc --info | runghc GenSettings.hs ghc-boot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this called HADRIAN_SETTINGS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how the environment variable is called in ghc-boot
's Setup.hs
¯_(ツ)_/¯
Makefile
Outdated
## Substituting variables | ||
cp _build/stage0/src/ghc-bin/ghc-bin.cabal{.in,} | ||
cp _build/stage0/src/libraries/ghc/ghc.cabal{.in,} | ||
cp _build/stage0/src/libraries/ghc/GHC/CmmToLlvm/Version/Bounds.hs{.in,} | ||
cp _build/stage0/src/libraries/ghc-boot/ghc-boot.cabal{.in,} | ||
cp _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal{.in,} | ||
cp _build/stage0/src/libraries/ghc-heap/ghc-heap.cabal{.in,} | ||
cp _build/stage0/src/libraries/ghci/ghci.cabal{.in,} | ||
cp _build/stage0/src/utils/ghc-pkg/ghc-pkg.cabal{.in,} | ||
|
||
sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/ghc-bin/ghc-bin.cabal | ||
sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/ghc-bin/ghc-bin.cabal | ||
sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghc/ghc.cabal | ||
sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghc/ghc.cabal | ||
sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghc-boot/ghc-boot.cabal | ||
sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghc-boot/ghc-boot.cabal | ||
sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal | ||
sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal | ||
sed -i 's/@Suffix@//' _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal | ||
sed -i 's/@SourceRoot@/./' _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal | ||
sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghc-heap/ghc-heap.cabal | ||
sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghc-heap/ghc-heap.cabal | ||
sed -i 's/@ProjectVersionForLib@/9.13/' _build/stage0/src/libraries/ghc-heap/ghc-heap.cabal | ||
sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghci/ghci.cabal | ||
sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghci/ghci.cabal | ||
sed -i 's/@ProjectVersionForLib@/9.13/' _build/stage0/src/libraries/ghci/ghci.cabal | ||
sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/utils/ghc-pkg/ghc-pkg.cabal | ||
sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/utils/ghc-pkg/ghc-pkg.cabal | ||
sed -i 's/@ProjectVersionForLib@/9.13/' _build/stage0/src/utils/ghc-pkg/ghc-pkg.cabal | ||
|
||
sed -i 's/@LlvmMinVersion@/13/' _build/stage0/src/libraries/ghc/GHC/CmmToLlvm/Version/Bounds.hs | ||
sed -i 's/@LlvmMaxVersion@/20/' _build/stage0/src/libraries/ghc/GHC/CmmToLlvm/Version/Bounds.hs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just use a configure script for this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could. But we moved away from it upstream.
cabal.project-stage0
Outdated
./_build/stage0/src/ghc-bin/ | ||
./_build/stage0/src/libraries/ghc | ||
./_build/stage0/src/libraries/directory/ | ||
./_build/stage0/src/libraries/file-io/ | ||
./_build/stage0/src/libraries/filepath/ | ||
./_build/stage0/src/libraries/ghc-platform/ | ||
./_build/stage0/src/libraries/ghc-boot/ | ||
./_build/stage0/src/libraries/ghc-boot-th/ | ||
./_build/stage0/src/libraries/ghc-heap | ||
./_build/stage0/src/libraries/ghci | ||
./_build/stage0/src/libraries/os-string/ | ||
./_build/stage0/src/libraries/process/ | ||
./_build/stage0/src/libraries/semaphore-compat | ||
./_build/stage0/src/libraries/time | ||
./_build/stage0/src/libraries/unix/ | ||
./_build/stage0/src/libraries/Win32/ | ||
./_build/stage0/src/utils/ghc-pkg | ||
./_build/stage0/src/utils/hsc2hs | ||
./_build/stage0/src/utils/unlit | ||
./_build/stage0/src/utils/genprimopcode/ | ||
./_build/stage0/src/utils/deriveConstants/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we put them in build/stage0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to modify the source tree directly, this way it's easier to nuke the _build
directory and restart from a clean state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to copy all source files across. It is also annoying to do it propely with Make.
cabal will use a separate build directory anyway, only some generated cabal files will end up in the source tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to perform some substitution/file generations more than once (for the different stages). I still think it's cleaner to avoid dirtying the source directory. I don't want to have to fix bugs because we've done something for stage0 and forgot to do it again differently for stage1.
Now it seems like cabal doesn't like empty package databases:
Edit: that was my mistake (a debug statement in ghc-pkg...). Now it works. |
Effectively we want to completely disable the solver. We can add |
I've disabled it for stage1 where we start fresh to build boot libraries. |
4f9641d
to
563f2cf
Compare
09d2c38
to
1df74eb
Compare
We need Haskell anyway for GenSettings and Makefile syntax isn't high-level enough to write quality code.
Note that we need a patched cabal: https://github.com/hsyl20/cabal/tree/hsyl20/per-file-extra-source-options