cargo: Apple Silicon: Exiting with SIGKILL when using custom build script

Problem When using cargo check using the new apple silicon toolchain on any package with a build.rs file it ends with a “SIGKILL” abort:

patrickkuen@mbp-von-patrick test_library % cargo check
   Compiling test_library v0.1.0 (/Users/patrickkuen/Developer/personal/test_library)
error: failed to run custom build command for `test_library v0.1.0 (/Users/patrickkuen/Developer/personal/test_library)`

Caused by:
  process didn't exit successfully: `/Users/patrickkuen/Developer/personal/test_library/target/debug/build/test_library-deff025c5c03f0d3/build-script-build` (signal: 9, SIGKILL: kill)

rustup-toolchain:

beta-aarch64-apple-darwin (default)
rustc 1.49.0-beta.2 (bd26e4e54 2020-11-24)

Steps

  1. Create a package using cargo new testlib --lib
  2. Create a build.rs file with a simple main function in it
  3. Run cargo check

Possible Solution(s) When removing the file, the error appears, so it seems like the build.rs causes the sigkill. Maybe the main function expect any specific return?

Notes

Output of cargo version: cargo 1.49.0-beta (b9216831a 2020-11-24)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 22 (10 by maintainers)

Most upvoted comments

I still have this problem… It looks like my rustc version is correct

file $(which rustup)
/Users/ad/.cargo/bin/rustup: Mach-O 64-bit executable arm64
file $(which cargo)
/Users/ad/.cargo/bin/cargo: Mach-O 64-bit executable arm64
file $(which rustc)
/Users/ad/.cargo/bin/rustc: Mach-O 64-bit executable arm64
rustc --version
rustc 1.50.0-nightly (6645da366 2020-12-01)

This problem drove me nuts. The underlying issue was that I was running a shell from homebrew (bash), which was running under emulation, and confusing the architecture detection of everything that was running underneath.

arch -arm64e sh and going back to the default shells fixed this.

I uninstalled rustup-init from brew and installed rustup the common way. I have the arm version of rustup now and the build of the test library completed successfully. Therefore the solution is to have a complete arm toolchain (rustup, cargo and rustc) like @ehuss suggested.

It would be good if this case could be handled with an error message, but I will close this issue for now. Thank you for your help!