bazelbuild / bazelbuild/rules_rust
error: unable to run `strip`: No such file or directory (os error 2)
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Hi.
I am trying to build a simple `rust_binary`, but the build fails with the error:
```
ERROR: /private/var/tmp/_bazel_claudio/7ec48aaaaf38cb969348d6b03cb24398/external/rules_rust/util/process_wrapper/BUILD.bazel:31:36: Compiling Rust (without process_wrapper) bin process_wrapper (6 files) [for tool] failed: (Exit 1): process-wrapper failed: error executing command
(cd /private/var/tmp/_bazel_claudio/7ec48aaaaf38cb969348d6b03cb24398/sandbox/processwrapper-sandbox/5/execroot/__main__ && \
exec env - \
CARGO_CFG_TARGET_ARCH=x86_64 \
CARGO_CFG_TARGET_OS=darwin \
CARGO_CRATE_NAME=process_wrapper \
CARGO_MANIFEST_DIR='${pwd}/external/rules_rust/util/process_wrapper' \
CARGO_PKG_AUTHORS='' \
CARGO_PKG_DESCRIPTION='' \
CARGO_PKG_HOMEPAGE='' \
CARGO_PKG_NAME=process_wrapper \
CARGO_PKG_VERSION=0.0.0 \
CARGO_PKG_VERSION_MAJOR=0 \
CARGO_PKG_VERSION_MINOR=0 \
CARGO_PKG_VERSION_PATCH=0 \
CARGO_PKG_VERSION_PRE='' \
PATH=/nix/store/0ly5lpwanagc5qpmnqrw8aqxb4ivw7kf-bash-5.2-p15/bin:/nix/store/vd0b59wk8x56i8kmwda8jl5h37wnixn2-coreutils-9.3/bin:/nix/store/2jp91fvgj8mjnpx2vjavc7sw5njbdv04-diffutils-3.10/bin:/nix/store/dl50w02kxffqn52rc1hlps01danyac5g-file-5.45/bin:/nix/store/cmh1dkqbzds5ilgmz9vc7jpavd8lflp3-findutils-4.9.0/bin:/nix/store/f27mhm2kpk37mpj88f77j0y2ncgb95a7-gawk-5.2.2/bin:/nix/store/ccnn45f8fjs7dcj53jgw8jmaa2dq9nrm-gnugrep-3.11/bin:/nix/store/l7hp06f9rfvx8w54vmi3vk1xvgpj34fc-patch-2.7.6/bin:/nix/store/lpzfs8kvdf7fs2j2fbc8a0r2zjjlygna-gnused-4.9/bin:/nix/store/9zmlp4a3y519q3hkflyik9alsmjzpyda-gnutar-1.35/bin:/nix/store/q0vax9kk0mylpd91d9j18556awm1l6ip-gzip-1.13/bin:/nix/store/cdbhdah4qillzy7z9rsi3svbarwm8a6i-python3-3.11.6/bin:/nix/store/693r22pwssm9pl0bs8qym3sqv7l1z730-unzip-6.0/bin:/nix/store/v89g5yvikb31g5xf67zfzycqbag37afw-which-2.21/bin:/nix/store/xga5kc0ggmhyarkphb5wqb8ipb6xb724-zip-3.0/bin \
SYSROOT=bazel-out/darwin-opt-exec-C7777A24/bin/external/nix_rust/rust_nix_impl \
TMPDIR=/tmp \
/var/tmp/_bazel_claudio/install/cd2c210472e7996ec15d2a8e1f15308e/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_claudio/7ec48aaaaf38cb969348d6b03cb24398/sandbox/processwrapper-sandbox/5/stats.out' bazel-out/darwin-opt-exec-C7777A24/bin/external/rules_rust/util/process_wrapper/process_wrapper.sh -- bazel-out/darwin-opt-exec-C7777A24/bin/external/nix_rust/rust_nix_impl/bin/rustc external/rules_rust/util/process_wrapper/main.rs '--crate-name=process_wrapper' '--crate-type=bin' '--error-format=human' '--out-dir=bazel-out/darwin-opt-exec-C7777A24/bin/external/rules_rust/util/process_wrapper' '--codegen=opt-level=3' '--codegen=debuginfo=0' '--remap-path-prefix=${pwd}=' '--emit=dep-info,link' '--color=always' '--target=x86_64-apple-darwin' -L bazel-out/darwin-opt-exec-C7777A24/bin/external/nix_rust/rust_nix_impl/lib/rustlib/x86_64-apple-darwin/lib '-Cstrip=debuginfo' '--edition=2018' '--codegen=linker=external/nixpkgs_config_cc/cc_wrapper.sh' --codegen 'link-args=-undefined dynamic_lookup -headerpad_max_install_names -lpthread -ldl -lc++ -lm' '--extern=tinyjson=bazel-out/darwin-opt-exec-C7777A24/bin/external/rules_rust_tinyjson/libtinyjson-4031717389.rlib' '-Ldependency=bazel-out/darwin-opt-exec-C7777A24/bin/external/rules_rust_tinyjson' '--sysroot=bazel-out/darwin-opt-exec-C7777A24/bin/external/nix_rust/rust_nix_impl')
error: unable to run `strip`: No such file or directory (os error 2)
error: aborting due to previous error
Target //:hello failed to build
INFO: Elapsed time: 2.082s, Critical Path: 1.45s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
```
This seems to be caused by rustc expecting a `strip` binary in `PATH`. Is that right? Is there a way to inform rustc which tool it should call when stripping a binary instead of doing a PATH lookup, ie. use the strip tool from the cc toolchain?
\edit: This is only the case on Darwin (or Illumos), reference: https://github.com/rust-lang/rust/blob/8d39ec1825024f3014e1f847942ac5bbfcf055b0/compiler/rustc_codegen_ssa/src/back/link.rs#L1043-L1103
Contributor guide
Assessment
This issue has not been assessed yet.