-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Port most of --print=target-cpus
to Rust
#132514
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//@ ignore-cross-compile | ||
//@ needs-llvm-components: aarch64 x86 | ||
// FIXME(#132514): Is needs-llvm-components actually necessary for this test? | ||
|
||
use run_make_support::{assert_contains_regex, rfs, rustc, target}; | ||
|
||
// Test that when querying `--print=target-cpus` for a target with the same | ||
// architecture as the host, the first CPU is "native" with a suitable remark. | ||
|
||
fn main() { | ||
let expected = r"^Available CPUs for this target: | ||
native +- Select the CPU of the current host \(currently [^ )]+\)\. | ||
"; | ||
|
||
// Without an explicit target. | ||
rustc().print("target-cpus").run().assert_stdout_contains_regex(expected); | ||
|
||
// With an explicit target that happens to be the host. | ||
let host = target(); // Because of ignore-cross-compile, assume host == target. | ||
rustc().print("target-cpus").target(host).run().assert_stdout_contains_regex(expected); | ||
|
||
// With an explicit output path. | ||
rustc().print("target-cpus=./xyzzy.txt").run().assert_stdout_equals(""); | ||
assert_contains_regex(rfs::read_to_string("./xyzzy.txt"), expected); | ||
|
||
// Now try some cross-target queries with the same arch as the host. | ||
// (Specify multiple targets so that at least one of them is not the host.) | ||
let cross_targets: &[&str] = if cfg!(target_arch = "aarch64") { | ||
&["aarch64-unknown-linux-gnu", "aarch64-apple-darwin"] | ||
} else if cfg!(target_arch = "x86_64") { | ||
&["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"] | ||
} else { | ||
&[] | ||
}; | ||
for target in cross_targets { | ||
println!("Trying target: {target}"); | ||
rustc().print("target-cpus").target(target).run().assert_stdout_contains_regex(expected); | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: ... would this need
needs-llvm-component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure.
My guess is no, because it's guaranteed by
ignore-cross-compile
that we at least have the relevant arch component for the host system, and we're only testing other targets with the same arch as the host.But I know very little about LLVM components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked because I have dealt with run-make tests that seemed innocent (like see #129390). Apparently even
--print=target-list
needed relevant llvm components to be available.So I think we should have the
//@ needs-llvm-components
for the cross-compiled targets: usually we have them (e.g. CI LLVM or locally), so it would be trivially satisfied.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the condition will usually be true in CI and locally, then I don't mind adding the directive as a precaution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's mostly just that some contributors do build local llvms without unneeded components.