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

Correctly provision build tools in all situations #9912

Merged
merged 3 commits into from
May 2, 2024

Conversation

sheaf
Copy link
Collaborator

@sheaf sheaf commented Apr 19, 2024

This PR ensures that we correctly provision executables declared in the build-tool-depends fields in all circumstances:

  • whether the build tool is external (from another package) or internal (declared in the current package)
  • whether the build tool is used at compile time (e.g. in a pre-build rule or in a Template Haskell splice),
    or at run time (e.g. when running a test-suite, benchmark or executable).

Note that correctly provisioning a build tool requires two pieces of information:

  • making it available in PATH,
  • ensuring it has the correct environment variables overrides;
    in particular, the build tool needs to be able to find its own data directory.

The test case BuildToolPaths checks all of these situations are handled correctly.

@sheaf sheaf marked this pull request as draft April 19, 2024 19:17
@sheaf sheaf force-pushed the wip/program-db-paths branch 4 times, most recently from eb044a1 to e2e4a3a Compare April 19, 2024 19:29
@Mikolaj Mikolaj added the re: build-tool Concerning `build-tools` and `build-tool-depends` label Apr 19, 2024
cabal-testsuite/main/cabal-tests.hs Outdated Show resolved Hide resolved
@alt-romes alt-romes force-pushed the wip/program-db-paths branch 3 times, most recently from a5becf7 to 947eea5 Compare April 22, 2024 19:25
@sheaf sheaf force-pushed the wip/program-db-paths branch 4 times, most recently from 26ddcb5 to 88e5941 Compare April 24, 2024 11:06
@sheaf sheaf marked this pull request as ready for review April 24, 2024 11:06
@sheaf
Copy link
Collaborator Author

sheaf commented Apr 24, 2024

This PR is now ready for review and should be passing CI. @jasagredo, might you be interested in taking a look?

Edit: CI failing for silly Windows reasons even though the test passes locally on my Windows machine. Investigating.
Edit 2: Seems like it was MAX_PATH related. I shortened some package and module names, hoping that we can squeeze through.

@sheaf sheaf requested a review from jasagredo April 24, 2024 11:07
@sheaf sheaf force-pushed the wip/program-db-paths branch from 88e5941 to 1e32da6 Compare April 24, 2024 11:10
@sheaf sheaf force-pushed the wip/program-db-paths branch from 1e32da6 to cebcca4 Compare April 24, 2024 15:23
@alt-romes
Copy link
Collaborator

This is quite a key improvement to Cabal's handling of build-tools (the tests serve as good examples of things that were previously not possible because of incorrect PATH handling for build-tools).
Looking forward to it being merged.

Copy link
Collaborator

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel comfortable approving because I do not have time to fully analyze the impact of this, or whether it is cohesive with the rest of the code.

A top-to-bottom read of the PR looks reasonable, steps look documented, and the tests pass and seem thorough, so I think it is fine.

@alt-romes
Copy link
Collaborator

Thanks @jasagredo.

Would anyone else like to review this PR? Perhaps @andreabedini or @gbaz ?

@Mikolaj
Copy link
Member

Mikolaj commented Apr 30, 2024

Let's not let it bitrot. Last chance for extra reviews.

@Mikolaj Mikolaj added the merge me Tell Mergify Bot to merge label Apr 30, 2024
@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label May 2, 2024
sheaf added 2 commits May 2, 2024 07:35
This commit ensures the test-suite driver also provides the Cabal-hooks
package, on top of Cabal and Cabal-syntax.
This patch ensures that we correctly provision executables declared
in the build-tool-depends fields in all circumstances:

  - whether the build tool is external (from another package) or
    internal (declared in the current package)
  - whether the build tool is used at compile time (e.g. in a pre-build
    rule or in a Template Haskell splice) or at run time (e.g. when
    running a test-suite, benchmark or executable).

Note that correctly provisioning a build tool requires two pieces of
information:

  - making it available in PATH,
  - ensuring it has the correct environment variables overrides;
    in particular, the build tool needs to be able to find its own
    data directory.

The test case BuildToolPaths checks all of these situations are handled
correctly.
@Mikolaj Mikolaj force-pushed the wip/program-db-paths branch from cebcca4 to ee11ac6 Compare May 2, 2024 07:35
@mergify mergify bot merged commit 8e150ad into haskell:master May 2, 2024
43 checks passed
@ulysses4ever
Copy link
Collaborator

This looks like a correctness fix, so, formally speaking, should be backported. But I fear that it can bring regressions. Should we shelve it till 3.14?

@Mikolaj
Copy link
Member

Mikolaj commented Jun 6, 2024

I think the risk/reward in this case is not in favour of backporting it: it fixes problems, but they don't seem particularly grave nor commonly occurring nor recent regressions. OTOH, this introduces significant changes that may result in expected interactions with other changes in the release, etc. And it didn't make it to the pre-release, so it wasn't tested enough in the wild. I'd vote for 3.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge re: build-tool Concerning `build-tools` and `build-tool-depends`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants