-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
bootstrap should not use rustc --version
to detect the build triple on on Mac Apple Silicon M1 arm64
#104723
Comments
You can manage to compile Rust in this manner, but you must specifically configure it for cross-compiling. Rosetta2 produces these results because the machine is trying to say it is both an aarch64 and x86-64 machine to different things, so bootstrap does not successfully navigate this. You must hold its hand. However, this is all irrelevant. It having "only" Tier 2 support does not prevent us from distributing an aarch64-apple-darwin host compiler toolchain, including most optional components through Rustup, so please use that instead of... suffering through these shenanigans. |
@workingjubilee , oops, I plan to get a Macbook M2, it seems it's not suitable for Rust compiler development? |
That makes sense, thanks! I suspected something like this might be going on. Do you have any suggestions for how to "hold its hand"? Or what resources might be helpful?
My apologies; I should have made it clear that I have the normal Rust toolchain installed via the normal methods and it has all worked great! I can compile my own Rust programs and install tools via I did a fair amount of Googling to see if there were other places where people talked about contributing to the Rust compiler using an Apple Silicon/M1/etc. machine and didn't find anything. That's why I posted here 😄 Any pointers would be appreciated, for my sake and for the sake of anybody else who wants to do the same and finds this thread. |
I believe the simplest way will be to edit the config.toml. It has various options, which you probably want to set, like # Build triple for the original snapshot compiler. This must be a compiler that
# nightlies are already produced for. The current platform must be able to run
# binaries of this build triple and the nightly will be used to bootstrap the
# first compiler.
#
# Defaults to platform where `x.py` is run.
build = "aarch64-apple-darwin" # because Rosetta confuses bootstrap and maybe # Instead of downloading the src/stage0.json version of Cargo specified, use
# this Cargo binary instead to build all Rust code
cargo = "/path/to/cargo" # bypassing downloads that might get the wrong compiler You will want to peruse the config.toml.example for the full list of options. It seems that https://github.com/rust-lang/rustc-dev-guide needs a PR listing explicit instructions for how to get aarch64-apple-darwin building, or we need a PR here to bootstrap to get aarch64-apple-darwin building "automatically". Either one. |
@workingjubilee is right, just because the My # Includes one of the default files in src/bootstrap/defaults
profile = "compiler"
# profile = "codegen"
changelog-seen = 2 Usually I just want a stage1 build which I get like so: $ ./x.py build -i library/std
[...]
Finished release [optimized] target(s) in 0.13s
Copying stage1 std from stage1 (aarch64-apple-darwin -> aarch64-apple-darwin / aarch64-apple-darwin)
Build completed successfully in ...
$ rustup toolchain link stage1 build/aarch64-apple-darwin/stage1
$ rustc +stage1 -vV
rustc 1.67.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: aarch64-apple-darwin
release: 1.67.0-dev
LLVM version: 15.0.4 I also haven't enabled Rosetta on this device so this is all native arm64. |
In that case I suppose the advisory of note is to suggest people try to actively not use Rosetta when compiling rustc. |
I haven't given it a try, but I wonder if setting the host/build triples to EDIT: Ok, looking at bootstrap it does seem like it should detect things properly. But if there's an existing |
@HarrisonMc555 Could you check the output of |
Thanks for your help, everyone! I made these changes to build = "aarch64-apple-darwin" # because Rosetta confuses bootstrap
# Instead of downloading the src/stage0.json version of Cargo specified, use
# this Cargo binary instead to build all Rust code
cargo = "/path/to/cargo" # bypassing downloausds that might get the wrong compiler And that worked! Thanks @workingjubilee! @luqmana here's what you asked for:
So that's weird. Where is my ... So I think I may have an idea about what happened. Previously, I had an Intel x86_64 MacBook. I then got a new M1 Apple Silicon MacBook. I used Apple's Time Machine to migrate everything from my old computer to my new computer. I had done Rust work on my previous laptop. So maybe the default stable toolchain was set to |
|
rustup
to detect the build triple on on Mac Apple Silicon M1 arm64
hmm. I remember @DebugSteven hit this same issue a while ago. I wonder if - on MacOS only - we should avoid inferring the build triple from rustup. I added it originally to detect windows-gnu vs windows-msvc, I hadn't considered Rosetta. |
Mentoring instructions: in rust/src/bootstrap/bootstrap.py Lines 205 to 224 in 39c6804
sys.platform == 'darwin' , skip the logic to run rustc --version --verbose and fallthrough directly to the logic that uses uname .
|
rustup
to detect the build triple on on Mac Apple Silicon M1 arm64rustc --version
to detect the build triple on on Mac Apple Silicon M1 arm64
For anyone else hitting this in the meantime, you can either set |
@rustbot claim |
TL;DR
I understand that Apple Silicon/M1/Arm is not supported as a tier 1 target. However, I was hoping that I would be able to compile the Rust compiler with Rosetta support. However, I could not do so.
Details
I did a fresh clone of the
rust
repository and tried to compile it by running./x.py
. However, it gave me the following errors:I expected to see this happen: I expected to be able to compile the Rust compiler on my machine.
Instead, this happened: I could not compile the Rust compiler on my machine.
I can see the warning that "building for macOS-x86_64 but attempting to link with file built for macOS-arm64". However, I don't know how to change that. I'm also a bit confused by the difference in reporting from the rust tools themselves vs. the
file
command. The tools themselves report "x86_64", but thefile
command reports "arm64".Meta
The text was updated successfully, but these errors were encountered: