rust-lang / cargo-bisect-rustc

Bisects rustc, either nightlies or CI artifacts
https://rust-lang.github.io/cargo-bisect-rustc/
Apache License 2.0
174 stars 55 forks source link

"Exec format error" with custom script and cross compiling #342

Closed tgross35 closed 1 week ago

tgross35 commented 1 week ago

I am trying to run some compiler-builtins tests that need to be run through Docker. So, I have the following command:

RUST_BACKTRACE=1 cargo bisect-rustc --start=2024-05-29 --end=2024-06-21 --target powerpc64le-unknown-linux-gnu --without-cargo --script script.sh --preserve -vvvvv

And the following script:

set -eaux
RUST_COMPILER_RT_ROOT=./compiler-rt ./ci/run-docker.sh powerpc64le-unknown-linux-gnu

Unfortunately this is hitting an "Exec format error" trying to run the command https://github.com/rust-lang/cargo-bisect-rustc/blob/a036d4207aed2e2eefdb22634bc9bf3b59e869b4/src/toolchains.rs#L313. I don't get this because if I copy and paste the command from the output it runs fine. Exec format error is usually related to running something on the wrong arch... is it trying to execute ./script.sh as a powerpc executable somehow?

Full error:

thread 'main' panicked at /home/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-bisect-rustc-0.6.9/src/toolchains.rs:313:17:
thiserror::Errored to run cd "." && CARGO_BUILD_TARGET="powerpc64le-unknown-linux-gnu" CARGO_TARGET_DIR="target-bisector-nightly-2024-05-29-x86_64-unknown-linux-gnu" RUSTUP_TOOLCHAIN="bisector-nightly-2024-05-29-x86_64-unknown-linux-gnu" "/home/tmgross/projects/rust/compiler-builtins/script.sh": Os { code: 8, kind: Uncategorized, message: "Exec format error" }
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: cargo_bisect_rustc::toolchains::Toolchain::run_test
   3: cargo_bisect_rustc::toolchains::Toolchain::test
   4: cargo_bisect_rustc::Config::install_and_test
   5: cargo_bisect_rustc::main

(side note - what's up with the error message being "thiserror::Errored to run"?)

ehuss commented 1 week ago

The script needs a shebang line (like #!/bin/bash). It works when run manually because bourne shells will assume it is a shell script without the shebang.

tgross35 commented 1 week ago

OH I totally missed that, thanks!