summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_cranelift/build_system
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_codegen_cranelift/build_system')
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/build_backend.rs2
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs9
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/main.rs2
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/prepare.rs7
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/tests.rs68
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/utils.rs45
6 files changed, 58 insertions, 75 deletions
diff --git a/compiler/rustc_codegen_cranelift/build_system/build_backend.rs b/compiler/rustc_codegen_cranelift/build_system/build_backend.rs
index e434c36f9..d90111adf 100644
--- a/compiler/rustc_codegen_cranelift/build_system/build_backend.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/build_backend.rs
@@ -20,6 +20,8 @@ pub(crate) fn build_backend(
let mut rustflags = rustflags_from_env("RUSTFLAGS");
+ rustflags.push("-Zallow-features=rustc_private".to_owned());
+
if is_ci() {
// Deny warnings on CI
rustflags.push("-Dwarnings".to_owned());
diff --git a/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs b/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs
index 31a4b2098..1ed896c6b 100644
--- a/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs
@@ -1,3 +1,4 @@
+use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
@@ -259,6 +260,14 @@ fn build_clif_sysroot_for_triple(
// inlining.
rustflags.push("-Zinline-mir".to_owned());
}
+ if let Some(prefix) = env::var_os("CG_CLIF_STDLIB_REMAP_PATH_PREFIX") {
+ rustflags.push("--remap-path-prefix".to_owned());
+ rustflags.push(format!(
+ "{}={}",
+ STDLIB_SRC.to_path(dirs).to_str().unwrap(),
+ prefix.to_str().unwrap()
+ ));
+ }
compiler.rustflags.extend(rustflags);
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
maybe_incremental(&mut build_cmd);
diff --git a/compiler/rustc_codegen_cranelift/build_system/main.rs b/compiler/rustc_codegen_cranelift/build_system/main.rs
index 798ae9dbd..e8cf486e9 100644
--- a/compiler/rustc_codegen_cranelift/build_system/main.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/main.rs
@@ -55,7 +55,7 @@ enum CodegenBackend {
}
fn main() {
- if env::var("RUST_BACKTRACE").is_err() {
+ if env::var_os("RUST_BACKTRACE").is_none() {
env::set_var("RUST_BACKTRACE", "1");
}
env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");
diff --git a/compiler/rustc_codegen_cranelift/build_system/prepare.rs b/compiler/rustc_codegen_cranelift/build_system/prepare.rs
index 165296cb4..c68968b4f 100644
--- a/compiler/rustc_codegen_cranelift/build_system/prepare.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/prepare.rs
@@ -122,10 +122,10 @@ impl GitRepo {
if download_dir.exists() {
let actual_hash = format!("{:016x}", hash_dir(&download_dir));
if actual_hash == self.content_hash {
- println!("[FRESH] {}", download_dir.display());
+ eprintln!("[FRESH] {}", download_dir.display());
return;
} else {
- println!(
+ eprintln!(
"Mismatched content hash for {download_dir}: {actual_hash} != {content_hash}. Downloading again.",
download_dir = download_dir.display(),
content_hash = self.content_hash,
@@ -143,6 +143,7 @@ impl GitRepo {
RelPath::PATCHES.to_path(dirs).join(format!("{}-lock.toml", self.patch_name));
let target_lockfile = download_dir.join("Cargo.lock");
if source_lockfile.exists() {
+ assert!(!target_lockfile.exists());
fs::copy(source_lockfile, target_lockfile).unwrap();
} else {
assert!(target_lockfile.exists());
@@ -150,7 +151,7 @@ impl GitRepo {
let actual_hash = format!("{:016x}", hash_dir(&download_dir));
if actual_hash != self.content_hash {
- println!(
+ eprintln!(
"Download of {download_dir} failed with mismatched content hash: {actual_hash} != {content_hash}",
download_dir = download_dir.display(),
content_hash = self.content_hash,
diff --git a/compiler/rustc_codegen_cranelift/build_system/tests.rs b/compiler/rustc_codegen_cranelift/build_system/tests.rs
index e7bd8b127..10736ff9a 100644
--- a/compiler/rustc_codegen_cranelift/build_system/tests.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/tests.rs
@@ -9,7 +9,7 @@ use crate::path::{Dirs, RelPath};
use crate::prepare::{apply_patches, GitRepo};
use crate::rustc_info::get_default_sysroot;
use crate::shared_utils::rustflags_from_env;
-use crate::utils::{spawn_and_wait, spawn_and_wait_with_input, CargoProject, Compiler, LogGroup};
+use crate::utils::{spawn_and_wait, CargoProject, Compiler, LogGroup};
use crate::{CodegenBackend, SysrootKind};
static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example");
@@ -99,15 +99,14 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
TestCase::build_bin_and_run("aot.mod_bench", "example/mod_bench.rs", &[]),
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
+ TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),
];
-// FIXME(rust-random/rand#1293): Newer rand versions fail to test on Windows. Update once this is
-// fixed.
pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
"rust-random",
"rand",
- "50b9a447410860af8d6db9a208c3576886955874",
- "446203b96054891e",
+ "9a02c819cc1e4ec6959ae25eafbb5cf6acb68234",
+ "4934f0afb1d1c2ca",
"rand",
);
@@ -116,8 +115,8 @@ pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir()
pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
"rust-lang",
"regex",
- "32fed9429eafba0ae92a64b01796a0c5a75b88c8",
- "fcc4df7c5b902633",
+ "061ee815ef2c44101dba7b0b124600fcb03c1912",
+ "dc26aefbeeac03ca",
"regex",
);
@@ -126,8 +125,8 @@ pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
"rust-lang",
"portable-simd",
- "7c7dbe0c505ccbc02ff30c1e37381ab1d47bf46f",
- "5bcc9c544f6fa7bd",
+ "4825b2a64d765317066948867e8714674419359b",
+ "9e67d07c00f5fb0b",
"portable-simd",
);
@@ -180,40 +179,6 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
spawn_and_wait(build_cmd);
}
}),
- TestCase::custom("test.regex-shootout-regex-dna", &|runner| {
- REGEX_REPO.patch(&runner.dirs);
-
- REGEX.clean(&runner.dirs);
-
- let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
- build_cmd.arg("--example").arg("shootout-regex-dna");
- spawn_and_wait(build_cmd);
-
- if runner.is_native {
- let mut run_cmd = REGEX.run(&runner.target_compiler, &runner.dirs);
- run_cmd.arg("--example").arg("shootout-regex-dna");
-
- let input = fs::read_to_string(
- REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-input.txt"),
- )
- .unwrap();
- let expected = fs::read_to_string(
- REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-output.txt"),
- )
- .unwrap();
-
- let output = spawn_and_wait_with_input(run_cmd, input);
-
- let output_matches = expected.lines().eq(output.lines());
- if !output_matches {
- println!("Output files don't match!");
- println!("Expected Output:\n{}", expected);
- println!("Actual Output:\n{}", output);
-
- std::process::exit(1);
- }
- }
- }),
TestCase::custom("test.regex", &|runner| {
REGEX_REPO.patch(&runner.dirs);
@@ -223,7 +188,22 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
// regex-capi and regex-debug don't have any tests. Nor do they contain any code
// that is useful to test with cg_clif. Skip building them to reduce test time.
- run_cmd.args(["-p", "regex", "-p", "regex-syntax", "--", "-q"]);
+ run_cmd.args([
+ "-p",
+ "regex",
+ "-p",
+ "regex-syntax",
+ "--release",
+ "--all-targets",
+ "--",
+ "-q",
+ ]);
+ spawn_and_wait(run_cmd);
+
+ let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
+ // don't run integration tests for regex-autonata. they take like 2min each without
+ // much extra coverage of simd usage.
+ run_cmd.args(["-p", "regex-automata", "--release", "--lib", "--", "-q"]);
spawn_and_wait(run_cmd);
} else {
eprintln!("Cross-Compiling: Not running tests");
diff --git a/compiler/rustc_codegen_cranelift/build_system/utils.rs b/compiler/rustc_codegen_cranelift/build_system/utils.rs
index 24624cdea..149f1618f 100644
--- a/compiler/rustc_codegen_cranelift/build_system/utils.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/utils.rs
@@ -1,8 +1,8 @@
use std::env;
use std::fs;
-use std::io::{self, Write};
+use std::io;
use std::path::{Path, PathBuf};
-use std::process::{self, Command, Stdio};
+use std::process::{self, Command};
use std::sync::atomic::{AtomicBool, Ordering};
use crate::path::{Dirs, RelPath};
@@ -42,12 +42,22 @@ impl Compiler {
"/usr/s390x-linux-gnu".to_owned(),
];
}
+ "riscv64gc-unknown-linux-gnu" => {
+ // We are cross-compiling for riscv64. Use the correct linker and run tests in qemu.
+ self.rustflags.push("-Clinker=riscv64-linux-gnu-gcc".to_owned());
+ self.rustdocflags.push("-Clinker=riscv64-linux-gnu-gcc".to_owned());
+ self.runner = vec![
+ "qemu-riscv64".to_owned(),
+ "-L".to_owned(),
+ "/usr/riscv64-linux-gnu".to_owned(),
+ ];
+ }
"x86_64-pc-windows-gnu" => {
// We are cross-compiling for Windows. Run tests in wine.
self.runner = vec!["wine".to_owned()];
}
_ => {
- println!("Unknown non-native platform");
+ eprintln!("Unknown non-native platform");
}
}
}
@@ -197,7 +207,9 @@ pub(crate) fn try_hard_link(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
#[track_caller]
pub(crate) fn spawn_and_wait(mut cmd: Command) {
- if !cmd.spawn().unwrap().wait().unwrap().success() {
+ let status = cmd.spawn().unwrap().wait().unwrap();
+ if !status.success() {
+ eprintln!("{cmd:?} exited with status {:?}", status);
process::exit(1);
}
}
@@ -207,38 +219,17 @@ pub(crate) fn spawn_and_wait(mut cmd: Command) {
pub(crate) fn retry_spawn_and_wait(tries: u64, mut cmd: Command) {
for i in 1..tries + 1 {
if i != 1 {
- println!("Command failed. Attempt {i}/{tries}:");
+ eprintln!("Command failed. Attempt {i}/{tries}:");
}
if cmd.spawn().unwrap().wait().unwrap().success() {
return;
}
std::thread::sleep(std::time::Duration::from_secs(i * 5));
}
- println!("The command has failed after {tries} attempts.");
+ eprintln!("The command has failed after {tries} attempts.");
process::exit(1);
}
-#[track_caller]
-pub(crate) fn spawn_and_wait_with_input(mut cmd: Command, input: String) -> String {
- let mut child = cmd
- .stdin(Stdio::piped())
- .stdout(Stdio::piped())
- .spawn()
- .expect("Failed to spawn child process");
-
- let mut stdin = child.stdin.take().expect("Failed to open stdin");
- std::thread::spawn(move || {
- stdin.write_all(input.as_bytes()).expect("Failed to write to stdin");
- });
-
- let output = child.wait_with_output().expect("Failed to read stdout");
- if !output.status.success() {
- process::exit(1);
- }
-
- String::from_utf8(output.stdout).unwrap()
-}
-
pub(crate) fn remove_dir_if_exists(path: &Path) {
match fs::remove_dir_all(&path) {
Ok(()) => {}