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
Include a prof subdirectory in dist-dir layout #5314
base: master
Are you sure you want to change the base?
Conversation
Switch between profiling and non-profiling builds is a fairly common usecase so supporting this without forcing a recompile is pretty useful.
@@ -434,7 +434,8 @@ elabDistDirParams shared elab = DistDirParams { | |||
ElabPackage _ -> Nothing, | |||
distParamCompilerId = compilerId (pkgConfigCompiler shared), | |||
distParamPlatform = pkgConfigPlatform shared, | |||
distParamOptimization = elabOptimization elab | |||
distParamOptimization = elabOptimization elab, | |||
distParamProfiling = elabProfLib elab || elabProfExe elab |
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 am not sure if this is the proper way to check this. If anyone has a better suggestion, I’m all ears.
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.
Ok, here's the tricky thing...
If we are dealing with standard packages where we can split them up and handle the components individually (ie elabPkgOrComp elab
is a ElabComponent _
) then I think this approach should work ok, since each component is either being built with profiling or without, but not a mixture.
On the other hand if we're dealing with a multi-component package that we have to handle as a monolit (ie elabPkgOrComp elab
is a ElabPackage _
) then I think we have a problem because different components within that package can be built for profiling or not. For example we can enable both the profiling and non-profiling flavours of libs, and just non-profiling of an exe in the same package. It's worth remembering that the --enable-library-profiling
and flag adds additional artefacts, it doesn't switch the flavour of a single set of artefacts.
Can we have this? I am profiling a lot lately and I am tripping this quite often. @23Skidoo |
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'm not yet sure I see how this works.
A package or indeed a component is not a thing that is built one of the ways: vanilla | dynamic | profiling. Rather it can be built and/all of those ways, and all the artefacts will be built.
As you allude to, the "proper" way to do this will be to duplicate the components in the component graph and enable a single flavour in each one, giving each one their own local build dir or store id.
In the meantime, short of doing that, you're proposing this scheme, but it's not immediately clear how it behaves given the "any/all flavour" behaviour. Perhaps you can elaborate.
@@ -434,7 +434,8 @@ elabDistDirParams shared elab = DistDirParams { | |||
ElabPackage _ -> Nothing, | |||
distParamCompilerId = compilerId (pkgConfigCompiler shared), | |||
distParamPlatform = pkgConfigPlatform shared, | |||
distParamOptimization = elabOptimization elab | |||
distParamOptimization = elabOptimization elab, | |||
distParamProfiling = elabProfLib elab || elabProfExe elab |
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.
Ok, here's the tricky thing...
If we are dealing with standard packages where we can split them up and handle the components individually (ie elabPkgOrComp elab
is a ElabComponent _
) then I think this approach should work ok, since each component is either being built with profiling or without, but not a mixture.
On the other hand if we're dealing with a multi-component package that we have to handle as a monolit (ie elabPkgOrComp elab
is a ElabPackage _
) then I think we have a problem because different components within that package can be built for profiling or not. For example we can enable both the profiling and non-profiling flavours of libs, and just non-profiling of an exe in the same package. It's worth remembering that the --enable-library-profiling
and flag adds additional artefacts, it doesn't switch the flavour of a single set of artefacts.
At @dcoutts 's request I just gave this a spin on a rather large project, with quite a large number of local packages, a ton of constraints to pin it to a particular Stackage version (basically, I manually translated a
So it seems something somewhere is getting confused. |
I don’t know when I will have time to work on this again so if someone else wants to pick this up, be my guest. @edsko Do you have some public testcase for this? I just tried it again and it seems to work fine for me @dcoutts So I’m not too familiar with the cabal internals so I’m just documenting how I think this should work, feel free to correct me: So currently all artifacts end up in the same directory. This forces a rebuild when switching between non-profiling and profiling builds. This patch adds a new subdirectory to the already existing subdirectories (e.g. the |
I do have a public test case for you, but until now it was a bit awkward to reproduce. However, I've now written a (first, very preliminary) version of https://github.com/edsko/stack2cabal , which is making this a lot easier. These are the steps to that should reproduce the above problem:
However, as I was experimenting with this, I think I happened to come across an unrelated bug in the
It doesn't throw this same error for any other package, strangely. I could only complete the build if I run Even after that, when I run step (7), it starts building a ton of additional stuff and then fails somewhere else again... this time with
It seems there are still some issues with this branch. But maybe this will at least provide a larger example to play with. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'm going to try this again in 2.4.0.1 |
ok, my build broke. I got a tonne of errors that looked like this
when I swapped from Now that I'm back on regular 2.4.0.1, and doing a |
now that the cache corruption problems seem to have magically disappeared, is anybody interested in resurrecting this? 😄 |
Switch between profiling and non-profiling builds is a fairly common
usecase so supporting this without forcing a recompile is pretty
useful.
Please include the following checklist in your PR:
[ci skip]
is used to avoid triggering the build bots.I tested this both on a very simple project as well as a large project with a lot of vendored deps, where this makes a huge difference.
@hvr mentioned that eventually it might be nice to split prof/non-prof into separate units but that this is a useful low-hanging fruit in the meantime.