-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Apple Silicon: Exiting with SIGKILL when using custom build script #8913
Comments
Is this perhaps related to Apple's latest changes around running untrusted executables? I'm not sure if there's anything Cargo can do about this since Cargo itself isn't sending SIGKILL or anything like that. I'm not entirely sure how toolchain-created-binaries are to be trusted on the new macOS... |
Okay could be possible, but the only strange thing is that the SIGKILL only appears when using the |
Can you compile and run a simple program with just rustc? Something like: $ cat foo.rs
fn main() {}
$ rustc foo.rs
$ ./foo or does that also die with SIGKILL? |
I believe others are having similar issues, see https://rust-lang.zulipchat.com/#narrow/stream/242906-t-compiler.2Farm/topic/macOS/near/213374421 and https://rust-lang.zulipchat.com/#narrow/stream/242906-t-compiler.2Farm/topic/Native.20aarch64-apple-darwin.20install.20trouble/near/217656988 and https://stackoverflow.com/questions/64830671/why-does-my-native-arm64-application-built-using-an-x86-64-build-system-fail-to. I would check the Console app to see if there are any signature verification errors in the logs. Maybe also run with I don't think any of us have access to an arm64 mac, so it may be difficult for us to help. People working on that target are mostly hanging out on the #t-compiler/arm stream on Zulip, so you may get some more insight there. |
No this works fine. As I said it also works fine when using cargo. Only when using a
I tried this several times but the compiler does not print any useful data. It seems like it not even executes the
No, sadly there isn't any output. See the following test:
|
I just found out another strange behaviour. When using |
When you get SIGKILL, if you go to System Preferences under "Security & Privacy", is there anything there that's asking you to allow the binary in one way or another? Similarly if you build a Rust program where the program spawns |
No sadly there is no option to allow anything. I know this message from downloading applications but in this case there is nothing to allow.
I'm not sure if you meant doing the following, but this also works:
I also tried the following:
After googling a bit, could this issue be of any help? neovim/neovim#13399 |
Hm interesting! To confirm, what build targets are you working with? Are you running through the x86_64 emulation or native aarch64? Maybe the bug is with one or the other? (for example if you have an emulated executable produce an emulated executable, does that work? Or for that matter, do all permutations of executable producing executabale work or do some fail?) |
I worked with the beta-aarch64-apple-darwin on a M1 Macbook Pro, so there would be no emulation. Yesterday I tried using the x86_64 toolchain, this works fine (probably it uses Rosetta?). |
So to confirm, using a native aarch64 toolchain produces these SIGKILL warnings while using the x86_64 toolchain does not? Can you test that at the command line? Does a bare |
As noted in https://rust-lang.zulipchat.com/#narrow/stream/242906-t-compiler.2Farm/topic/macOS.20build.20scripts.20and.20SIGKILL/near/218453006, you need to be extra careful to ensure the entire toolchain is arm64. Most notably, the rustup wrappers. Check |
If I can chime in here, did you check if this is not the result of the kernel caching the inodes? This results in similar behaviour where any change to the already signed and cached binary by the kernel will end up in an immediate SIGKILL. In Zig, to circumvent that when we do incremental linking (by modifying the existing binary in place), in addition to re-adding a valid code signature, it is also necessary to copy-rename the resultant binary so that the kernel doesn't see it as the already cached inode. Another instance of this issue manifesting I've had when patching the output of LLD in Zig toolchain so that we can compute and append valid code signatures without requiring the toolchain to fall back to the system linker. In this case, after LLD generates the binary without the code signature, I open the binary for writing, calculate and embed an adhoc code signature, and then do the copy-rename dance on the binary. Here's the latest PR describing this in Zig: ziglang/zig#7273. |
You are right. I installed rustup-init with brew, but as the arm brew is still very unstable, I used the x86_64 brew over rosetta. Therefore Sadly I don't really want to install brew for arm yet, so I fear I have to wait until it gets more stable to make rust for arm work. |
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. It would be good if this case could be handled with an error message, but I will close this issue for now. |
I still have this problem...
|
@aircloud what terminal emulator are you using? running from alacritty under rosetta as x86 it's exiting with SIGKILL. running with macOs default terminal it completes the build. |
I tried macOS terminal(default in the system)
|
I am also hitting this. I'm using Terminal.app and the latest Rust nightly.
|
I ran the build script with lldb and here's the output, in case it's helpful:
|
Ah I see this is the tracking issue for MacBook M1, which has a workaround for the issue: Sorry for the noise! |
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.
|
Same issue. Tried a billion fixes, nothing worked. Ended up just re-running everything in Bash instead of Apple's native zsh and everything worked fine. |
Problem
When using
cargo check
using the new apple silicon toolchain on any package with abuild.rs
file it ends with a "SIGKILL" abort:rustup-toolchain:
Steps
cargo new testlib --lib
build.rs
file with a simplemain
function in itcargo 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 (b921683 2020-11-24)
The text was updated successfully, but these errors were encountered: