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

Fix build problems with GHC 9.x #1749

Merged
merged 4 commits into from
Jun 2, 2022
Merged

Fix build problems with GHC 9.x #1749

merged 4 commits into from
Jun 2, 2022

Conversation

avdv
Copy link
Member

@avdv avdv commented Jun 1, 2022

This PR integrates changes from the daml project which where deemed necessary when upgrading GHC to 9.0.2, see digital-asset/daml#12300

  1. handle include dir for GHC 9.x on Windows https://github.com/digital-asset/daml/blob/main/bazel_tools/haskell-ghc-includes.patch
  2. remove non-existent haddock settings for the rts package https://github.com/digital-asset/daml/blob/main/bazel_tools/haskell-rts-docs.patch

Note, I did not want to change the default GHC version to 9.x yet, but I did run checks for 9.0.2 and 9.2.1 in branches https://github.com/tweag/rules_haskell/tree/fix-bindist-issues-9.2.1 and https://github.com/tweag/rules_haskell/tree/fix-bindist-issues-9.0.2:

Furthermore, this PR reverts commit 20085b2 because building the example with GHC 9.2.1 failed (https://github.com/tweag/rules_haskell/actions/runs/2414717193), and reverting the commit fixed the problem. ❗ cc @matsubara0507

avdv added 4 commits May 31, 2022 12:55
The GHC bindists changed the directory layout starting with version 9.
The rts package's haddock file is not shipped with GHC bindists.
This reverts commit 20085b2.

Without this flag, the pkgdb files are not correctly modified and absolute paths
to sandbox directories are referenced.
@matsubara0507
Copy link
Contributor

I created commit 20085b2 to fix following error:

$ bazelisk run //:example-bin
INFO: SHA256 (https://github.com/tweag/rules_haskell/archive/1d10367157c22031df0e9f5ceab355eedd2c8403.tar.gz) = 54039ccacb89f9a2e4966a74c46388edd5c92b30ab0ebaef66476854b1448fd8
INFO: Analyzed target //:example-bin (36 packages loaded, 8087 targets configured).
INFO: Found 1 target...
ERROR: /path/to/external/stackage/BUILD.bazel:12:22: HaskellCabalLibrary @stackage//:unliftio-core failed: (Exit 1): cabal_wrapper failed: error executing command bazel-out/host/bin/external/rules_haskell/haskell/cabal_wrapper bazel-out/darwin-fastbuild/bin/external/stackage/unliftio-core_cabal_wrapper_args.json

Use --sandbox_debug to see verbose messages from the sandbox

../../../bazel-out/darwin-fastbuild/bin/external/stackage/unliftio-core-0.2.0.1/unliftio-core-0.2.0.1/build/autogen/Paths_unliftio_core.hs:47:17: error:
    Variable not in scope: splitFileName :: FilePath -> (a, b0)
   |
47 |   let (dir,_) = splitFileName exePath
   |                 ^^^^^^^^^^^^^

../../../bazel-out/darwin-fastbuild/bin/external/stackage/unliftio-core-0.2.0.1/unliftio-core-0.2.0.1/build/autogen/Paths_unliftio_core.hs:48:16: error:
    Variable not in scope: minusFileName :: t0 -> String -> String
   |
48 |   return ((dir `minusFileName` "bin") `joinFileName` dirRel)
   |                ^^^^^^^^^^^^^^^
Traceback (most recent call last):
  File "/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/bazel-out/host/bin/external/rules_haskell/haskell/runghc.runfiles/rules_haskell/haskell/runghc.py", line 9, in <module>
    subprocess.run([r.Rlocation("rules_haskell_ghc_darwin_amd64/bin/runghc")] + sys.argv[1:], check=True)
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/bazel-out/host/bin/external/rules_haskell/haskell/runghc.runfiles/rules_haskell_ghc_darwin_amd64/bin/runghc', '/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/external/stackage/unliftio-core-0.2.0.1/Setup.hs', 'build', '--verbose=0', '--builddir=/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/bazel-out/darwin-fastbuild/bin/external/stackage/unliftio-core-0.2.0.1/unliftio-core-0.2.0.1']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/bazel-out/host/bin/external/rules_haskell/haskell/cabal_wrapper.runfiles/rules_haskell/haskell/private/cabal_wrapper.py", line 287, in <module>
    run([runghc] + runghc_args + [setup, "build", "--verbose=0", "--builddir=" + distdir])
  File "/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/bazel-out/host/bin/external/rules_haskell/haskell/cabal_wrapper.runfiles/rules_haskell/haskell/private/cabal_wrapper.py", line 68, in run
    subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, *args, **kwargs)
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/bazel-out/host/bin/external/rules_haskell/haskell/runghc', '/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/external/stackage/unliftio-core-0.2.0.1/Setup.hs', 'build', '--verbose=0', '--builddir=/path/to/sandbox/darwin-sandbox/21/execroot/example-haskell-with-bazel/bazel-out/darwin-fastbuild/bin/external/stackage/unliftio-core-0.2.0.1/unliftio-core-0.2.0.1']' returned non-zero exit status 1.
Target //:example-bin failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 29.443s, Critical Path: 12.49s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

ref: https://github.com/matsubara0507/example-haskell-with-bazel/runs/6690310788?check_suite_focus=true

The cause of this error is haskell/cabal#6984 .
When Cabal v3.6 generate Paths module with --enable-relocatable, not generate utility functions (e.g. splitFileName).
So, disable relocatable flag.

Looking back now, I think that unliftio-core package should not generate Paths module.
So, I think that it’s okay to revert commit 20085b2 .

@avdv
Copy link
Member Author

avdv commented Jun 2, 2022

Thank you @matsubara0507, for providing the context for the change and confirming that reverting that commit is OK.

I am just wondering, haskell/cabal#6984 says "The PR first appeared in 3.6.2+0", so Cabal 3.6.0.0 should not be effected, right?! Does that mean we might see this problem in a later GHC version (read: with a newer Cabal version) again?

Copy link
Member

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

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

Thank you, looks good!

@aherrmann aherrmann added the merge-queue merge on green CI label Jun 2, 2022
@mergify mergify bot merged commit d9b300e into master Jun 2, 2022
@mergify mergify bot deleted the ghc-9-improvements branch June 2, 2022 08:10
@mergify mergify bot removed the merge-queue merge on green CI label Jun 2, 2022
@avdv avdv added the merge-queue merge on green CI label Jun 2, 2022
@mergify mergify bot removed the merge-queue merge on green CI label Jun 2, 2022
@matsubara0507
Copy link
Contributor

haskell/cabal#6984 says "The PR first appeared in 3.6.2+0", so Cabal 3.6.0.0 should not be effected, right?!

🤔

I think that haskell/cabal#6984 first appeared in Cabal-v3.6.0.0 release.

haskell/cabal@fe9a524

sync-master-3.8.0.20220526 sync-3.8.0.20220526-master gitlab-ci-try1-3.8.0.20220526 cabal-install-v3.8.1.0-rc1 cabal-install-v3.6.2.0 Cabal-v3.8.1.0-rc1 Cabal-v3.6.3.0 Cabal-v3.6.2.0 Cabal-v3.6.1.0 Cabal-v3.6.0.0 3.6.2+0

This order is probably 0123...ABC...abc..., not created timestamp.

symbiont-eric-torreborre added a commit to symbiont-eric-torreborre/transformers-compat that referenced this pull request Jun 10, 2022
To support the compilation with bazel. See tweag/rules_haskell#1749 (comment)
symbiont-eric-torreborre added a commit to symbiont-eric-torreborre/hspec that referenced this pull request Jun 10, 2022
To support the compilation with bazel. See tweag/rules_haskell#1749
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