Skip to content

Commit cdeddae

Browse files
committed
Auto merge of #133956 - bjorn3:sync_cg_clif-2024-12-06, r=bjorn3
Sync cg clif 2024 12 06 The main highlights this time are a Cranelift update disabling the clif ir verifier by default for better performance. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2 parents bc145ce + 063e21b commit cdeddae

30 files changed

+398
-428
lines changed

Diff for: compiler/rustc_codegen_cranelift/Cargo.lock

+49-28
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
4646

4747
[[package]]
4848
name = "cranelift-bforest"
49-
version = "0.113.0"
49+
version = "0.114.0"
5050
source = "registry+https://github.com/rust-lang/crates.io-index"
51-
checksum = "8ea5e7afe85cadb55c4c1176268a2ac046fdff8dfaeca39e18581b9dc319ca9e"
51+
checksum = "2ba4f80548f22dc9c43911907b5e322c5555544ee85f785115701e6a28c9abe1"
5252
dependencies = [
5353
"cranelift-entity",
5454
]
5555

5656
[[package]]
5757
name = "cranelift-bitset"
58-
version = "0.113.0"
58+
version = "0.114.0"
5959
source = "registry+https://github.com/rust-lang/crates.io-index"
60-
checksum = "8ab25ef3be935a80680e393183e1f94ef507e93a24a8369494d2c6818aedb3e3"
60+
checksum = "005884e3649c3e5ff2dc79e8a94b138f11569cc08a91244a292714d2a86e9156"
6161

6262
[[package]]
6363
name = "cranelift-codegen"
64-
version = "0.113.0"
64+
version = "0.114.0"
6565
source = "registry+https://github.com/rust-lang/crates.io-index"
66-
checksum = "900a19b84545924f1851cbfe386962edfc4ecbc3366a254825cf1ecbcda8ba08"
66+
checksum = "fe4036255ec33ce9a37495dfbcfc4e1118fd34e693eff9a1e106336b7cd16a9b"
6767
dependencies = [
6868
"bumpalo",
6969
"cranelift-bforest",
@@ -78,48 +78,49 @@ dependencies = [
7878
"log",
7979
"regalloc2",
8080
"rustc-hash",
81+
"serde",
8182
"smallvec",
8283
"target-lexicon",
8384
]
8485

8586
[[package]]
8687
name = "cranelift-codegen-meta"
87-
version = "0.113.0"
88+
version = "0.114.0"
8889
source = "registry+https://github.com/rust-lang/crates.io-index"
89-
checksum = "08c73b2395ffe9e7b4fdf7e2ebc052e7e27af13f68a964985346be4da477a5fc"
90+
checksum = "f7ca74f4b68319da11d39e894437cb6e20ec7c2e11fbbda823c3bf207beedff7"
9091
dependencies = [
9192
"cranelift-codegen-shared",
9293
]
9394

9495
[[package]]
9596
name = "cranelift-codegen-shared"
96-
version = "0.113.0"
97+
version = "0.114.0"
9798
source = "registry+https://github.com/rust-lang/crates.io-index"
98-
checksum = "7d9ed0854e96a4ff0879bff39d078de8dea7f002721c9494c1fdb4e1baa86ccc"
99+
checksum = "897e54f433a0269c4187871aa06d452214d5515d228d5bdc22219585e9eef895"
99100

100101
[[package]]
101102
name = "cranelift-control"
102-
version = "0.113.0"
103+
version = "0.114.0"
103104
source = "registry+https://github.com/rust-lang/crates.io-index"
104-
checksum = "b4aca921dd422e781409de0129c255768fec5dec1dae83239b497fb9138abb89"
105+
checksum = "29cb4018f5bf59fb53f515fa9d80e6f8c5ce19f198dc538984ebd23ecf8965ec"
105106
dependencies = [
106107
"arbitrary",
107108
]
108109

109110
[[package]]
110111
name = "cranelift-entity"
111-
version = "0.113.0"
112+
version = "0.114.0"
112113
source = "registry+https://github.com/rust-lang/crates.io-index"
113-
checksum = "e2d770e6605eccee15b49decdd82cd26f2b6404767802471459ea49c57379a98"
114+
checksum = "305399fd781a2953ac78c1396f02ff53144f39c33eb7fc7789cf4e8936d13a96"
114115
dependencies = [
115116
"cranelift-bitset",
116117
]
117118

118119
[[package]]
119120
name = "cranelift-frontend"
120-
version = "0.113.0"
121+
version = "0.114.0"
121122
source = "registry+https://github.com/rust-lang/crates.io-index"
122-
checksum = "29268711cb889cb39215b10faf88b9087d4c9e1d2633581e4f722a2bf4bb4ef9"
123+
checksum = "9230b460a128d53653456137751d27baf567947a3ab8c0c4d6e31fd08036d81e"
123124
dependencies = [
124125
"cranelift-codegen",
125126
"log",
@@ -129,15 +130,15 @@ dependencies = [
129130

130131
[[package]]
131132
name = "cranelift-isle"
132-
version = "0.113.0"
133+
version = "0.114.0"
133134
source = "registry+https://github.com/rust-lang/crates.io-index"
134-
checksum = "dc65156f010aed1985767ad1bff0eb8d186743b7b03e23d0c17604a253e3f356"
135+
checksum = "b961e24ae3ec9813a24a15ae64bbd2a42e4de4d79a7f3225a412e3b94e78d1c8"
135136

136137
[[package]]
137138
name = "cranelift-jit"
138-
version = "0.113.0"
139+
version = "0.114.0"
139140
source = "registry+https://github.com/rust-lang/crates.io-index"
140-
checksum = "40ba6b46367a4f466cfb1abe32793fa1a0f96d862251491b01a44726b8ed9445"
141+
checksum = "62699329d4ced20fe281fbaef45e11b473b7ab310491b4bdebcd8b818a8ef7fe"
141142
dependencies = [
142143
"anyhow",
143144
"cranelift-codegen",
@@ -155,9 +156,9 @@ dependencies = [
155156

156157
[[package]]
157158
name = "cranelift-module"
158-
version = "0.113.0"
159+
version = "0.114.0"
159160
source = "registry+https://github.com/rust-lang/crates.io-index"
160-
checksum = "007607022a4883ebdffc46c0925e2e10babf2a565ae78518034ade722aa825d2"
161+
checksum = "2f20b0b51ba962dac30fc7e812b86e4390d908acd4f59bcc8ac7610a8f3e0977"
161162
dependencies = [
162163
"anyhow",
163164
"cranelift-codegen",
@@ -166,9 +167,9 @@ dependencies = [
166167

167168
[[package]]
168169
name = "cranelift-native"
169-
version = "0.113.0"
170+
version = "0.114.0"
170171
source = "registry+https://github.com/rust-lang/crates.io-index"
171-
checksum = "d8bf9b361eaf5a7627647270fabf1dc910d993edbeaf272a652c107861ebe9c2"
172+
checksum = "4d5bd76df6c9151188dfa428c863b33da5b34561b67f43c0cf3f24a794f9fa1f"
172173
dependencies = [
173174
"cranelift-codegen",
174175
"libc",
@@ -177,9 +178,9 @@ dependencies = [
177178

178179
[[package]]
179180
name = "cranelift-object"
180-
version = "0.113.0"
181+
version = "0.114.0"
181182
source = "registry+https://github.com/rust-lang/crates.io-index"
182-
checksum = "30ca5c38fa00c0cd943035391bdcc84ed00748f17c66c682e410f5a62f234d44"
183+
checksum = "ee231640a7ecceedd0f1f2782d9288db6a6908cc70675ed9427e3bf0ea6daacd"
183184
dependencies = [
184185
"anyhow",
185186
"cranelift-codegen",
@@ -363,6 +364,26 @@ dependencies = [
363364
"target-lexicon",
364365
]
365366

367+
[[package]]
368+
name = "serde"
369+
version = "1.0.210"
370+
source = "registry+https://github.com/rust-lang/crates.io-index"
371+
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
372+
dependencies = [
373+
"serde_derive",
374+
]
375+
376+
[[package]]
377+
name = "serde_derive"
378+
version = "1.0.210"
379+
source = "registry+https://github.com/rust-lang/crates.io-index"
380+
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
381+
dependencies = [
382+
"proc-macro2",
383+
"quote",
384+
"syn",
385+
]
386+
366387
[[package]]
367388
name = "slice-group-by"
368389
version = "0.3.1"
@@ -412,9 +433,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
412433

413434
[[package]]
414435
name = "wasmtime-jit-icache-coherence"
415-
version = "26.0.0"
436+
version = "27.0.0"
416437
source = "registry+https://github.com/rust-lang/crates.io-index"
417-
checksum = "6e458e6a1a010a53f86ac8d75837c0c6b2ce3e54b7503b2f1dc5629a4a541f5a"
438+
checksum = "91b218a92866f74f35162f5d03a4e0f62cd0e1cc624285b1014275e5d4575fad"
418439
dependencies = [
419440
"anyhow",
420441
"cfg-if",

Diff for: compiler/rustc_codegen_cranelift/Cargo.toml

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

99
[dependencies]
1010
# These have to be in sync with each other
11-
cranelift-codegen = { version = "0.113.0", default-features = false, features = ["std", "unwind", "all-native-arch"] }
12-
cranelift-frontend = { version = "0.113.0" }
13-
cranelift-module = { version = "0.113.0" }
14-
cranelift-native = { version = "0.113.0" }
15-
cranelift-jit = { version = "0.113.0", optional = true }
16-
cranelift-object = { version = "0.113.0" }
11+
cranelift-codegen = { version = "0.114.0", default-features = false, features = ["std", "unwind", "all-native-arch"] }
12+
cranelift-frontend = { version = "0.114.0" }
13+
cranelift-module = { version = "0.114.0" }
14+
cranelift-native = { version = "0.114.0" }
15+
cranelift-jit = { version = "0.114.0", optional = true }
16+
cranelift-object = { version = "0.114.0" }
1717
target-lexicon = "0.12.0"
1818
gimli = { version = "0.31", default-features = false, features = ["write"] }
1919
object = { version = "0.36", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

Diff for: compiler/rustc_codegen_cranelift/build_system/abi_cafe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::path::{Dirs, RelPath};
1+
use crate::path::Dirs;
22
use crate::prepare::GitRepo;
33
use crate::utils::{CargoProject, Compiler, spawn_and_wait};
44
use crate::{CodegenBackend, SysrootKind, build_sysroot};
@@ -20,7 +20,7 @@ pub(crate) fn run(
2020
rustup_toolchain_name: Option<&str>,
2121
bootstrap_host_compiler: &Compiler,
2222
) {
23-
RelPath::DOWNLOAD.ensure_exists(dirs);
23+
std::fs::create_dir_all(&dirs.download_dir).unwrap();
2424
ABI_CAFE_REPO.fetch(dirs);
2525
ABI_CAFE_REPO.patch(dirs);
2626

Diff for: compiler/rustc_codegen_cranelift/build_system/bench.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::io::Write;
33
use std::path::Path;
44
use std::process::Command;
55

6-
use crate::path::{Dirs, RelPath};
6+
use crate::path::Dirs;
77
use crate::prepare::GitRepo;
88
use crate::rustc_info::get_file_name;
99
use crate::utils::{Compiler, spawn_and_wait};
@@ -39,11 +39,11 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
3939
};
4040

4141
eprintln!("[BENCH COMPILE] ebobby/simple-raytracer");
42-
let cargo_clif = RelPath::DIST
43-
.to_path(dirs)
42+
let cargo_clif = dirs
43+
.dist_dir
4444
.join(get_file_name(&bootstrap_host_compiler.rustc, "cargo_clif", "bin").replace('_', "-"));
4545
let manifest_path = SIMPLE_RAYTRACER_REPO.source_dir().to_path(dirs).join("Cargo.toml");
46-
let target_dir = RelPath::BUILD.join("simple_raytracer").to_path(dirs);
46+
let target_dir = dirs.build_dir.join("simple_raytracer");
4747

4848
let clean_cmd = format!(
4949
"RUSTC=rustc cargo clean --manifest-path {manifest_path} --target-dir {target_dir}",
@@ -68,7 +68,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
6868
target_dir = target_dir.display(),
6969
);
7070

71-
let bench_compile_markdown = RelPath::DIST.to_path(dirs).join("bench_compile.md");
71+
let bench_compile_markdown = dirs.dist_dir.join("bench_compile.md");
7272

7373
let bench_compile = hyperfine_command(
7474
1,
@@ -92,7 +92,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
9292

9393
eprintln!("[BENCH RUN] ebobby/simple-raytracer");
9494

95-
let bench_run_markdown = RelPath::DIST.to_path(dirs).join("bench_run.md");
95+
let bench_run_markdown = dirs.dist_dir.join("bench_run.md");
9696

9797
let raytracer_cg_llvm = Path::new(".").join(get_file_name(
9898
&bootstrap_host_compiler.rustc,
@@ -120,7 +120,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
120120
],
121121
&bench_run_markdown,
122122
);
123-
bench_run.current_dir(RelPath::BUILD.to_path(dirs));
123+
bench_run.current_dir(&dirs.build_dir);
124124
spawn_and_wait(bench_run);
125125

126126
if let Some(gha_step_summary) = gha_step_summary.as_mut() {

Diff for: compiler/rustc_codegen_cranelift/build_system/build_backend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::rustc_info::get_file_name;
66
use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env};
77
use crate::utils::{CargoProject, Compiler, LogGroup};
88

9-
static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
9+
static CG_CLIF: CargoProject = CargoProject::new(&RelPath::source("."), "cg_clif");
1010

1111
pub(crate) fn build_backend(
1212
dirs: &Dirs,

Diff for: compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ pub(crate) fn build_sysroot(
2222

2323
eprintln!("[BUILD] sysroot {:?}", sysroot_kind);
2424

25-
let dist_dir = RelPath::DIST.to_path(dirs);
25+
let dist_dir = &dirs.dist_dir;
2626

27-
ensure_empty_dir(&dist_dir);
27+
ensure_empty_dir(dist_dir);
2828
fs::create_dir_all(dist_dir.join("bin")).unwrap();
2929
fs::create_dir_all(dist_dir.join("lib")).unwrap();
3030

@@ -55,7 +55,7 @@ pub(crate) fn build_sysroot(
5555
let mut build_cargo_wrapper_cmd = Command::new(&bootstrap_host_compiler.rustc);
5656
let wrapper_path = dist_dir.join(&wrapper_name);
5757
build_cargo_wrapper_cmd
58-
.arg(RelPath::SCRIPTS.to_path(dirs).join(&format!("{wrapper}.rs")))
58+
.arg(dirs.source_dir.join("scripts").join(&format!("{wrapper}.rs")))
5959
.arg("-o")
6060
.arg(&wrapper_path)
6161
.arg("-Cstrip=debuginfo");
@@ -85,7 +85,7 @@ pub(crate) fn build_sysroot(
8585
&cg_clif_dylib_path,
8686
sysroot_kind,
8787
);
88-
host.install_into_sysroot(&dist_dir);
88+
host.install_into_sysroot(dist_dir);
8989

9090
if !is_native {
9191
build_sysroot_for_triple(
@@ -99,7 +99,7 @@ pub(crate) fn build_sysroot(
9999
&cg_clif_dylib_path,
100100
sysroot_kind,
101101
)
102-
.install_into_sysroot(&dist_dir);
102+
.install_into_sysroot(dist_dir);
103103
}
104104

105105
let mut target_compiler = {
@@ -143,10 +143,10 @@ impl SysrootTarget {
143143
}
144144
}
145145

146-
static STDLIB_SRC: RelPath = RelPath::BUILD.join("stdlib");
146+
static STDLIB_SRC: RelPath = RelPath::build("stdlib");
147147
static STANDARD_LIBRARY: CargoProject =
148-
CargoProject::new(&STDLIB_SRC.join("library/sysroot"), "stdlib_target");
149-
static RTSTARTUP_SYSROOT: RelPath = RelPath::BUILD.join("rtstartup");
148+
CargoProject::new(&RelPath::build("stdlib/library/sysroot"), "stdlib_target");
149+
static RTSTARTUP_SYSROOT: RelPath = RelPath::build("rtstartup");
150150

151151
fn build_sysroot_for_triple(
152152
dirs: &Dirs,
@@ -247,6 +247,7 @@ fn build_clif_sysroot_for_triple(
247247
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
248248
build_cmd.arg("--release");
249249
build_cmd.arg("--features").arg("backtrace panic-unwind compiler-builtins-no-f16-f128");
250+
build_cmd.arg(format!("-Zroot-dir={}", STDLIB_SRC.to_path(dirs).display()));
250251
build_cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "true");
251252
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");
252253
if compiler.triple.contains("apple") {
@@ -281,13 +282,14 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
281282
return None;
282283
}
283284

284-
RTSTARTUP_SYSROOT.ensure_fresh(dirs);
285+
let rtstartup_sysroot = RTSTARTUP_SYSROOT.to_path(dirs);
286+
ensure_empty_dir(&rtstartup_sysroot);
285287

286288
let rtstartup_src = STDLIB_SRC.to_path(dirs).join("library").join("rtstartup");
287289
let mut target_libs = SysrootTarget { triple: compiler.triple.clone(), libs: vec![] };
288290

289291
for file in ["rsbegin", "rsend"] {
290-
let obj = RTSTARTUP_SYSROOT.to_path(dirs).join(format!("{file}.o"));
292+
let obj = rtstartup_sysroot.join(format!("{file}.o"));
291293
let mut build_rtstartup_cmd = Command::new(&compiler.rustc);
292294
build_rtstartup_cmd
293295
.arg("--target")

Diff for: compiler/rustc_codegen_cranelift/build_system/main.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,11 @@ fn main() {
185185
frozen,
186186
};
187187

188-
path::RelPath::BUILD.ensure_exists(&dirs);
188+
std::fs::create_dir_all(&dirs.build_dir).unwrap();
189189

190190
{
191191
// Make sure we always explicitly specify the target dir
192-
let target =
193-
path::RelPath::BUILD.join("target_dir_should_be_set_explicitly").to_path(&dirs);
192+
let target = dirs.build_dir.join("target_dir_should_be_set_explicitly");
194193
env::set_var("CARGO_TARGET_DIR", &target);
195194
let _ = std::fs::remove_file(&target);
196195
std::fs::File::create(target).unwrap();

0 commit comments

Comments
 (0)