Skip to content
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

Plans that use bootstrapping to break cycles #7189

Open
Ericson2314 opened this issue Dec 5, 2020 · 7 comments
Open

Plans that use bootstrapping to break cycles #7189

Ericson2314 opened this issue Dec 5, 2020 · 7 comments

Comments

@Ericson2314
Copy link
Collaborator

Ericson2314 commented Dec 5, 2020

In haskell/happy#175 (no merged) I have

executable happy
  ...
  if flag(bootstrap)
    ...
    -- build-tools: happy
  else
    ...

I would like to uncomment build-tools: happy to indicate that when bootstrapping, Happy does in fact depend on Happy, but then Cabal will complain of the cycle.

There's a lot of nuance on exactly how to make this goal, but I figured I'd start with the problem first, now that I finally have a small example of it.

@gbaz
Copy link
Collaborator

gbaz commented Oct 21, 2021

Build-tools is deprecated in version 2 format files and removed in version 3 format cabal files. That's not going to be the right approach: https://cabal.readthedocs.io/en/3.6/cabal-package.html?highlight=build-tools#pkg-field-build-tools

@Ericson2314
Copy link
Collaborator Author

@gbaz same issues happens with build-tool-depends. Glad build-tools is going away, though!

@Ericson2314
Copy link
Collaborator Author

I tried with https://github.com/simonmar/happy/pull/212/files using a different name to avoid this and #3502, but then I hit there there is no way to say "use happy-boot for .ly files". It's rather alpha-equivalence-violating, but the dep will only work if it's named happy.

@Mikolaj
Copy link
Member

Mikolaj commented Oct 21, 2021

From the little I understand about this, #6459 is related, but it's a serious undertaking.

@Ericson2314
Copy link
Collaborator Author

@Mikolaj Yes, that required for this to work, thanks for pointing out.

@gbaz
Copy link
Collaborator

gbaz commented Oct 22, 2021

With build-tools-depends it gets introduced as a qualified goal. I think there are two things to do -- one is enable the same package version with different configs under different subgoals. The second is just to enable backtracking instead of hard failure on cycle detection (unless that may already occur!). Its an interesting problem and worthwhile to solve for the next release, if possible.

@grayjay
Copy link
Collaborator

grayjay commented Oct 29, 2021

The dependency solver should already be able to backtrack in response to a cycle. The findCycles function creates a conflict set from the packages in one of the cycles that is found, which is used for backtracking. However, there is a TODO for adding flag and stanza variables:

-- | Given the reverse dependency map from a node in the tree, check
-- if the solution is cyclic. If it is, return the conflict set containing
-- all decisions that could potentially break the cycle.
--
-- TODO: The conflict set should also contain flag and stanza variables.
findCycles :: QPN -> RevDepMap -> Maybe ConflictSet

I think we would need to fix the TODO and implement #6459 to allow the solver to break the cycle by building the same version of happy with different flags.

@Ericson2314 do you have the solver log (-v3) from trying to add a build-tool-depends dependency on happy so that I can check whether this is the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants