Skip to content

Reproducible interface files for Cabal packages with C dependencies - #1689

Merged
mergify[bot] merged 2 commits into
masterfrom
cabal-reproducible
Feb 8, 2022
Merged

Reproducible interface files for Cabal packages with C dependencies#1689
mergify[bot] merged 2 commits into
masterfrom
cabal-reproducible

Conversation

@aherrmann

Copy link
Copy Markdown
Contributor

This is the continuation of #1648 addressing the case where a Cabal target has C dependencies.

Addresses the non-reproducible interface files aspect of #1600.

As described in haskell/cabal#1317 (comment) we can avoid passing absolute C header and library search paths to Cabal builds if we do not call Setup.hs install. Setup.hs install fails if the configuration contains relative paths. Instead, we call Setup.hs copy to copy the generated files and then generate a package configuration file with Setup.hs register --gen-pkg-config, patch it to replace relative paths by paths starting with ${pkgroot}, and then invoke ghc-pkg directly to cache the package-db.

This adds a test-case that be used to confirm that the build is now reproducible.

$ n=1; bazel clean; bazel build //tests/haskell_cabal_reproducibility/pkg-b --execution_log_json_file=execlog$n.json; rsync -aL bazel-bin output$n
$ n=2; bazel clean; bazel build //tests/haskell_cabal_reproducibility/pkg-b --execution_log_json_file=execlog$n.json; rsync -aL bazel-bin output$n
$ diff -u execlog1.json execlog2.json
$ diff -ur output1 output2
$ diff -u <(ghc --show-iface output1/bazel-bin/tests/haskell_cabal_reproducibility/pkg-a/_install/pkg-a-0.1.0.0_iface/LibA.dyn_hi) <(ghc --show-iface output2/bazel-bin/tests/haskell_cabal_reproducibility/pkg-a/_install/pkg-a-0.1.0.0_iface/LibA.dyn_hi)

When #1645 is merged this could be turned into an integration test.

Currently fails with the following steps:

```
$ n=1; bazel clean; sudo rm -rf output$n; bazel build //tests/haskell_cabal_reproducibility/pkg-b --execution_log_json_file=execlog$n.json; rsync -aL bazel-bin output$n
$ n=2; bazel clean; sudo rm -rf output$n; bazel build //tests/haskell_cabal_reproducibility/pkg-b --execution_log_json_file=execlog$n.json; rsync -aL bazel-bin output$n
$ diff -ur output1 output2
$ diff -u <(ghc --show-iface output1/bazel-bin/tests/haskell_cabal_reproducibility/pkg-a/_install/pkg-a-0.1.0.0_iface/LibA.dyn_hi) <(ghc --show-iface output2/bazel-bin/tests/haskell_cabal_reproducibility/pkg-a/_install/pkg-a-0.1.0.0_iface/LibA.dyn_hi)
```

@ylecornec ylecornec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me 👍

@aherrmann aherrmann added the merge-queue merge on green CI label Feb 8, 2022
@mergify
mergify Bot merged commit 7594909 into master Feb 8, 2022
@mergify
mergify Bot deleted the cabal-reproducible branch February 8, 2022 09:05
@mergify mergify Bot removed the merge-queue merge on green CI label Feb 8, 2022
@cocreature

Copy link
Copy Markdown
Collaborator

Thanks a lot!

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