-
Notifications
You must be signed in to change notification settings - Fork 37
Use Cabal directly in place of ghc-cabal + make build root configurable #531
Conversation
src/Base.hs
Outdated
hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, | ||
generatedDir, generatedPath, | ||
stageBinPath, stageLibPath, | ||
templateHscPath, ghcDeps, |
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.
nit: indentation
I found some remaining bits by grepping
|
src/UserSettings.hs
Outdated
@@ -18,7 +16,7 @@ import {-# SOURCE #-} Settings.Default | |||
|
|||
-- | All build results are put into the 'buildRoot' directory. | |||
userBuildRoot :: BuildRoot | |||
userBuildRoot = BuildRoot "_build" | |||
userBuildRoot = error "build root not set" -- BuildRoot "_build" |
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 it is better to use the default value here, since we should pass in --build-root
explicitly if we want to change it.
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.
Oh yes, that's just a leftover from some debugging I did. Nice catch :-)
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.
Looks like CI bots are broken by this error
.
I hope this PR will actually fix the recent series of breakages due to ghc-cabal
, so ideally we should be getting green light from CI :)
it told me |
It tweaks the toplevel rules and surely changes the default behaviour, you can try "stage2" as a target if you want. We'll probably want to change this a little. |
src/CommandLine.hs
Outdated
@@ -36,6 +38,7 @@ defaultCommandLineArgs = CommandLineArgs | |||
, progressColour = Auto | |||
, progressInfo = Brief | |||
, splitObjects = False | |||
, buildRoot = UserSettings.userBuildRoot |
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.
BTW, I think you can just move the _build
from UserSettings
to here.
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.
Indeed, one less hoop to go through to figure out the default value. I'll make that change in an upcoming commit.
Thanks. You can try updating the |
Oh yes, I definitely plan to augment the README with a section about |
src/Builder.hs
Outdated
@@ -139,8 +139,8 @@ builderProvenance = \case | |||
GhcCabal _ _ -> context Stage1 ghcCabal | |||
GhcPkg _ Stage0 -> Nothing | |||
GhcPkg _ _ -> context Stage0 ghcPkg | |||
Haddock _ -> context Stage2 haddock | |||
Hpc -> context Stage1 hpcBin | |||
Haddock _ -> context Stage1 haddock |
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.
Did we change the semantics of StageN
in your PR?
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 shouldn't be changing the semantics of stages in this PR. I remember @angerman had some arguments for doing this and there were also some arguments against. We should do this separately and after a discussion in a separate issue, since it's not a trivial decision.
src/Settings/Builders/Haddock.hs
Outdated
[ arg "--verbosity=0" | ||
[ arg $ "-B" ++ root -/- "stage1" -/- "lib" | ||
, arg $ "--lib=" ++ root -/- "lib" | ||
, arg "--verbosity=0" |
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.
nit: add new arg
below it for a smaller diff
a weird directory appeared in
|
Regarding the
|
src/GHC/Packages.hs
Outdated
unix = hsLib "unix" | ||
win32 = hsLib "Win32" | ||
xhtml = hsLib "xhtml" | ||
-- libiserv = hsLib "libiserv" |
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.
is dynamic linking broken? add TODO for such case will help future investigation
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.
@izgzhen, what makes you believe dynamic linking is broken? The libiserv
comment? libiserv
doesn’t exist right now as it requires a diff in ghc to land first.
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.
Oh, I see ... thanks!
instance Hashable ConfiguredCabal where | ||
hashWithSalt salt = hashWithSalt salt . show | ||
|
||
instance NFData ConfiguredCabal where |
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.
Could we derive
that with Generic
?
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.
Done in latest commit.
Does the |
This commit implements two significant changes (that were not easy to separate): - Don't use ghc-cabal anymore for getting information about Haskell packages. We now instead directly use Cabal-the-library. - Make the build root configurable. This effectively gets rid of the inplace logic and allows us to place _all_ build artefacts in some directory of our choice, by passing '--build-root <some path>' to hadrian. The code for this was mostly taken from snowleopard#445.
@alpmestan Unfortunately there is no way to check since Hadrian is currently broken. However, it used to work just fine on my machine around a month ago. |
src/Hadrian/Haskell/Cabal/Type.hs
Outdated
|
||
instance Hashable Cabal where | ||
hashWithSalt salt = hashWithSalt salt . show | ||
|
||
instance NFData Cabal where | ||
rnf (Cabal a b c d) = a `seq` b `seq` c `seq` d `seq` () | ||
rnf (Cabal a b c d e f) = a `seq` b `seq` c `seq` d `seq` e `seq` f `seq` () |
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.
use derivation here as well?
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.
Turns out we can derive NFData
but not Hashable
because GenericPackageDescription
does not have a Hashable
instance. Will be done in an upcoming commit.
src/Rules.hs
Outdated
, ghcPkg, hp2ps, hpc, hsc2hs, runGhc ] | ||
-- programsStage1Only :: [Package] | ||
-- programsStage1Only = [ deriveConstants, genapply, genprimopcode, ghc, ghcCabal | ||
-- , ghcPkg, hp2ps, hpc, hsc2hs, runGhc ] |
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.
delete if useless?
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.
done
@alpmestan update on
|
@izgzhen nuke |
I deleted the |
We could also probably just Maybe not even trying to register the package in the bootstrap db, if it's present might be the cleaner choice. |
Regarding stagesIn general there are only two sets of file we generate: we either compile them by the bootstrap compiler, or we compile them with the stage1 compiler. For proper stage separation, we'd want to keep the artifacts build with the same compile in the same stage. Stage 0 (bootstrap)This stage contains packages and utilities built by the bootstrap compiler, that are necessary to build the final compiler. We rely on packages that are shipped with the bootstrap compiler where we do not build those packages. That is: bootpackages + packages form the bootstrap compiler make up the package set that is used to build the next stage compiler. No where do we place those? The are built artifacts of the bootstrap compiler and end up in stage0/bin and stage0/lib. For packages that are not in the bootpackages, we clone (copy & register) the packages from the bootstrap compiler. Stage 1 (the final stage)This stage contains packages and utilities built by the compiler from the previous stage. Now we could just bump the stage by I also trust @alpmestan to have tried to minimize the diff and extract only the necessary bits from #445, I also believe this has already taken a lot more time than initially anticipated. |
d4b1b1d
to
e23a3d9
Compare
By the way, Simon (Marlow) just released a new version of |
@snowleopard I've opened #538 for the rule replacement. |
OK, I think we are mostly done with this PR. There are a few things that I'd like to look at after merging:
@angerman There is one question that I think I haven't got an answer from you yet:
Could you clarify? @alpmestan Do you still have any unfinished work on this PR? Anything I missed that needs further discussion? |
I created an issue about reviving wrapper/install rules under a "modernised" form (in light of this PR, that is) at #539.
I still need to update the README as well as the user settings document. And address a couple of small things here and there. But nothing huge. Unless I'm missing something? Github's UI has certainly not made it easy for us to track what got addressed or not as I was pushing new commits. Please do let me know if you spot anything. |
Updated |
Look at this beautiful travis CI page: https://travis-ci.org/snowleopard/hadrian/builds/360321326 🎉 |
Alright, I pushed another patch that addresses some minor things. I also tried to get rid of @snowleopard Anything else that you see that I should take care of? |
@alpmestan Thanks! I've added the I think I can merge this now. There are some unanswered questions, but discussing them here seems to be counterproductive. I suggest to merge and move on to discussing the leftovers in separate issues. @alpmestan Waiting for a Good-To-Go signal from you :) |
|
Done! @alpmestan @angerman Thank you both for this amazing PR! |
This commit implements two significant changes (that were not easy to
separate):
Don't use ghc-cabal anymore for getting information about Haskell packages.
We now instead directly use Cabal-the-library.
Make the build root configurable. This effectively gets rid of the inplace
logic and allows us to place all build artefacts in some directory of
our choice, by passing '--build-root ' to hadrian. The GHCs we
produce are now relocatable.
The code for this was mostly taken from #445. I have successfully built functional quick/prof/perf/devel2/quick-cross builds of GHC with this branch. I might commit
another tweak or two as I'm now testing the test/docs rules. But I'm not expecting
major changes there.
I'm also not clear on what we want to do with the install/wrapper rules, with
relocatable GHC builds.