2023-01-05 11:57:35 -06:00
|
|
|
use super::build_sysroot::{self, SYSROOT_SRC};
|
2022-08-24 11:40:58 -05:00
|
|
|
use super::config;
|
2022-12-01 08:54:37 -06:00
|
|
|
use super::path::{Dirs, RelPath};
|
2022-10-26 09:51:03 -05:00
|
|
|
use super::prepare::GitRepo;
|
2023-01-14 06:53:33 -06:00
|
|
|
use super::rustc_info::get_host_triple;
|
2023-01-05 11:57:35 -06:00
|
|
|
use super::utils::{spawn_and_wait, spawn_and_wait_with_input, CargoProject, Compiler};
|
2022-10-28 04:54:05 -05:00
|
|
|
use super::SysrootKind;
|
2022-08-24 11:40:58 -05:00
|
|
|
use std::env;
|
|
|
|
use std::ffi::OsStr;
|
|
|
|
use std::fs;
|
2022-12-01 07:30:03 -06:00
|
|
|
use std::path::Path;
|
2022-08-24 11:40:58 -05:00
|
|
|
use std::process::Command;
|
|
|
|
|
2022-12-01 07:30:03 -06:00
|
|
|
static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example");
|
|
|
|
|
2022-08-24 11:40:58 -05:00
|
|
|
struct TestCase {
|
|
|
|
config: &'static str,
|
2023-01-13 08:19:54 -06:00
|
|
|
cmd: TestCaseCmd,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TestCaseCmd {
|
|
|
|
Custom { func: &'static dyn Fn(&TestRunner) },
|
|
|
|
BuildLib { source: &'static str, crate_types: &'static str },
|
|
|
|
BuildBinAndRun { source: &'static str, args: &'static [&'static str] },
|
|
|
|
JitBin { source: &'static str, args: &'static str },
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl TestCase {
|
2023-01-13 08:19:54 -06:00
|
|
|
// FIXME reduce usage of custom test case commands
|
|
|
|
const fn custom(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
|
|
|
|
Self { config, cmd: TestCaseCmd::Custom { func } }
|
|
|
|
}
|
|
|
|
|
|
|
|
const fn build_lib(
|
|
|
|
config: &'static str,
|
|
|
|
source: &'static str,
|
|
|
|
crate_types: &'static str,
|
|
|
|
) -> Self {
|
|
|
|
Self { config, cmd: TestCaseCmd::BuildLib { source, crate_types } }
|
|
|
|
}
|
|
|
|
|
|
|
|
const fn build_bin_and_run(
|
|
|
|
config: &'static str,
|
|
|
|
source: &'static str,
|
|
|
|
args: &'static [&'static str],
|
|
|
|
) -> Self {
|
|
|
|
Self { config, cmd: TestCaseCmd::BuildBinAndRun { source, args } }
|
|
|
|
}
|
|
|
|
|
|
|
|
const fn jit_bin(config: &'static str, source: &'static str, args: &'static str) -> Self {
|
|
|
|
Self { config, cmd: TestCaseCmd::JitBin { source, args } }
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const NO_SYSROOT_SUITE: &[TestCase] = &[
|
2023-01-13 08:19:54 -06:00
|
|
|
TestCase::build_lib("build.mini_core", "example/mini_core.rs", "lib,dylib"),
|
|
|
|
TestCase::build_lib("build.example", "example/example.rs", "lib"),
|
|
|
|
TestCase::jit_bin("jit.mini_core_hello_world", "example/mini_core_hello_world.rs", "abc bcd"),
|
|
|
|
TestCase::build_bin_and_run(
|
|
|
|
"aot.mini_core_hello_world",
|
|
|
|
"example/mini_core_hello_world.rs",
|
|
|
|
&["abc", "bcd"],
|
|
|
|
),
|
2022-08-24 11:40:58 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
const BASE_SYSROOT_SUITE: &[TestCase] = &[
|
2023-01-13 08:19:54 -06:00
|
|
|
TestCase::build_bin_and_run(
|
|
|
|
"aot.arbitrary_self_types_pointers_and_wrappers",
|
|
|
|
"example/arbitrary_self_types_pointers_and_wrappers.rs",
|
|
|
|
&[],
|
|
|
|
),
|
|
|
|
TestCase::build_bin_and_run(
|
|
|
|
"aot.issue_91827_extern_types",
|
|
|
|
"example/issue-91827-extern-types.rs",
|
|
|
|
&[],
|
|
|
|
),
|
|
|
|
TestCase::build_lib("build.alloc_system", "example/alloc_system.rs", "lib"),
|
|
|
|
TestCase::build_bin_and_run("aot.alloc_example", "example/alloc_example.rs", &[]),
|
|
|
|
TestCase::jit_bin("jit.std_example", "example/std_example.rs", ""),
|
|
|
|
TestCase::build_bin_and_run("aot.std_example", "example/std_example.rs", &["arg"]),
|
|
|
|
TestCase::build_bin_and_run("aot.dst_field_align", "example/dst-field-align.rs", &[]),
|
|
|
|
TestCase::build_bin_and_run(
|
|
|
|
"aot.subslice-patterns-const-eval",
|
|
|
|
"example/subslice-patterns-const-eval.rs",
|
|
|
|
&[],
|
|
|
|
),
|
|
|
|
TestCase::build_bin_and_run(
|
|
|
|
"aot.track-caller-attribute",
|
|
|
|
"example/track-caller-attribute.rs",
|
|
|
|
&[],
|
|
|
|
),
|
|
|
|
TestCase::build_bin_and_run("aot.float-minmax-pass", "example/float-minmax-pass.rs", &[]),
|
|
|
|
TestCase::build_bin_and_run("aot.mod_bench", "example/mod_bench.rs", &[]),
|
|
|
|
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
|
2022-08-24 11:40:58 -05:00
|
|
|
];
|
|
|
|
|
2022-10-26 09:51:03 -05:00
|
|
|
pub(crate) static RAND_REPO: GitRepo =
|
|
|
|
GitRepo::github("rust-random", "rand", "0f933f9c7176e53b2a3c7952ded484e1783f0bf1", "rand");
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2023-01-13 09:40:22 -06:00
|
|
|
pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand");
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2022-10-26 09:51:03 -05:00
|
|
|
pub(crate) static REGEX_REPO: GitRepo =
|
|
|
|
GitRepo::github("rust-lang", "regex", "341f207c1071f7290e3f228c710817c280c8dca1", "regex");
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2023-01-13 09:40:22 -06:00
|
|
|
pub(crate) static REGEX: CargoProject = CargoProject::new(®EX_REPO.source_dir(), "regex");
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2022-10-26 09:51:03 -05:00
|
|
|
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
|
|
|
|
"rust-lang",
|
|
|
|
"portable-simd",
|
2023-02-19 11:46:51 -06:00
|
|
|
"9bd30e77b3a3c699af102ebb3df0f6110f8aa02e",
|
2022-10-26 09:51:03 -05:00
|
|
|
"portable-simd",
|
|
|
|
);
|
2022-08-28 12:41:36 -05:00
|
|
|
|
2023-01-13 09:40:22 -06:00
|
|
|
pub(crate) static PORTABLE_SIMD: CargoProject =
|
2022-12-01 07:30:03 -06:00
|
|
|
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd");
|
2022-08-28 11:38:09 -05:00
|
|
|
|
2023-01-13 09:40:22 -06:00
|
|
|
pub(crate) static LIBCORE_TESTS: CargoProject =
|
2023-01-05 11:26:54 -06:00
|
|
|
CargoProject::new(&SYSROOT_SRC.join("library/core/tests"), "core_tests");
|
2022-10-26 09:51:03 -05:00
|
|
|
|
|
|
|
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
2023-01-13 08:19:54 -06:00
|
|
|
TestCase::custom("test.rust-random/rand", &|runner| {
|
2023-01-14 06:36:56 -06:00
|
|
|
RAND.clean(&runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
|
|
|
|
if runner.is_native {
|
|
|
|
eprintln!("[TEST] rust-random/rand");
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut test_cmd = RAND.test(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
test_cmd.arg("--workspace");
|
|
|
|
spawn_and_wait(test_cmd);
|
|
|
|
} else {
|
|
|
|
eprintln!("[AOT] rust-random/rand");
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut build_cmd = RAND.build(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
build_cmd.arg("--workspace").arg("--tests");
|
|
|
|
spawn_and_wait(build_cmd);
|
|
|
|
}
|
2022-08-24 11:40:58 -05:00
|
|
|
}),
|
2023-01-13 08:19:54 -06:00
|
|
|
TestCase::custom("test.libcore", &|runner| {
|
2023-01-14 06:36:56 -06:00
|
|
|
LIBCORE_TESTS.clean(&runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
|
|
|
|
if runner.is_native {
|
2023-02-25 11:48:45 -06:00
|
|
|
let mut test_cmd = LIBCORE_TESTS.test(&runner.target_compiler, &runner.dirs);
|
|
|
|
test_cmd.arg("--").arg("-q");
|
|
|
|
spawn_and_wait(test_cmd);
|
2022-10-26 09:51:03 -05:00
|
|
|
} else {
|
|
|
|
eprintln!("Cross-Compiling: Not running tests");
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut build_cmd = LIBCORE_TESTS.build(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
build_cmd.arg("--tests");
|
|
|
|
spawn_and_wait(build_cmd);
|
|
|
|
}
|
2022-08-24 11:40:58 -05:00
|
|
|
}),
|
2023-01-13 08:19:54 -06:00
|
|
|
TestCase::custom("test.regex-shootout-regex-dna", &|runner| {
|
2023-01-14 06:36:56 -06:00
|
|
|
REGEX.clean(&runner.dirs);
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2022-10-26 09:51:03 -05:00
|
|
|
// newer aho_corasick versions throw a deprecation warning
|
|
|
|
let lint_rust_flags = format!("{} --cap-lints warn", runner.target_compiler.rustflags);
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
build_cmd.arg("--example").arg("shootout-regex-dna");
|
|
|
|
build_cmd.env("RUSTFLAGS", lint_rust_flags.clone());
|
|
|
|
spawn_and_wait(build_cmd);
|
|
|
|
|
|
|
|
if runner.is_native {
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut run_cmd = REGEX.run(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
run_cmd.arg("--example").arg("shootout-regex-dna");
|
|
|
|
run_cmd.env("RUSTFLAGS", lint_rust_flags);
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2022-12-01 08:54:37 -06:00
|
|
|
let input = fs::read_to_string(
|
|
|
|
REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-input.txt"),
|
|
|
|
)
|
|
|
|
.unwrap();
|
2023-01-13 09:14:04 -06:00
|
|
|
let expected = fs::read_to_string(
|
|
|
|
REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-output.txt"),
|
|
|
|
)
|
|
|
|
.unwrap();
|
2022-10-26 09:51:03 -05:00
|
|
|
|
|
|
|
let output = spawn_and_wait_with_input(run_cmd, input);
|
|
|
|
// Make sure `[codegen mono items] start` doesn't poison the diff
|
|
|
|
let output = output
|
|
|
|
.lines()
|
|
|
|
.filter(|line| !line.contains("codegen mono items"))
|
|
|
|
.chain(Some("")) // This just adds the trailing newline
|
|
|
|
.collect::<Vec<&str>>()
|
|
|
|
.join("\r\n");
|
|
|
|
|
|
|
|
let output_matches = expected.lines().eq(output.lines());
|
|
|
|
if !output_matches {
|
2023-01-13 09:14:04 -06:00
|
|
|
println!("Output files don't match!");
|
|
|
|
println!("Expected Output:\n{}", expected);
|
|
|
|
println!("Actual Output:\n{}", output);
|
2022-10-26 09:51:03 -05:00
|
|
|
|
|
|
|
std::process::exit(1);
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
2022-10-26 09:51:03 -05:00
|
|
|
}
|
2022-08-24 11:40:58 -05:00
|
|
|
}),
|
2023-01-13 08:19:54 -06:00
|
|
|
TestCase::custom("test.regex", &|runner| {
|
2023-01-14 06:36:56 -06:00
|
|
|
REGEX.clean(&runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
|
|
|
|
// newer aho_corasick versions throw a deprecation warning
|
|
|
|
let lint_rust_flags = format!("{} --cap-lints warn", runner.target_compiler.rustflags);
|
|
|
|
|
|
|
|
if runner.is_native {
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
run_cmd.args([
|
|
|
|
"--tests",
|
|
|
|
"--",
|
|
|
|
"--exclude-should-panic",
|
|
|
|
"--test-threads",
|
|
|
|
"1",
|
|
|
|
"-Zunstable-options",
|
|
|
|
"-q",
|
|
|
|
]);
|
|
|
|
run_cmd.env("RUSTFLAGS", lint_rust_flags);
|
|
|
|
spawn_and_wait(run_cmd);
|
|
|
|
} else {
|
|
|
|
eprintln!("Cross-Compiling: Not running tests");
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
build_cmd.arg("--tests");
|
|
|
|
build_cmd.env("RUSTFLAGS", lint_rust_flags.clone());
|
|
|
|
spawn_and_wait(build_cmd);
|
|
|
|
}
|
2022-08-24 11:40:58 -05:00
|
|
|
}),
|
2023-01-13 08:19:54 -06:00
|
|
|
TestCase::custom("test.portable-simd", &|runner| {
|
2023-01-14 06:36:56 -06:00
|
|
|
PORTABLE_SIMD.clean(&runner.dirs);
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut build_cmd = PORTABLE_SIMD.build(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
build_cmd.arg("--all-targets");
|
|
|
|
spawn_and_wait(build_cmd);
|
|
|
|
|
|
|
|
if runner.is_native {
|
2022-12-01 08:54:37 -06:00
|
|
|
let mut test_cmd = PORTABLE_SIMD.test(&runner.target_compiler, &runner.dirs);
|
2022-10-26 09:51:03 -05:00
|
|
|
test_cmd.arg("-q");
|
|
|
|
spawn_and_wait(test_cmd);
|
|
|
|
}
|
2022-08-24 11:40:58 -05:00
|
|
|
}),
|
|
|
|
];
|
|
|
|
|
|
|
|
pub(crate) fn run_tests(
|
2022-12-01 08:54:37 -06:00
|
|
|
dirs: &Dirs,
|
2022-08-24 11:40:58 -05:00
|
|
|
channel: &str,
|
|
|
|
sysroot_kind: SysrootKind,
|
2022-08-28 11:46:09 -05:00
|
|
|
cg_clif_dylib: &Path,
|
2023-01-14 06:53:33 -06:00
|
|
|
bootstrap_host_compiler: &Compiler,
|
2023-01-14 07:04:40 -06:00
|
|
|
target_triple: String,
|
2022-08-24 11:40:58 -05:00
|
|
|
) {
|
|
|
|
if config::get_bool("testsuite.no_sysroot") {
|
2023-01-14 07:04:40 -06:00
|
|
|
let target_compiler = build_sysroot::build_sysroot(
|
2022-12-01 08:54:37 -06:00
|
|
|
dirs,
|
2022-08-24 11:40:58 -05:00
|
|
|
channel,
|
|
|
|
SysrootKind::None,
|
2022-08-28 11:46:09 -05:00
|
|
|
cg_clif_dylib,
|
2023-01-14 06:53:33 -06:00
|
|
|
bootstrap_host_compiler,
|
2023-01-14 07:04:40 -06:00
|
|
|
target_triple.clone(),
|
2022-08-24 11:40:58 -05:00
|
|
|
);
|
|
|
|
|
2023-01-14 07:04:40 -06:00
|
|
|
let runner =
|
|
|
|
TestRunner::new(dirs.clone(), target_compiler, get_host_triple() == target_triple);
|
|
|
|
|
2022-12-01 08:54:37 -06:00
|
|
|
BUILD_EXAMPLE_OUT_DIR.ensure_fresh(dirs);
|
2022-08-24 11:40:58 -05:00
|
|
|
runner.run_testsuite(NO_SYSROOT_SUITE);
|
|
|
|
} else {
|
|
|
|
eprintln!("[SKIP] no_sysroot tests");
|
|
|
|
}
|
|
|
|
|
|
|
|
let run_base_sysroot = config::get_bool("testsuite.base_sysroot");
|
|
|
|
let run_extended_sysroot = config::get_bool("testsuite.extended_sysroot");
|
|
|
|
|
|
|
|
if run_base_sysroot || run_extended_sysroot {
|
2023-01-14 07:04:40 -06:00
|
|
|
let target_compiler = build_sysroot::build_sysroot(
|
2022-12-01 08:54:37 -06:00
|
|
|
dirs,
|
2022-08-24 11:40:58 -05:00
|
|
|
channel,
|
|
|
|
sysroot_kind,
|
2022-08-28 11:46:09 -05:00
|
|
|
cg_clif_dylib,
|
2023-01-14 06:53:33 -06:00
|
|
|
bootstrap_host_compiler,
|
2023-01-14 07:04:40 -06:00
|
|
|
target_triple.clone(),
|
2022-08-24 11:40:58 -05:00
|
|
|
);
|
|
|
|
|
2023-01-14 07:04:40 -06:00
|
|
|
let runner =
|
|
|
|
TestRunner::new(dirs.clone(), target_compiler, get_host_triple() == target_triple);
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2023-01-14 07:04:40 -06:00
|
|
|
if run_base_sysroot {
|
|
|
|
runner.run_testsuite(BASE_SYSROOT_SUITE);
|
|
|
|
} else {
|
|
|
|
eprintln!("[SKIP] base_sysroot tests");
|
|
|
|
}
|
|
|
|
|
|
|
|
if run_extended_sysroot {
|
|
|
|
runner.run_testsuite(EXTENDED_SYSROOT_SUITE);
|
|
|
|
} else {
|
|
|
|
eprintln!("[SKIP] extended_sysroot tests");
|
|
|
|
}
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestRunner {
|
2022-10-26 09:51:03 -05:00
|
|
|
is_native: bool,
|
2022-08-24 11:40:58 -05:00
|
|
|
jit_supported: bool,
|
2022-12-01 08:54:37 -06:00
|
|
|
dirs: Dirs,
|
2022-10-26 09:51:03 -05:00
|
|
|
target_compiler: Compiler,
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl TestRunner {
|
2023-01-14 07:04:40 -06:00
|
|
|
pub fn new(dirs: Dirs, mut target_compiler: Compiler, is_native: bool) -> Self {
|
2023-01-13 06:32:20 -06:00
|
|
|
if let Ok(rustflags) = env::var("RUSTFLAGS") {
|
|
|
|
target_compiler.rustflags.push(' ');
|
|
|
|
target_compiler.rustflags.push_str(&rustflags);
|
|
|
|
}
|
|
|
|
if let Ok(rustdocflags) = env::var("RUSTDOCFLAGS") {
|
|
|
|
target_compiler.rustdocflags.push(' ');
|
|
|
|
target_compiler.rustdocflags.push_str(&rustdocflags);
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME fix `#[linkage = "extern_weak"]` without this
|
2023-01-13 06:32:20 -06:00
|
|
|
if target_compiler.triple.contains("darwin") {
|
|
|
|
target_compiler.rustflags.push_str(" -Clink-arg=-undefined -Clink-arg=dynamic_lookup");
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
|
2023-01-14 06:44:39 -06:00
|
|
|
let jit_supported = is_native
|
|
|
|
&& target_compiler.triple.contains("x86_64")
|
|
|
|
&& !target_compiler.triple.contains("windows");
|
|
|
|
|
2023-01-14 06:36:56 -06:00
|
|
|
Self { is_native, jit_supported, dirs, target_compiler }
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn run_testsuite(&self, tests: &[TestCase]) {
|
2023-01-13 08:19:54 -06:00
|
|
|
for TestCase { config, cmd } in tests {
|
2022-08-24 11:40:58 -05:00
|
|
|
let (tag, testname) = config.split_once('.').unwrap();
|
|
|
|
let tag = tag.to_uppercase();
|
|
|
|
let is_jit_test = tag == "JIT";
|
|
|
|
|
|
|
|
if !config::get_bool(config) || (is_jit_test && !self.jit_supported) {
|
|
|
|
eprintln!("[{tag}] {testname} (skipped)");
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
eprintln!("[{tag}] {testname}");
|
|
|
|
}
|
|
|
|
|
2023-01-13 08:19:54 -06:00
|
|
|
match *cmd {
|
|
|
|
TestCaseCmd::Custom { func } => func(self),
|
|
|
|
TestCaseCmd::BuildLib { source, crate_types } => {
|
|
|
|
self.run_rustc([source, "--crate-type", crate_types]);
|
|
|
|
}
|
|
|
|
TestCaseCmd::BuildBinAndRun { source, args } => {
|
|
|
|
self.run_rustc([source]);
|
|
|
|
self.run_out_command(
|
|
|
|
source.split('/').last().unwrap().split('.').next().unwrap(),
|
|
|
|
args,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
TestCaseCmd::JitBin { source, args } => {
|
|
|
|
let mut jit_cmd = self.rustc_command([
|
|
|
|
"-Zunstable-options",
|
|
|
|
"-Cllvm-args=mode=jit",
|
|
|
|
"-Cprefer-dynamic",
|
|
|
|
source,
|
|
|
|
"--cfg",
|
|
|
|
"jit",
|
|
|
|
]);
|
|
|
|
if !args.is_empty() {
|
|
|
|
jit_cmd.env("CG_CLIF_JIT_ARGS", args);
|
|
|
|
}
|
|
|
|
spawn_and_wait(jit_cmd);
|
|
|
|
|
|
|
|
eprintln!("[JIT-lazy] {testname}");
|
|
|
|
let mut jit_cmd = self.rustc_command([
|
|
|
|
"-Zunstable-options",
|
|
|
|
"-Cllvm-args=mode=jit-lazy",
|
|
|
|
"-Cprefer-dynamic",
|
|
|
|
source,
|
|
|
|
"--cfg",
|
|
|
|
"jit",
|
|
|
|
]);
|
|
|
|
if !args.is_empty() {
|
|
|
|
jit_cmd.env("CG_CLIF_JIT_ARGS", args);
|
|
|
|
}
|
|
|
|
spawn_and_wait(jit_cmd);
|
|
|
|
}
|
|
|
|
}
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-26 09:51:03 -05:00
|
|
|
#[must_use]
|
2022-08-24 11:40:58 -05:00
|
|
|
fn rustc_command<I, S>(&self, args: I) -> Command
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = S>,
|
|
|
|
S: AsRef<OsStr>,
|
|
|
|
{
|
2022-10-26 09:51:03 -05:00
|
|
|
let mut cmd = Command::new(&self.target_compiler.rustc);
|
|
|
|
cmd.args(self.target_compiler.rustflags.split_whitespace());
|
2022-08-24 11:40:58 -05:00
|
|
|
cmd.arg("-L");
|
2022-12-01 08:54:37 -06:00
|
|
|
cmd.arg(format!("crate={}", BUILD_EXAMPLE_OUT_DIR.to_path(&self.dirs).display()));
|
2022-08-24 11:40:58 -05:00
|
|
|
cmd.arg("--out-dir");
|
2022-12-01 08:54:37 -06:00
|
|
|
cmd.arg(format!("{}", BUILD_EXAMPLE_OUT_DIR.to_path(&self.dirs).display()));
|
2022-08-24 11:40:58 -05:00
|
|
|
cmd.arg("-Cdebuginfo=2");
|
2023-01-13 06:52:29 -06:00
|
|
|
cmd.arg("--target");
|
|
|
|
cmd.arg(&self.target_compiler.triple);
|
|
|
|
cmd.arg("-Cpanic=abort");
|
2022-08-24 11:40:58 -05:00
|
|
|
cmd.args(args);
|
|
|
|
cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_rustc<I, S>(&self, args: I)
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = S>,
|
|
|
|
S: AsRef<OsStr>,
|
|
|
|
{
|
|
|
|
spawn_and_wait(self.rustc_command(args));
|
|
|
|
}
|
|
|
|
|
2023-01-13 08:19:54 -06:00
|
|
|
fn run_out_command<'a>(&self, name: &str, args: &[&str]) {
|
2022-08-24 11:40:58 -05:00
|
|
|
let mut full_cmd = vec![];
|
|
|
|
|
|
|
|
// Prepend the RUN_WRAPPER's
|
2022-10-26 09:51:03 -05:00
|
|
|
if !self.target_compiler.runner.is_empty() {
|
|
|
|
full_cmd.extend(self.target_compiler.runner.iter().cloned());
|
2022-08-24 11:40:58 -05:00
|
|
|
}
|
|
|
|
|
2022-12-01 08:54:37 -06:00
|
|
|
full_cmd.push(
|
|
|
|
BUILD_EXAMPLE_OUT_DIR.to_path(&self.dirs).join(name).to_str().unwrap().to_string(),
|
|
|
|
);
|
2022-08-24 11:40:58 -05:00
|
|
|
|
2023-01-13 08:19:54 -06:00
|
|
|
for arg in args {
|
2022-08-24 11:40:58 -05:00
|
|
|
full_cmd.push(arg.to_string());
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut cmd_iter = full_cmd.into_iter();
|
|
|
|
let first = cmd_iter.next().unwrap();
|
|
|
|
|
|
|
|
let mut cmd = Command::new(first);
|
|
|
|
cmd.args(cmd_iter);
|
|
|
|
|
|
|
|
spawn_and_wait(cmd);
|
|
|
|
}
|
|
|
|
}
|