Skip to content
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

Add missing needs-llvm-components directives for run-make tests that need target-specific codegen #129605

Merged
merged 2 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/tools/tidy/src/target_specific_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct RevisionInfo<'a> {
llvm_components: Option<Vec<&'a str>>,
}

pub fn check(path: &Path, bad: &mut bool) {
crate::walk::walk(path, |path, _is_dir| filter_not_rust(path), &mut |entry, content| {
pub fn check(tests_path: &Path, bad: &mut bool) {
crate::walk::walk(tests_path, |path, _is_dir| filter_not_rust(path), &mut |entry, content| {
let file = entry.path().display();
let mut header_map = BTreeMap::new();
iter_header(content, &mut |HeaderLine { revision, directive, .. }| {
Expand Down Expand Up @@ -65,6 +65,12 @@ pub fn check(path: &Path, bad: &mut bool) {
}
}
});

// Skip run-make tests as revisions are not supported.
if entry.path().strip_prefix(tests_path).is_ok_and(|rest| rest.starts_with("run-make")) {
return;
}

for (rev, RevisionInfo { target_arch, llvm_components }) in &header_map {
let rev = rev.unwrap_or("[unspecified]");
match (target_arch, llvm_components) {
Expand Down
5 changes: 5 additions & 0 deletions tests/run-make/print-cfg/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
//!
//! It also checks that some targets have the correct set cfgs.

// ignore-tidy-linelength
//@ needs-llvm-components: arm x86
// Note: without the needs-llvm-components it will fail on LLVM built without the required
// components listed above.

use std::collections::HashSet;
use std::iter::FromIterator;
use std::path::PathBuf;
Expand Down
13 changes: 9 additions & 4 deletions tests/run-make/print-target-list/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// Checks that all the targets returned by `rustc --print target-list` are valid
// target specifications
// Checks that all the targets returned by `rustc --print target-list` are valid target
// specifications.

// ignore-tidy-linelength
//@ needs-llvm-components: aarch64 arm avr bpf csky hexagon loongarch m68k mips msp430 nvptx powerpc riscv sparc systemz webassembly x86
// FIXME(jieyouxu): there has to be a better way to do this, without the needs-llvm-components it
// will fail on LLVM built without all of the components listed above.

Comment on lines +5 to +7
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this, but I also am not sure if there's a better way

Copy link
Member

@cuviper cuviper Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rustc should be filtering this before printing targets anyway? Or else it could do a better job of avoiding LLVM initialization when it's not really needed -- e.g. I see no reason why --print sysroot should care.

That might also help coreos/cargo-vendor-filterer#87

use run_make_support::bare_rustc;

// FIXME(127877): certain experimental targets fail with creating a 'LLVM TargetMachine'
// in CI, so we skip them
// FIXME(#127877): certain experimental targets fail with creating a 'LLVM TargetMachine' in CI, so
// we skip them.
const EXPERIMENTAL_TARGETS: &[&str] = &["avr", "m68k", "csky", "xtensa"];

fn main() {
Expand Down
10 changes: 8 additions & 2 deletions tests/run-make/print-to-output/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
//! This checks the output of some `--print` options when
//! output to a file (instead of stdout)
//! This checks the output of some `--print` options when output to a file (instead of stdout)

// ignore-tidy-linelength
//@ needs-llvm-components: aarch64 arm avr bpf csky hexagon loongarch m68k mips msp430 nvptx powerpc riscv sparc systemz webassembly x86
// FIXME(jieyouxu): there has to be a better way to do this, without the needs-llvm-components it
// will fail on LLVM built without all of the components listed above. If adding a new target that
// relies on a llvm component not listed above, it will need to be added to the required llvm
// components above.

use std::path::PathBuf;

Expand Down
15 changes: 10 additions & 5 deletions tests/run-make/target-without-atomic-cas/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// ARM Cortex-M are a class of processors supported by the rust compiler. However,
// they cannot support any atomic features, such as Arc. This test simply prints
// the configuration details of one Cortex target, and checks that the compiler
// does not falsely list atomic support.
// See https://github.com/rust-lang/rust/pull/36874
// ARM Cortex-M are a class of processors supported by the rust compiler. However, they cannot
// support any atomic features, such as Arc. This test simply prints the configuration details of
// one Cortex target, and checks that the compiler does not falsely list atomic support.
// See <https://github.com/rust-lang/rust/pull/36874>.

// ignore-tidy-linelength
//@ needs-llvm-components: arm
// Note: without the needs-llvm-components it will fail on LLVM built without all of the components
// listed above. If any new targets are added, please double-check their respective llvm components
// are specified above.

use run_make_support::rustc;

Expand Down
Loading