rules_haskell
rules_haskell copied to clipboard
`ghc_wrapper` is killed on MacOS arm64 running tests under `rules_haskell_tests`
Describe the bug
The ghc_wrapper is killed when executing bazel test //... in rules_haskell_tests on MacBook Pro (M2 Pro).
ERROR: /Users/chuckgrindel/code/tweag/rules_haskell/cg/macos_arm64/rules_haskell_tests/tests/haddock/BUILD.bazel:18:16: HaskellBuildLibrary @//tests/haddock:haddock-lib-a failed: (Killed): ghc_wrapper failed: error executing command (from target //tests/haddock:haddock-lib-a) bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/ghc_wrapper bazel-out/darwin_arm64-fastbuild/bin/tests/haddock/compile_flags_haddock-lib-a__HaskellBuildLibrary ... (remaining 1 argument skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
ld: warning: -single_module is obsolete
/var/folders/5q/_th2byd13h11mxtnvm5ck9_40000gq/T/ghc90734_0/libghc_7.dylib.resign: replacing existing signature
/Applications/Xcode-15.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: /var/folders/5q/_th2byd13h11mxtnvm5ck9_40000gq/T/ghc90734_0/libghc_7.dylib
bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_haskell/haskell/ghc_wrapper: line 80: 90734 Killed: 9 "${compile_flags[@]}" "${extra_args[@]}" 2>&1
90736 Done | drop_loaded_and_warning 1>&2
To Reproduce
Change into rules_haskell_tests.
cd rules_haskell_tests
Create .bazelrc.local file.
build --config=macos-bindist
Build and test.
BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 bazel test //...
Expected behavior
Success.
Environment
- OS name + version: MacOS 14.2.1 (23C71)
- Bazel version: 6.4.0
- Version of the rules: 0.18
Additional context
Messages found in MacOS Console
CODE SIGNING: cs_invalid_page(0x100318000): p=90734[ghc-9.2.8] final status 0x23020200, denying page sending SIGKILL
CODE SIGNING: process 90734[ghc-9.2.8]: rejecting invalid page at address 0x100318000 from offset 0x0 in file "/private/var/folders/5q/_th2byd13h11mxtnvm5ck9_40000gq/T/ghc90734_0/libghc_7.dylib" (cs_mtime:1704409989.686403126 == mtime:1704409989.686403126) (signed:1 validated:1 tainted:1 nx:0 wpmapped:0 dirty:0 depth:0)
ghc-9.2.8[90734] Corpse allowed 1 of 5
Possible related to https://github.com/input-output-hk/haskell.nix/issues/2018.
Looking at the error message, the relevant code is probably here: https://github.com/tweag/rules_haskell/blob/b2baa5f8f08aa859a03e83cc4bb9718798a0d90a/haskell/private/cc_wrapper.py.tpl#L932-L939
I tracked this down to how the darwinCC in rules_nixpkgs_cc is constructed: tools from different toolchains are mixed (stdenv.cc and darwin.cctools based on llvm) and this seems to cause trouble.
See https://github.com/tweag/rules_nixpkgs/pull/479
@avdv Good find. Can we close this issue or do you think that there is more work to do here?
Can we close this issue or do you think that there is more work to do here?
@cgrindel Maybe we should upgrade rules_nixpkgs to a revision that has this fix? WDYT?
That is a good idea. Should we create a separate issue to track?
That is a good idea. Should we create a separate issue to track?
:+1: done: https://github.com/tweag/rules_haskell/issues/2119