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

Use more deterministic distdir path in haskell_cabal_* #1648

Merged
merged 1 commit into from
Dec 10, 2021

Conversation

aherrmann
Copy link
Member

@aherrmann aherrmann commented Dec 2, 2021

Addresses indeterministic interface generation as reported in #1600.

Use a path for distdir in the haskell_cabal_* rules that is based on the package name and deterministic unless there is a collision with an already existing file or directory.

The distdir path enters flags that are passed to GHC and thereby enters the 'flag hash' field of the generated interface files. If the distdir path is indeterministic, then the interface file will also be indeterministic.

With this PR a build of the hspec Cabal library and its dependencies has been found to be bit-reproducible by building it twice without caching and comparing the outputs.

Notably, there is still an issue with non-deterministic builds if a haskell_cabal_* target has a C library dependency that was built by Bazel. In that case the absolute path to the sandbox execroot, which can change between builds, enters the include and library search path flags. Cabal forces us to provide these paths as absolute paths, see haskell/cabal#1317 and haskell/cabal#694. Meaning, the generated interface files of haskell_cabal_library targets with Bazel built C library dependencies remain indeterministic.

Copy link
Member

@ylecornec ylecornec left a comment

Choose a reason for hiding this comment

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

It seems good to me 👍

Copy link
Contributor

@thufschmitt thufschmitt left a comment

Choose a reason for hiding this comment

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

The motivation for the change made me scream a bit, but the change itself looks good 👍

@aherrmann aherrmann added the merge-queue merge on green CI label Dec 6, 2021
@aherrmann
Copy link
Member Author

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Dec 7, 2021

refresh

✅ Pull request refreshed

Use a path for distdir in the `haskell_cabal_*` rules that is based on
the package name and deterministic unless there is a collision with an
already existing file or directory.

The distdir path enters flags that are passed to GHC and thereby enters
the 'flag hash' field of the generated interface files. If the distdir
path is indeterministic, then the interface file will also be
indeterministic.
@mergify mergify bot merged commit a4fedf6 into master Dec 10, 2021
@mergify mergify bot deleted the cabal-reproducible branch December 10, 2021 17:19
@mergify mergify bot removed the merge-queue merge on green CI label Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants