Change:
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. I did a fresh clone of the repository and tried to compile it by running . 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-x8664 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 command. The tools themselves report "x8664", but the command reports "arm64". <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
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 through , so please use that instead of... suffering through these shenanigans.
, 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 and everything like that. I wanted to get to work because I was interested in contributing to the compiler itself. 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 It has various options, which you probably want to set, like and maybe You will want to peruse the for the full list of options. It seems that 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.
is right, just because the target isn't tier 1 doesn't mean you can't build it. I build rust on an m1 mac every so often without any thing special. My Usually I just want a stage1 build which I get like so: 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 in would be enough. In any case, seems like something the build tooling should handle automatically. EDIT: Ok, looking at bootstrap it does seem like it should detect things properly. But if there's an existing installed (e.g. from rustup) it will use whatever host triple that was configured with, otherwise it does -based auto detection. Running with the verbose flag should output either "detected default triple ... from pre-installed rustc" or "falling back to auto-detect", respectively.
Could you check the output of ? The in is just a wrapper. It's possible your default toolchain is the version, hence the mismatch.
Thanks for your help, everyone! I made these changes to And that worked! Thanks here's what you asked for: So that's weird. Where is my coming from? And why does it get to be an executable, while the version is ? ... So I think I may have an idea about what happened. Previously, I had an Intel x8664 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 , which was correct for the previous computer, and never got updated when I migrated to the new computer? Does that seem plausible?
(and cargo there) is from rustup and is just a wrapper that enables the or conveniences.
hmm. I remember hit this same issue a while ago. I wonder if - on MacOS only - we should avoid inferring the build triple from rustup. I it originally to detect windows-gnu vs windows-msvc, I hadn't considered Rosetta.
Mentoring instructions: in , if , skip the logic to run and fallthrough directly to the logic that uses .
For anyone else hitting this in the meantime, you can either set as suggested by Jubilee, or change your default rustup host triple: .
claim

Discussion:
# install, use their preference. This fixes most issues with Windows builds # being detected as GNU instead of MSVC. default_encoding = sys.getdefaultencoding() <del> try: version = subprocess.check_output(["rustc", "--version", "--verbose"], stderr=subprocess.DEVNULL) version = version.decode(default_encoding) host = next(x for x in version.split('n') if x.startswith("host: ")) triple = host.split("host: ")[1] if verbose: print("detected default triple {} from pre-installed rustc".format(triple)) return triple except Exception as e: </del> <ins> if sys.platform == 'darwin': </ins> if verbose: <del> print("pre-installed rustc not detected: {}".format(e)) </del> <ins> print("not using rustc detection as it is unreliable on macOS") </ins> print("falling back to auto-detect") <ins> else: try: version = subprocess.check_output(["rustc", "--version", "--verbose"], stderr=subprocess.DEVNULL) version = version.decode(default_encoding) host = next(x for x in version.split('n') if x.startswith("host: ")) triple = host.split("host: ")[1] if verbose: print("detected default triple {} from pre-installed rustc".format(triple)) return triple except Exception as e: if verbose: print("pre-installed rustc not detected: {}".format(e)) print("falling back to auto-detect") </ins> required = sys.platform != 'win32' ostype = require(["uname", "-s"], exit=required)