Skip to content

Commit 317783a

Browse files
committed
Auto merge of #116569 - matthiaskrgr:rollup-ni0jdd6, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #115882 (improve the suggestion of `generic_bound_failure`) - #116537 (Fix suggestion span involving wrongly placed generic arg on variant) - #116543 (In smir `find_crates` returns `Vec<Crate>` instead of `Option<Crate>`) - #116549 (Simplify some mir passes by using let chains) - #116556 (Sync rustc_codegen_cranelift) - #116561 (Add a test for fixed ICE) r? `@ghost` `@rustbot` modify labels: rollup
2 parents be581d9 + 27a5146 commit 317783a

File tree

141 files changed

+2820
-1547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2820
-1547
lines changed

compiler/rustc_codegen_cranelift/Cargo.lock

+72-94
Large diffs are not rendered by default.

compiler/rustc_codegen_cranelift/Cargo.toml

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ crate-type = ["dylib"]
88

99
[dependencies]
1010
# These have to be in sync with each other
11-
cranelift-codegen = { version = "0.98", features = ["unwind", "all-arch"] }
12-
cranelift-frontend = { version = "0.98" }
13-
cranelift-module = { version = "0.98" }
14-
cranelift-native = { version = "0.98" }
15-
cranelift-jit = { version = "0.98", optional = true }
16-
cranelift-object = { version = "0.98" }
11+
cranelift-codegen = { version = "0.100", features = ["unwind", "all-arch"] }
12+
cranelift-frontend = { version = "0.100" }
13+
cranelift-module = { version = "0.100" }
14+
cranelift-native = { version = "0.100" }
15+
cranelift-jit = { version = "0.100", optional = true }
16+
cranelift-object = { version = "0.100" }
1717
target-lexicon = "0.12.0"
18-
gimli = { version = "0.27.2", default-features = false, features = ["write"]}
19-
object = { version = "0.30.3", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
18+
gimli = { version = "0.28", default-features = false, features = ["write"]}
19+
object = { version = "0.32", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
2020

2121
indexmap = "2.0.0"
2222
libloading = { version = "0.7.3", optional = true }

compiler/rustc_codegen_cranelift/Readme.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,14 @@ You need to do this steps to successfully compile and use the cranelift backend
6060
2. Run `python x.py setup` and choose option for compiler (`b`).
6161
3. Build compiler and necessary tools: `python x.py build --stage=2 compiler library/std src/tools/rustdoc src/tools/rustfmt`
6262
* (Optional) You can also build cargo by adding `src/tools/cargo` to previous command.
63-
4. Copy exectutable files from `./build/host/stage2-tools/<your hostname triple>/release`
64-
to `./build/host/stage2/bin/`. Note that you would need to do this every time you rebuilt `rust` repository.
65-
5. Copy cargo from another toolchain: `cp $(rustup which cargo) .build/<your hostname triple>/stage2/bin/cargo`
66-
* Another option is to build it at step 3 and copy with other executables at step 4.
67-
6. Link your new `rustc` to toolchain: `rustup toolchain link stage2 ./build/host/stage2/`.
68-
7. (Windows only) compile the build system: `rustc +stage2 -O build_system/main.rs -o y.exe`.
69-
8. You need to prefix every `./y.sh` (or `y` if you built `build_system/main.rs` as `y`) command by `rustup run stage2` to make cg_clif use your local changes in rustc.
70-
63+
4. Copy cargo from a nightly toolchain: `cp $(rustup +nightly which cargo) ./build/host/stage2/bin/cargo`. Note that you would need to do this every time you rebuilt `rust` repository.
64+
5. Link your new `rustc` to toolchain: `rustup toolchain link stage2 ./build/host/stage2/`.
65+
6. (Windows only) compile the build system: `rustc +stage2 -O build_system/main.rs -o y.exe`.
66+
7. You need to prefix every `./y.sh` (or `y` if you built `build_system/main.rs` as `y`) command by `rustup run stage2` to make cg_clif use your local changes in rustc.
7167
* `rustup run stage2 ./y.sh prepare`
7268
* `rustup run stage2 ./y.sh build`
7369
* (Optional) run tests: `rustup run stage2 ./y.sh test`
74-
9. Now you can use your cg_clif build to compile other Rust programs, e.g. you can open any Rust crate and run commands like `$RustCheckoutDir/compiler/rustc_codegen_cranelift/dist/cargo-clif build --release`.
70+
8. Now you can use your cg_clif build to compile other Rust programs, e.g. you can open any Rust crate and run commands like `$RustCheckoutDir/compiler/rustc_codegen_cranelift/dist/cargo-clif build --release`.
7571

7672
## Configuration
7773

compiler/rustc_codegen_cranelift/build_system/build_backend.rs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub(crate) fn build_backend(
2020

2121
let mut rustflags = rustflags_from_env("RUSTFLAGS");
2222

23+
rustflags.push("-Zallow-features=rustc_private".to_owned());
24+
2325
if is_ci() {
2426
// Deny warnings on CI
2527
rustflags.push("-Dwarnings".to_owned());

compiler/rustc_codegen_cranelift/build_system/prepare.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ impl GitRepo {
122122
if download_dir.exists() {
123123
let actual_hash = format!("{:016x}", hash_dir(&download_dir));
124124
if actual_hash == self.content_hash {
125-
println!("[FRESH] {}", download_dir.display());
125+
eprintln!("[FRESH] {}", download_dir.display());
126126
return;
127127
} else {
128-
println!(
128+
eprintln!(
129129
"Mismatched content hash for {download_dir}: {actual_hash} != {content_hash}. Downloading again.",
130130
download_dir = download_dir.display(),
131131
content_hash = self.content_hash,
@@ -150,7 +150,7 @@ impl GitRepo {
150150

151151
let actual_hash = format!("{:016x}", hash_dir(&download_dir));
152152
if actual_hash != self.content_hash {
153-
println!(
153+
eprintln!(
154154
"Download of {download_dir} failed with mismatched content hash: {actual_hash} != {content_hash}",
155155
download_dir = download_dir.display(),
156156
content_hash = self.content_hash,

compiler/rustc_codegen_cranelift/build_system/tests.rs

+23-44
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::path::{Dirs, RelPath};
99
use crate::prepare::{apply_patches, GitRepo};
1010
use crate::rustc_info::get_default_sysroot;
1111
use crate::shared_utils::rustflags_from_env;
12-
use crate::utils::{spawn_and_wait, spawn_and_wait_with_input, CargoProject, Compiler, LogGroup};
12+
use crate::utils::{spawn_and_wait, CargoProject, Compiler, LogGroup};
1313
use crate::{CodegenBackend, SysrootKind};
1414

1515
static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example");
@@ -101,13 +101,11 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
101101
TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
102102
];
103103

104-
// FIXME(rust-random/rand#1293): Newer rand versions fail to test on Windows. Update once this is
105-
// fixed.
106104
pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
107105
"rust-random",
108106
"rand",
109-
"50b9a447410860af8d6db9a208c3576886955874",
110-
"446203b96054891e",
107+
"f3dd0b885c4597b9617ca79987a0dd899ab29fcb",
108+
"3f869e4fcd602b66",
111109
"rand",
112110
);
113111

@@ -116,8 +114,8 @@ pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir()
116114
pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
117115
"rust-lang",
118116
"regex",
119-
"32fed9429eafba0ae92a64b01796a0c5a75b88c8",
120-
"fcc4df7c5b902633",
117+
"061ee815ef2c44101dba7b0b124600fcb03c1912",
118+
"dc26aefbeeac03ca",
121119
"regex",
122120
);
123121

@@ -126,8 +124,8 @@ pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir
126124
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
127125
"rust-lang",
128126
"portable-simd",
129-
"7c7dbe0c505ccbc02ff30c1e37381ab1d47bf46f",
130-
"5bcc9c544f6fa7bd",
127+
"4825b2a64d765317066948867e8714674419359b",
128+
"8b188cc41f5af835",
131129
"portable-simd",
132130
);
133131

@@ -180,40 +178,6 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
180178
spawn_and_wait(build_cmd);
181179
}
182180
}),
183-
TestCase::custom("test.regex-shootout-regex-dna", &|runner| {
184-
REGEX_REPO.patch(&runner.dirs);
185-
186-
REGEX.clean(&runner.dirs);
187-
188-
let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
189-
build_cmd.arg("--example").arg("shootout-regex-dna");
190-
spawn_and_wait(build_cmd);
191-
192-
if runner.is_native {
193-
let mut run_cmd = REGEX.run(&runner.target_compiler, &runner.dirs);
194-
run_cmd.arg("--example").arg("shootout-regex-dna");
195-
196-
let input = fs::read_to_string(
197-
REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-input.txt"),
198-
)
199-
.unwrap();
200-
let expected = fs::read_to_string(
201-
REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-output.txt"),
202-
)
203-
.unwrap();
204-
205-
let output = spawn_and_wait_with_input(run_cmd, input);
206-
207-
let output_matches = expected.lines().eq(output.lines());
208-
if !output_matches {
209-
println!("Output files don't match!");
210-
println!("Expected Output:\n{}", expected);
211-
println!("Actual Output:\n{}", output);
212-
213-
std::process::exit(1);
214-
}
215-
}
216-
}),
217181
TestCase::custom("test.regex", &|runner| {
218182
REGEX_REPO.patch(&runner.dirs);
219183

@@ -223,7 +187,22 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
223187
let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
224188
// regex-capi and regex-debug don't have any tests. Nor do they contain any code
225189
// that is useful to test with cg_clif. Skip building them to reduce test time.
226-
run_cmd.args(["-p", "regex", "-p", "regex-syntax", "--", "-q"]);
190+
run_cmd.args([
191+
"-p",
192+
"regex",
193+
"-p",
194+
"regex-syntax",
195+
"--release",
196+
"--all-targets",
197+
"--",
198+
"-q",
199+
]);
200+
spawn_and_wait(run_cmd);
201+
202+
let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
203+
// don't run integration tests for regex-autonata. they take like 2min each without
204+
// much extra coverage of simd usage.
205+
run_cmd.args(["-p", "regex-automata", "--release", "--lib", "--", "-q"]);
227206
spawn_and_wait(run_cmd);
228207
} else {
229208
eprintln!("Cross-Compiling: Not running tests");

compiler/rustc_codegen_cranelift/build_system/utils.rs

+8-27
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::env;
22
use std::fs;
3-
use std::io::{self, Write};
3+
use std::io;
44
use std::path::{Path, PathBuf};
5-
use std::process::{self, Command, Stdio};
5+
use std::process::{self, Command};
66
use std::sync::atomic::{AtomicBool, Ordering};
77

88
use crate::path::{Dirs, RelPath};
@@ -47,7 +47,7 @@ impl Compiler {
4747
self.runner = vec!["wine".to_owned()];
4848
}
4949
_ => {
50-
println!("Unknown non-native platform");
50+
eprintln!("Unknown non-native platform");
5151
}
5252
}
5353
}
@@ -197,7 +197,9 @@ pub(crate) fn try_hard_link(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
197197

198198
#[track_caller]
199199
pub(crate) fn spawn_and_wait(mut cmd: Command) {
200-
if !cmd.spawn().unwrap().wait().unwrap().success() {
200+
let status = cmd.spawn().unwrap().wait().unwrap();
201+
if !status.success() {
202+
eprintln!("{cmd:?} exited with status {:?}", status);
201203
process::exit(1);
202204
}
203205
}
@@ -207,38 +209,17 @@ pub(crate) fn spawn_and_wait(mut cmd: Command) {
207209
pub(crate) fn retry_spawn_and_wait(tries: u64, mut cmd: Command) {
208210
for i in 1..tries + 1 {
209211
if i != 1 {
210-
println!("Command failed. Attempt {i}/{tries}:");
212+
eprintln!("Command failed. Attempt {i}/{tries}:");
211213
}
212214
if cmd.spawn().unwrap().wait().unwrap().success() {
213215
return;
214216
}
215217
std::thread::sleep(std::time::Duration::from_secs(i * 5));
216218
}
217-
println!("The command has failed after {tries} attempts.");
219+
eprintln!("The command has failed after {tries} attempts.");
218220
process::exit(1);
219221
}
220222

221-
#[track_caller]
222-
pub(crate) fn spawn_and_wait_with_input(mut cmd: Command, input: String) -> String {
223-
let mut child = cmd
224-
.stdin(Stdio::piped())
225-
.stdout(Stdio::piped())
226-
.spawn()
227-
.expect("Failed to spawn child process");
228-
229-
let mut stdin = child.stdin.take().expect("Failed to open stdin");
230-
std::thread::spawn(move || {
231-
stdin.write_all(input.as_bytes()).expect("Failed to write to stdin");
232-
});
233-
234-
let output = child.wait_with_output().expect("Failed to read stdout");
235-
if !output.status.success() {
236-
process::exit(1);
237-
}
238-
239-
String::from_utf8(output.stdout).unwrap()
240-
}
241-
242223
pub(crate) fn remove_dir_if_exists(path: &Path) {
243224
match fs::remove_dir_all(&path) {
244225
Ok(()) => {}

compiler/rustc_codegen_cranelift/config.txt

-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@ aot.issue-59326
4646
testsuite.extended_sysroot
4747
test.rust-random/rand
4848
test.libcore
49-
test.regex-shootout-regex-dna
5049
test.regex
5150
test.portable-simd

compiler/rustc_codegen_cranelift/example/mini_core.rs

+6
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,12 @@ pub macro cfg() {
683683
/* compiler built-in */
684684
}
685685

686+
#[rustc_builtin_macro]
687+
#[rustc_macro_transparency = "semitransparent"]
688+
pub macro asm() {
689+
/* compiler built-in */
690+
}
691+
686692
#[rustc_builtin_macro]
687693
#[rustc_macro_transparency = "semitransparent"]
688694
pub macro global_asm() {

compiler/rustc_codegen_cranelift/patches/0001-portable-simd-Allow-internal-features.patch

-24
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 5d4afb8d807d181038b6a004d17ed055a8d191b2 Mon Sep 17 00:00:00 2001
2+
From: bjorn3 <17426603+bjorn3@users.noreply.github.com>
3+
Date: Mon, 2 Oct 2023 13:59:00 +0000
4+
Subject: [PATCH] Ignore test which gets miscompiled with llvm sysroot
5+
6+
---
7+
regex-automata/src/util/pool.rs | 2 ++
8+
1 file changed, 2 insertions(+)
9+
10+
diff --git a/regex-automata/src/util/pool.rs b/regex-automata/src/util/pool.rs
11+
index c03d7b0..28b233b 100644
12+
--- a/regex-automata/src/util/pool.rs
13+
+++ b/regex-automata/src/util/pool.rs
14+
@@ -1081,6 +1081,8 @@ mod tests {
15+
// into the pool. This in turn resulted in this test producing a data race.
16+
#[cfg(feature = "std")]
17+
#[test]
18+
+ // FIXME(rustc_codegen_cranelift#1395) miscompilation of thread::scope with LLVM sysroot
19+
+ #[ignore]
20+
fn thread_owner_sync() {
21+
let pool = Pool::new(|| vec!['a']);
22+
{
23+
--
24+
2.34.1
25+

compiler/rustc_codegen_cranelift/patches/0027-coretests-128bit-atomic-operations.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ index 897a5e9..331f66f 100644
1919
#![feature(const_option_ext)]
2020
#![feature(const_result)]
2121
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
22+
#![cfg_attr(test, feature(cfg_match))]
2223
#![feature(int_roundings)]
2324
#![feature(slice_group_by)]
24-
#![feature(split_array)]
2525
diff --git a/atomic.rs b/atomic.rs
2626
index b735957..ea728b6 100644
2727
--- a/atomic.rs

0 commit comments

Comments
 (0)