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

ghc962: could not execute: otool #267250

Closed
avdv opened this issue Nov 13, 2023 · 2 comments · Fixed by #268652
Closed

ghc962: could not execute: otool #267250

avdv opened this issue Nov 13, 2023 · 2 comments · Fixed by #268652
Labels
0.kind: bug Something is broken 6.topic: darwin Running or building packages on Darwin 6.topic: haskell

Comments

@avdv
Copy link
Member

avdv commented Nov 13, 2023

Describe the bug

I am trying to use GHC 9.6.2 from nixpkgs with Bazel but receive this error:

ERROR: /Users/claudio/rules_haskell/tools/runfiles/BUILD.bazel:24:16: HaskellLinkDynamicLibrary tools/runfiles/libHStoolsZSrunfilesZSrunfiles-ghc9.6.2.dylib failed: (Exit 1): process-wrapper failed: error executing command 
  (cd /private/var/tmp/_bazel_claudio/afceb7d1cdeddc94d64e34c0a088ac89/sandbox/processwrapper-sandbox/455/execroot/rules_haskell && \
  exec env - \
    CC_WRAPPER_CC_PATH=external/nixpkgs_config_cc/cc_wrapper.sh \
    CC_WRAPPER_CPU=darwin_arm64 \
    CC_WRAPPER_PLATFORM=darwin \
    LANG=C.UTF-8 \
    MUST_EXTRACT_ABI=false \
    PATH=/nix/store/ccjpkiqx40y6y98rpa2l8z4xg9mdlmq7-posix-toolchain/bin \
    RULES_HASKELL_DOCDIR_PATH=/nix/store/ywfzw2q59fna075p6ww98zlls4pgw17c-ghc-9.6.2/lib/ghc-9.6.2/lib/../../../../ya2qgcdazcvdb478zlzz97xpwp79jfjv-ghc-9.6.2-doc/share/doc/ghc/html/libraries/base-4.18.0.0 \
    RULES_HASKELL_GHC_PATH=external/rules_haskell_ghc_nixpkgs/bin/ghc \
    RULES_HASKELL_GHC_PKG_PATH=external/rules_haskell_ghc_nixpkgs/bin/ghc-pkg \
    RULES_HASKELL_LIBDIR_PATH=/nix/store/ywfzw2q59fna075p6ww98zlls4pgw17c-ghc-9.6.2/lib/ghc-9.6.2/lib \
    TMPDIR=/tmp \
  /var/tmp/_bazel_claudio/install/aa60e81d6fcd23c7034d0325a85596ce/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_claudio/afceb7d1cdeddc94d64e34c0a088ac89/sandbox/processwrapper-sandbox/455/stats.out' bazel-out/darwin_arm64-opt-exec-C7777A24/bin/haskell/ghc_wrapper bazel-out/darwin_arm64-fastbuild/bin/tools/runfiles/compile_flags_runfiles____HaskellLinkDynamicLibrary bazel-out/darwin_arm64-fastbuild/bin/tools/runfiles/extra_args_runfiles____HaskellLinkDynamicLibrary)
/Library/Developer/CommandLineTools/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: bazel-out/darwin_arm64-fastbuild/bin/tools/runfiles/libHStoolsZSrunfilesZSrunfiles-ghc9.6.2.dylib
bazel-out/darwin_arm64-fastbuild/bin/tools/runfiles/libHStoolsZSrunfilesZSrunfiles-ghc9.6.2.dylib.resign: replacing existing signature
ghc-9.6.2: could not execute: otool

Note that PATH is set to /nix/store/ccjpkiqx40y6y98rpa2l8z4xg9mdlmq7-posix-toolchain/bin inside Bazel's sandbox.

However, using GHC 9.4.6 or 9.2.8 works just fine.

Looking at GHC's settings ( /nix/store/ywfzw2q59fna075p6ww98zlls4pgw17c-ghc-9.6.2/lib/ghc-9.6.2/lib/settings) I notice that the otool command is just set to otool:

,("otool command", "otool")

But previously, for former GHC versions it is properly set (e.g. /nix/store/lyfm7yz87ygvp8lkizxn43jcc11irpyq-ghc-9.4.6/lib/ghc-9.4.6/settings):

,("otool command", "/nix/store/s9j9nksvxalyw464x6q1brdp79ga1qhr-cctools-binutils-darwin-973.0.1/bin/otool")

Steps To Reproduce

(it is a bit more involved to create a few simple steps to reproduce and I think it is quite clear what the problem is. I can provide these steps if wanted)

Expected behavior

GHC should be able to execute otool even it is not on the PATH.

Additional context

Add any other context about the problem here.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m" - system: `"aarch64-darwin"`
 - host os: `Darwin 21.6.0, macOS 12.7`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
@avdv avdv added the 0.kind: bug Something is broken label Nov 13, 2023
@cdepillabout
Copy link
Member

cdepillabout commented Nov 19, 2023

@avdv Thanks for reporting this.

I'm not sure any of the Haskell maintainers are that knowledgeable about aarch64-darwin. You may not get any help with this unless you're willing to investigate yourself.

My guess is that this at least has something to do with the differences between the GHC expressions for 9.4 and 9.6, where 9.6 is based on Hadrian:

vs

@cdepillabout cdepillabout added the 6.topic: darwin Running or building packages on Darwin label Nov 19, 2023
@avdv
Copy link
Member Author

avdv commented Nov 21, 2023

Thank you for the pointer, @cdepillabout. I could pinpoint the problem (which also manifests itself on x86_64-darwin BTW).

The hadrian build creates a bindist, which has to be configured again. Running make install generates the final settings file. The configure script of the bindist, however, does not care about the OTOOL env variable, but uses the OtoolCmd env variable instead... Same for INSTALL_NAME_TOOL vs. InstallNameToolCmd.

\edit: created an upstream issue here => https://gitlab.haskell.org/ghc/ghc/-/issues/24211

avdv added a commit to avdv/nixpkgs that referenced this issue Nov 21, 2023
sternenseemann added a commit that referenced this issue Nov 21, 2023
Fixes #267250.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
@sternenseemann sternenseemann linked a pull request Nov 21, 2023 that will close this issue
sternenseemann added a commit to sternenseemann/nixpkgs that referenced this issue Nov 22, 2023
Fixes NixOS#267250.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
sternenseemann added a commit that referenced this issue Nov 22, 2023
Fixes #267250.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
avdv added a commit to tweag/rules_haskell that referenced this issue Dec 1, 2023
In previous GHC versions from nixpkgs, the `otool` setting was referencing a tool in the nix store,
but for GHC 9.6.2 it is just set to "otool" which means it must be in `$PATH`.

The same applies to the `install_name_tool`.

See NixOS/nixpkgs#267250 and https://gitlab.haskell.org/ghc/ghc/-/issues/24211

We work around by using the location of the `ar` command and assume the other tools (from the bintools
package) are also available at the same place.
avdv added a commit to tweag/rules_haskell that referenced this issue Dec 4, 2023
In previous GHC versions from nixpkgs, the `otool` setting was referencing a tool in the nix store,
but for GHC 9.6.2 it is just set to "otool" which means it must be in `$PATH`.

The same applies to the `install_name_tool`.

See NixOS/nixpkgs#267250 and https://gitlab.haskell.org/ghc/ghc/-/issues/24211

We work around by using the location of the `ar` command and assume the other tools (from the bintools
package) are also available at the same place.
avdv added a commit to tweag/rules_haskell that referenced this issue Dec 4, 2023
In previous GHC versions from nixpkgs, the `otool` setting was referencing a tool in the nix store,
but for GHC 9.6.2 it is just set to "otool" which means it must be in `$PATH`.

The same applies to the `install_name_tool`.

See NixOS/nixpkgs#267250 and https://gitlab.haskell.org/ghc/ghc/-/issues/24211

We work around by using the location of the `ar` command and assume the other tools (from the bintools
package) are also available at the same place.
avdv added a commit to tweag/rules_haskell that referenced this issue Dec 4, 2023
In previous GHC versions from nixpkgs, the `otool` setting was referencing a tool in the nix store,
but for GHC 9.6.2 it is just set to "otool" which means it must be in `$PATH`.

The same applies to the `install_name_tool`.

See NixOS/nixpkgs#267250 and https://gitlab.haskell.org/ghc/ghc/-/issues/24211

We work around by using the location of the `ar` command and assume the other tools (from the bintools
package) are also available at the same place.
avdv added a commit to tweag/rules_haskell that referenced this issue Dec 4, 2023
In previous GHC versions from nixpkgs, the `otool` setting was referencing a tool in the nix store,
but for GHC 9.6.2 it is just set to "otool" which means it must be in `$PATH`.

The same applies to the `install_name_tool`.

See NixOS/nixpkgs#267250 and https://gitlab.haskell.org/ghc/ghc/-/issues/24211

We work around by using the location of the `ar` command and assume the other tools (from the bintools
package) are also available at the same place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: darwin Running or building packages on Darwin 6.topic: haskell
3 participants