Fix printing native CPU on cross-compiled compiler. #110668
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.