From 92b10819efecc0a2a638050d8fc8c9b2d2ad14d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:19:10 +0800 Subject: [PATCH 1/2] tidy: skip revision llvm-components check for run-make tests Since run-make tests do not support revisions. --- src/tools/tidy/src/target_specific_tests.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index 8be27d1e117..c1032b19f97 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -36,8 +36,8 @@ struct RevisionInfo<'a> { llvm_components: Option>, } -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, .. }| { @@ -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) { From beaf9d1c14122a55d71717560162c8123f5f23ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:20:32 +0800 Subject: [PATCH 2/2] tests/run-make: add missing needs-llvm-components Without suitable `needs-llvm-components` directives, these tests that rely on target-specific codegen can fail if used with a LLVM that is built without the required components. --- tests/run-make/print-cfg/rmake.rs | 5 +++++ tests/run-make/print-target-list/rmake.rs | 13 +++++++++---- tests/run-make/print-to-output/rmake.rs | 10 ++++++++-- tests/run-make/target-without-atomic-cas/rmake.rs | 15 ++++++++++----- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/tests/run-make/print-cfg/rmake.rs b/tests/run-make/print-cfg/rmake.rs index 471a99b90d9..7b8b760ea33 100644 --- a/tests/run-make/print-cfg/rmake.rs +++ b/tests/run-make/print-cfg/rmake.rs @@ -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; diff --git a/tests/run-make/print-target-list/rmake.rs b/tests/run-make/print-target-list/rmake.rs index 743ed52069d..04ef8440104 100644 --- a/tests/run-make/print-target-list/rmake.rs +++ b/tests/run-make/print-target-list/rmake.rs @@ -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. 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() { diff --git a/tests/run-make/print-to-output/rmake.rs b/tests/run-make/print-to-output/rmake.rs index db2a291f8e7..a85ab5e23b0 100644 --- a/tests/run-make/print-to-output/rmake.rs +++ b/tests/run-make/print-to-output/rmake.rs @@ -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; diff --git a/tests/run-make/target-without-atomic-cas/rmake.rs b/tests/run-make/target-without-atomic-cas/rmake.rs index c8782b6d1a5..e6c86c0c21d 100644 --- a/tests/run-make/target-without-atomic-cas/rmake.rs +++ b/tests/run-make/target-without-atomic-cas/rmake.rs @@ -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 . + +// 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;