Open pranaysashank opened 3 years ago
Looks related to #7189
I saw that issue but don't think it's related.
I did some digging around in the code base and it looks like the issue is in constraintScopeMatches
function, it gets a top level scope which is set in resolverParams
function. Because of this constraintScopeMatches
function returns False
and the solver doesn't fail here in processPackageConstraintF
and it doesn't reject the constraint with default flag +bootstrap
.
I haven't seen the solver code before, so I could be wrong. But with that fixed I could get the package to build.
Another reason I don't think it's related is because I can get it to build if I download it and add it to the packages list in cabal.project.
See https://github.com/pranaysashank/cabal/commit/73669e41c79f693d15bb744a49f1f04c87a60642 which works for me.
@grayjay looks like you have last touched this part of the code. Perhaps you can help?
I think that the problem is that there currently isn't a way to specify whether a package section in cabal.project applies to all uses of the package (including use as a build tool) or only the top-level use. I think there is an issue for this, but I wasn't able to find it just now.
I was able to make the reproduction progress by using the more expressive constraint field to specify that all uses of happy should be built with -bootstrap, by adding "constraints: any.happy -bootstrap" to the top of cabal.project.
Another related issue is #3502, which would add constraint syntax for more of the constraint scope functionality that is already implemented in the solver. For example, it would allow constraining the bootstrap flag of happy only when it is used as a build tool for chc.
@grayjay Thanks for the breakdown. The package also builds successfully with the flag if I unpack the happy package and add it to the packages section of the project file. Is this difference from when you're downloading from Hackage part of the same issue? I am assuming it works because the flag is applied to the package because its a target.
The package also builds successfully with the flag if I unpack the happy package and add it to the packages section of the project file.
Then it is also a local i.e. "top-level" package. i.e. package ... flags
applies to it.
You could also write.. which I imagine will satisfy this use case.
constraints:
any.happy -bootstrap
Describe the bug The solver doesn't seem to take into account constraints placed on packages in build-tool-depends.
To Reproduce With the following cabal file & the cabal.project file: --- chc.cabal
Expected behavior Expect the build to succeed with
happy
package built with-bootstrap
flag.System information
cabal
: 3.6.0.0, masterghc
: ghc-9.2.1