-
Notifications
You must be signed in to change notification settings - Fork 686
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
Refactor the core component building logic: gbuild vs buildOrReplLib #9602
Conversation
03688b1
to
0083fab
Compare
@mergify refresh |
✅ Pull request refreshed |
0ca44da
to
946a977
Compare
Thanks for the sneak peek "live preview" of this today @alt-romes. Should it be converted to draft or is it ready for review? It would be good to have people familiar with GHC development involved in the review. |
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.
TBH I am not sure of the value of BuildM, at least in the way it is used here. It looks like that, most of the times, the environment it carries is immediately extracted:
buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays = do
verbosity <- buildVerbosity
component <- buildComponent
clbi <- buildCLBI
lbi <- buildLBI
...
This is just off the top of my head. I need to have a close look.
newtype BuildM a = BuildM' (ReaderT PreBuildComponentInputs IO a) | ||
deriving (Functor, Applicative, Monad, MonadReader PreBuildComponentInputs, MonadIO) | ||
|
||
-- Ideally we'd use deriving via ReaderT PreBuildComponentInputs IO, but ghc 8.4 doesn't support 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.
Depending on how you read the policy, we might not need to support GHC 8.4 anymore. Last 8.4 is 8.4.4, which was released on 14/10/2018, more than 5 years ago.
74b5e60
to
0187e2f
Compare
231d3bd
to
3b6e66e
Compare
Leaving |
I have debugged with @alt-romes why there are CI failures on 7.6.3 and he is going to investigate how to fix this. |
e40e5d8
to
dd2b8df
Compare
Full CI is passing! I've furthermore tested the changes of the refactor against master by compiling head.hackage with both and diffing the GHC invocations: Nothing is different! This is ready to be merged, except for the ROMES:TODO: that we still must decide what to do with. |
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.
This looks really good now, thank you.
I think most of the ROMES:TODO
comments can be rephrased as general observations about the code, I think questions would be ok too.
I've furthermore tested the changes of the refactor against master by compiling head.hackage with both and diffing the GHC invocations: Nothing is different!
Fantastic. I know that the CLC uses https://github.com/Bodigrim/clc-stackage#how-to to assess changes. Maybe we should standarise a procedure to assess changes. If you have any notes to share about how you did the test, free free to share them here
-> Bool | ||
-- ^ Want dynamic? |
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.
Who is wanting dynamic linking (I assume)? Is it that some kind extra sources need to force dynamic linking? Actually it seem to only affect ghcOptFPic
, I am not sure. Can you explain in the comment the role of this.
Can we also use a more descriptive rather than a Bool?
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 this is about JS sources not requiring particularly to be built in the Dynamic way, even if the GHC is dynamic, because they behave differently from other object files like those from C. It may be as well because GHCJS could not even support dynamic-related flags such as -fPIC.
Really, this was the way it was done before: all extra sources except for GHCJS do "wantDyn = True", and JS sources (for the GHCJS compiler) "wantDyn = False". So I'm just preserving this behaviour.
I could investigate, but I think it would be better not mess around with GHCJS bits, especially because GHC's JS backend behaves somewhat differently to GHCJS and might result in a more uniform story here.
I will improve the comment.
b5add4e
to
aa7dee6
Compare
Thanks @andreabedini. I've addressed your review, and cleared the ROMES:TODOs comments for more general comments or todos. |
@andreabedini, regarding the testing strategy: I didn't do anything super high-tech. Here are a few steps: Have a GHC wrapper called
And another one called Then, I ran the cabal testuite with two different cabal versions, passing Then I cloned the head.hackage repository twice and built all packages in it with the two different cabals, each logging to a different file. And |
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.
Awesome work 👍
Looks good to me, given the robust testing strategy. It's impossible to review this patch as-is due to the large changes but I am happy to merge if it results in the same output for the tested packages. |
@mpickering thank you, that makes sense. I'll proceed with merging. If you think we should wait feel free to remove the merge label. |
4419418
to
35660e9
Compare
35660e9
to
acd31e5
Compare
1. Refactors the duplicated `buildExtraSources` function from `gbuild` and `buildOrReplLib` into a standalone monadic computation in the context of building a component. This refactor allows us to share the code for building an extra source amongst the two functions. 2. Creates a new module Distribution.Simple.GHC.Build.Modules which, in the same spirit as ...GHC.Build.ExtraModules, defines an action which builds all the Haskell modules of the component being built. This function clarifies and re-implements the logic of building Haskell modules in the different possible ways, while accounting for Template Haskell special "way requirements", which was previously duplicated in a non-obvious manner in gbuild and buildOrReplLib. The Note [Building Haskell modules accounting for TH] in that module explains the big picture, and the implementation is re-done in light of it. 3. Re-work the linker invocations, focusing on preserving existing behaviour before simplifying or fixing bugs any further. Fixes haskell#9389.
acd31e5
to
2decb0e
Compare
Refactors the duplicated
buildExtraSources
function fromgbuild
andbuildOrReplLib
into a standalone monadic computation in the context ofbuilding a component. This refactor allows
us to share the code for building an extra source amongst the two
functions.
Creates a new module Distribution.Simple.GHC.Build.Modules which, in the
same spirit as ...GHC.Build.ExtraModules, defines an action which builds
all the Haskell modules of the component being built.
This function clarifies and re-implements the logic of building Haskell
modules in the different possible ways, while accounting for
Template Haskell special "way requirements", which was previously
duplicated in a non-obvious manner in gbuild and buildOrReplLib.
The Note [Building Haskell modules accounting for TH] in that module
explains the big picture, and the implementation is re-done in light of
it.
Re-work the linker invocations, focusing on preserving existing
behaviour before simplifying or fixing bugs any further.
Template Β: This PR does not modify
cabal
behaviour (documentation, tests, refactoring, etc.)Include the following checklist in your PR: