Skip to content

Conversation

UebelAndre
Copy link
Contributor

@UebelAndre UebelAndre commented Jul 31, 2025

This change resolves the following issue which impacts rules_rust (bazelbuild/rules_rust#3535 (comment)):

(02:58:02) ERROR: /Users/buildkite/builds/bk-macos-arm64-pz85/bazel/rules-rust-rustlang/util/process_wrapper/BUILD.bazel:31:36: Compiling Rust (without process_wrapper) bin process_wrapper (6 files) failed: (Exit 1): bootstrap_process_wrapper.sh failed: error executing Rustc command (from target //util/process_wrapper:process_wrapper)
  (cd /private/var/tmp/_bazel_buildkite/a86460401be5422e0ecc75a08e74f9e3/sandbox/darwin-sandbox/75/execroot/_main && \
  exec env - \
    CARGO_CFG_TARGET_ARCH=aarch64 \
    CARGO_CFG_TARGET_OS=macos \
    CARGO_CRATE_NAME=process_wrapper \
    CARGO_MANIFEST_DIR='${pwd}/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='' \
    REPOSITORY_NAME='' \
    ZERO_AR_DATE=1 \
  bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/util/process_wrapper/bootstrap_process_wrapper.sh -- bazel-out/darwin_arm64-fastbuild/bin/external/+rust+rust_macos_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain/bin/rustc util/process_wrapper/main.rs '--crate-name=process_wrapper' '--crate-type=bin' '--error-format=human' '--out-dir=bazel-out/darwin_arm64-fastbuild/bin/util/process_wrapper' '--codegen=opt-level=0' '--codegen=debuginfo=0' '--codegen=strip=none' '--remap-path-prefix=${pwd}=.' '--emit=link=bazel-out/darwin_arm64-fastbuild/bin/util/process_wrapper/process_wrapper' '--emit=dep-info' '--color=always' '--target=aarch64-apple-darwin' -L bazel-out/darwin_arm64-fastbuild/bin/external/+rust+rust_macos_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain/lib/rustlib/aarch64-apple-darwin/lib '--edition=2018' '-Cembed-bitcode=no' '--codegen=linker=external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh' '--codegen=link-arg=-mmacosx-version-min=15.2' '--codegen=link-arg=-no-canonical-prefixes' '--codegen=link-arg=-fobjc-link-runtime' '--codegen=link-arg=-headerpad_max_install_names' '--codegen=link-arg=-lc++' '--codegen=link-arg=-lm' '--extern=tinyjson=bazel-out/darwin_arm64-fastbuild/bin/external/+i+rules_rust_tinyjson/libtinyjson-2730294943.rlib' '-Ldependency=bazel-out/darwin_arm64-fastbuild/bin/external/+i+rules_rust_tinyjson' '--sysroot=bazel-out/darwin_arm64-fastbuild/bin/external/+rust+rust_macos_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain')
# Configuration: 44d823af471c00a0f331560f31c47d7492ea88dc35aa83e5331e5aab8731d666
# Execution platform: @@platforms//host:host
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: linking with `external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh` failed: exit status: 127
  |
  = note:  "external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh" "/tmp/rustcYxWIZ7/symbols.o" "<17 object files omitted>" "/private/var/tmp/_bazel_buildkite/a86460401be5422e0ecc75a08e74f9e3/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/external/+i+rules_rust_tinyjson/{libtinyjson-2730294943.rlib}.rlib" "/private/var/tmp/_bazel_buildkite/a86460401be5422e0ecc75a08e74f9e3/external/+rust+rust_macos_aarch64__aarch64-apple-darwin__stable_tools/lib/rustlib/aarch64-apple-darwin/lib/{libstd-b14eaf39f161baba.rlib,libpanic_unwind-e9afca0624de13f2.rlib,libobject-f4f25c763c07e1da.rlib,libmemchr-f5821a4757eb4967.rlib,libaddr2line-e2075fd42f8fdfe6.rlib,libgimli-08932eb7054dd262.rlib,librustc_demangle-ed8c67e97825d1a5.rlib,libstd_detect-1047965a55c74dd5.rlib,libhashbrown-a128e33792b49d56.rlib,librustc_std_workspace_alloc-9d142a7fc6a557ed.rlib,libminiz_oxide-b5c8cae15aefe652.rlib,libadler2-458be00c7580c8fb.rlib,libunwind-ebf825f8faf836bb.rlib,libcfg_if-c920e7cfad4eac40.rlib,liblibc-b046c3bdd2263ebf.rlib,liballoc-4320d4958ec5f4d4.rlib,librustc_std_workspace_core-8e246dbdcfd33251.rlib,libcore-c8c2fe5a80a1416e.rlib,libcompiler_builtins-78f29445e315e03f.rlib}.rlib" "-lSystem" "-lc" "-lm" "-arch" "arm64" "-mmacosx-version-min=11.0.0" "-L" "<sysroot>/lib/rustlib/aarch64-apple-darwin/lib" "-o" "bazel-out/darwin_arm64-fastbuild/bin/util/process_wrapper/process_wrapper" "-Wl,-dead_strip" "-nodefaultlibs" "-mmacosx-version-min=15.2" "-no-canonical-prefixes" "-fobjc-link-runtime" "-headerpad_max_install_names" "-lc++" "-lm"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: env: bash: No such file or directory
error: aborting due to 1 previous error

This change is related to d749150 where shebangs were updated but on Posix systems /bin/sh is expected to be consistently available so PATH reliance can be avoided.

@UebelAndre
Copy link
Contributor Author

UebelAndre commented Jul 31, 2025

cc @keith @lromor

@UebelAndre
Copy link
Contributor Author

Based on my read of https://bazel.build/external/module#compatibility_level it seems this issue would be fairly widespread and require users to use single_version_override in some fashion to avoid this issue. It'd be great if a fix could be made and released as 0.1.5 and if the desire is to keep this breaking change then to publish it as 0.2.0.

@hzeller
Copy link

hzeller commented Jul 31, 2025

The only Posix-guaranteed available path is /bin/sh.

The bash shell might be installed wherever, so if the features of bash are needed in the shell script, it should be /usr/bin/env bash.

I would not be happy with using an absolute path to /bin/bash, it is a step backwards and breaks when bash is not installed there (many people use operating systems and package managers such as Nix (even on Mac) were hardcoded assumptions of bash does not hold).

The original issue just seems to be that there is no path to /bin set in the CI (which sounds broken).

If the scripts can be written to just use sh features, then using /bin/sh would be perfectly fine.

@UebelAndre
Copy link
Contributor Author

UebelAndre commented Jul 31, 2025

@hzeller I've switched to /bin/sh which seems to work just fine.

@hzeller
Copy link

hzeller commented Jul 31, 2025

Perfect. If the scripts don't use bash-specific features, it might be worthwhile looking through the other scripts as well and convert as many as possible to pure /bin/sh

@UebelAndre
Copy link
Contributor Author

Perfect. If the scripts don't use bash-specific features, it might be worthwhile looking through the other scripts as well and convert as many as possible to pure /bin/sh

I can do as part of a separate PR but for now this is the only one actually breaking things so would like to keep the focus on impacting issues. I agree it'd be a worthwhile to try to convert to /bin/sh.

@UebelAndre
Copy link
Contributor Author

poke @comius or any other rules_cc maintainer for a review 😅

@UebelAndre
Copy link
Contributor Author

@trybka does an additional review at Google need to be done?

@UebelAndre
Copy link
Contributor Author

Closing in favor of #466

@UebelAndre UebelAndre closed this Aug 19, 2025
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