-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Fix printing native CPU on cross-compiled compiler. #110668
Conversation
r? @cuviper (rustbot has picked a reviewer for you, use r? to override) |
That's amusing, e.g. from an aarch64-linux host I can get this mismatch:
... because the toolchain was built in Rust CI on x86_64, so it thinks native is a match and reports the aarch64 CPU. It seems this is an LLVM bug: // FIXME: getProcessTriple is bogus. It returns the host LLVM was compiled on,
// rather than a valid triple for the current process. I think the default target is not necessarily the runtime host either, if you had an LLVM configured as a cross-compiler by default, but it's probably more often correct. |
7629401
to
e4e4110
Compare
@bors r+ rollup |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#110661 (rustdoc: clean up settings.css and settings.js) - rust-lang#110663 (Add note about change in bootstrap defaults) - rust-lang#110664 (stop `x fmt` formatting untracked directories) - rust-lang#110668 (Fix printing native CPU on cross-compiled compiler.) - rust-lang#110689 (Fix grammar in core::hint::unreachable_unchecked() docs) - rust-lang#110700 (Don't infer fn return type to return itself) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
If
rustc
is cross-compiled from a different host, then the "native" entry inrustc --print=target-cpus
would not appear. There is a check in the printing code that will avoid printing the "native" entry if the user has passed--target
. However, that check was comparing the--target
value with theLLVM_TARGET_TRIPLE
which is the triple of the host thatrustc
was built on (the "build" target in Rust lingo), not the target it was being built for (the "host" in Rust lingo). This fixes it to use the target that LLVM was built for (which I'm pretty sure this is the correct function to determine that).This fixes the cpu listing for aarch64-apple-darwin which is built on CI using the x86_64-apple-darwin host.