summaryrefslogtreecommitdiffstats
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /src/tools/compiletest
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/common.rs28
-rw-r--r--src/tools/compiletest/src/header.rs20
-rw-r--r--src/tools/compiletest/src/main.rs29
-rw-r--r--src/tools/compiletest/src/runtest.rs35
-rw-r--r--src/tools/compiletest/src/util.rs6
5 files changed, 64 insertions, 54 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs
index 64df76e27..0260f6848 100644
--- a/src/tools/compiletest/src/common.rs
+++ b/src/tools/compiletest/src/common.rs
@@ -269,19 +269,15 @@ pub struct Config {
pub runtool: Option<String>,
/// Flags to pass to the compiler when building for the host
- pub host_rustcflags: Option<String>,
+ pub host_rustcflags: Vec<String>,
/// Flags to pass to the compiler when building for the target
- pub target_rustcflags: Option<String>,
+ pub target_rustcflags: Vec<String>,
/// Whether tests should be optimized by default. Individual test-suites and test files may
/// override this setting.
pub optimize_tests: bool,
- /// What panic strategy the target is built with. Unwind supports Abort, but
- /// not vice versa.
- pub target_panic: PanicStrategy,
-
/// Target system to be tested
pub target: String,
@@ -389,7 +385,8 @@ impl Config {
}
fn target_cfg(&self) -> &TargetCfg {
- self.target_cfg.borrow_with(|| TargetCfg::new(&self.rustc_path, &self.target))
+ self.target_cfg
+ .borrow_with(|| TargetCfg::new(&self.rustc_path, &self.target, &self.target_rustcflags))
}
pub fn matches_arch(&self, arch: &str) -> bool {
@@ -426,6 +423,10 @@ impl Config {
*&self.target_cfg().pointer_width
}
+ pub fn can_unwind(&self) -> bool {
+ self.target_cfg().panic == PanicStrategy::Unwind
+ }
+
pub fn has_asm_support(&self) -> bool {
static ASM_SUPPORTED_ARCHS: &[&str] = &[
"x86", "x86_64", "arm", "aarch64", "riscv32",
@@ -446,6 +447,7 @@ pub struct TargetCfg {
families: Vec<String>,
pointer_width: u32,
endian: Endian,
+ panic: PanicStrategy,
}
#[derive(Eq, PartialEq, Clone, Debug)]
@@ -455,11 +457,12 @@ pub enum Endian {
}
impl TargetCfg {
- fn new(rustc_path: &Path, target: &str) -> TargetCfg {
+ fn new(rustc_path: &Path, target: &str, target_rustcflags: &Vec<String>) -> TargetCfg {
let output = match Command::new(rustc_path)
.arg("--print=cfg")
.arg("--target")
.arg(target)
+ .args(target_rustcflags)
.output()
{
Ok(output) => output,
@@ -481,6 +484,7 @@ impl TargetCfg {
let mut families = Vec::new();
let mut pointer_width = None;
let mut endian = None;
+ let mut panic = None;
for line in print_cfg.lines() {
if let Some((name, value)) = line.split_once('=') {
let value = value.trim_matches('"');
@@ -498,6 +502,13 @@ impl TargetCfg {
s => panic!("unexpected {s}"),
})
}
+ "panic" => {
+ panic = match value {
+ "abort" => Some(PanicStrategy::Abort),
+ "unwind" => Some(PanicStrategy::Unwind),
+ s => panic!("unexpected {s}"),
+ }
+ }
_ => {}
}
}
@@ -510,6 +521,7 @@ impl TargetCfg {
families,
pointer_width: pointer_width.unwrap(),
endian: endian.unwrap(),
+ panic: panic.unwrap(),
}
}
}
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 3ff1cbf20..0d9a629e1 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -4,10 +4,11 @@ use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::{Path, PathBuf};
+use std::process::Command;
use tracing::*;
-use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PanicStrategy, PassMode};
+use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PassMode};
use crate::util;
use crate::{extract_cdb_version, extract_gdb_version};
@@ -843,6 +844,20 @@ pub fn extract_llvm_version(version: &str) -> Option<u32> {
Some(version)
}
+pub fn extract_llvm_version_from_binary(binary_path: &str) -> Option<u32> {
+ let output = Command::new(binary_path).arg("--version").output().ok()?;
+ if !output.status.success() {
+ return None;
+ }
+ let version = String::from_utf8(output.stdout).ok()?;
+ for line in version.lines() {
+ if let Some(version) = line.split("LLVM version ").skip(1).next() {
+ return extract_llvm_version(version);
+ }
+ }
+ None
+}
+
/// Takes a directive of the form "<version1> [- <version2>]",
/// returns the numeric representation of <version1> and <version2> as
/// tuple: (<version1> as u32, <version2> as u32)
@@ -949,8 +964,7 @@ pub fn make_test_description<R: Read>(
ignore |= !has_memtag && config.parse_name_directive(ln, "needs-sanitizer-memtag");
ignore |= !has_shadow_call_stack
&& config.parse_name_directive(ln, "needs-sanitizer-shadow-call-stack");
- ignore |= config.target_panic == PanicStrategy::Abort
- && config.parse_name_directive(ln, "needs-unwind");
+ ignore |= !config.can_unwind() && config.parse_name_directive(ln, "needs-unwind");
ignore |= config.target == "wasm32-unknown-unknown"
&& config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS);
ignore |= config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln);
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 38c7b87fc..19cf54780 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -5,9 +5,7 @@
extern crate test;
-use crate::common::{
- expected_output_path, output_base_dir, output_relative_path, PanicStrategy, UI_EXTENSIONS,
-};
+use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, TestPaths};
use crate::util::logv;
use getopts::Options;
@@ -105,7 +103,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
.optmulti("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS")
.optmulti("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS")
.optflag("", "optimize-tests", "run tests with optimizations enabled")
- .optopt("", "target-panic", "what panic strategy the target supports", "unwind | abort")
.optflag("", "verbose", "run tests verbosely, showing all output")
.optflag(
"",
@@ -203,7 +200,9 @@ pub fn parse_config(args: Vec<String>) -> Config {
Some(x) => panic!("argument for --color must be auto, always, or never, but found `{}`", x),
};
let llvm_version =
- matches.opt_str("llvm-version").as_deref().and_then(header::extract_llvm_version);
+ matches.opt_str("llvm-version").as_deref().and_then(header::extract_llvm_version).or_else(
+ || header::extract_llvm_version_from_binary(&matches.opt_str("llvm-filecheck")?),
+ );
let src_base = opt_path(matches, "src-base");
let run_ignored = matches.opt_present("ignored");
@@ -255,14 +254,9 @@ pub fn parse_config(args: Vec<String>) -> Config {
}),
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
runtool: matches.opt_str("runtool"),
- host_rustcflags: Some(matches.opt_strs("host-rustcflags").join(" ")),
- target_rustcflags: Some(matches.opt_strs("target-rustcflags").join(" ")),
+ host_rustcflags: matches.opt_strs("host-rustcflags"),
+ target_rustcflags: matches.opt_strs("target-rustcflags"),
optimize_tests: matches.opt_present("optimize-tests"),
- target_panic: match matches.opt_str("target-panic").as_deref() {
- Some("unwind") | None => PanicStrategy::Unwind,
- Some("abort") => PanicStrategy::Abort,
- _ => panic!("unknown `--target-panic` option `{}` given", mode),
- },
target,
host: opt_str2(matches.opt_str("host")),
cdb,
@@ -328,8 +322,8 @@ pub fn log_config(config: &Config) {
format!("force_pass_mode: {}", opt_str(&config.force_pass_mode.map(|m| format!("{}", m))),),
);
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
- logv(c, format!("host-rustcflags: {}", opt_str(&config.host_rustcflags)));
- logv(c, format!("target-rustcflags: {}", opt_str(&config.target_rustcflags)));
+ logv(c, format!("host-rustcflags: {:?}", config.host_rustcflags));
+ logv(c, format!("target-rustcflags: {:?}", config.target_rustcflags));
logv(c, format!("target: {}", config.target));
logv(c, format!("host: {}", config.host));
logv(c, format!("android-cross-path: {:?}", config.android_cross_path.display()));
@@ -403,6 +397,8 @@ pub fn run_tests(config: Config) {
make_tests(c, &mut tests);
}
+ tests.sort_by(|a, b| a.desc.name.as_slice().cmp(&b.desc.name.as_slice()));
+
let res = test::run_tests_console(&opts, tests);
match res {
Ok(true) => {}
@@ -805,7 +801,10 @@ fn make_test_closure(
let config = config.clone();
let testpaths = testpaths.clone();
let revision = revision.cloned();
- test::DynTestFn(Box::new(move || runtest::run(config, &testpaths, revision.as_deref())))
+ test::DynTestFn(Box::new(move || {
+ runtest::run(config, &testpaths, revision.as_deref());
+ Ok(())
+ }))
}
/// Returns `true` if the given target is an Android target for the
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 8f289876f..8af5f1da6 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -558,10 +558,7 @@ impl<'test> TestCx<'test> {
.arg(&aux_dir)
.args(&self.props.compile_flags)
.envs(self.props.rustc_env.clone());
- self.maybe_add_external_args(
- &mut rustc,
- self.split_maybe_args(&self.config.target_rustcflags),
- );
+ self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
let src = match read_from {
ReadFrom::Stdin(src) => Some(src),
@@ -629,10 +626,7 @@ impl<'test> TestCx<'test> {
.arg("-L")
.arg(aux_dir);
self.set_revision_flags(&mut rustc);
- self.maybe_add_external_args(
- &mut rustc,
- self.split_maybe_args(&self.config.target_rustcflags),
- );
+ self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
rustc.args(&self.props.compile_flags);
self.compose_and_run_compiler(rustc, Some(src))
@@ -1186,23 +1180,14 @@ impl<'test> TestCx<'test> {
ProcRes { status, stdout: out, stderr: err, cmdline: format!("{:?}", cmd) }
}
- fn cleanup_debug_info_options(&self, options: &Option<String>) -> Option<String> {
- if options.is_none() {
- return None;
- }
-
+ fn cleanup_debug_info_options(&self, options: &Vec<String>) -> Vec<String> {
// Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS.
let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()];
- let new_options = self
- .split_maybe_args(options)
- .into_iter()
- .filter(|x| !options_to_remove.contains(x))
- .collect::<Vec<String>>();
- Some(new_options.join(" "))
+ options.iter().filter(|x| !options_to_remove.contains(x)).map(|x| x.clone()).collect()
}
- fn maybe_add_external_args(&self, cmd: &mut Command, args: Vec<String>) {
+ fn maybe_add_external_args(&self, cmd: &mut Command, args: &Vec<String>) {
// Filter out the arguments that should not be added by runtest here.
//
// Notable use-cases are: do not add our optimisation flag if
@@ -2035,15 +2020,9 @@ impl<'test> TestCx<'test> {
}
if self.props.force_host {
- self.maybe_add_external_args(
- &mut rustc,
- self.split_maybe_args(&self.config.host_rustcflags),
- );
+ self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags);
} else {
- self.maybe_add_external_args(
- &mut rustc,
- self.split_maybe_args(&self.config.target_rustcflags),
- );
+ self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
if !is_rustdoc {
if let Some(ref linker) = self.config.linker {
rustc.arg(format!("-Clinker={}", linker));
diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs
index 9d047b63c..e5ff0906b 100644
--- a/src/tools/compiletest/src/util.rs
+++ b/src/tools/compiletest/src/util.rs
@@ -11,9 +11,15 @@ mod tests;
pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[
"aarch64-apple-darwin",
"aarch64-fuchsia",
+ "aarch64-linux-android",
"aarch64-unknown-linux-gnu",
+ "arm-linux-androideabi",
+ "armv7-linux-androideabi",
+ "i686-linux-android",
+ "i686-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-fuchsia",
+ "x86_64-linux-android",
"x86_64-unknown-freebsd",
"x86_64-unknown-linux-gnu",
];