Skip to content

Commit 9f8929f

Browse files
committed
Auto merge of #141557 - bjorn3:sync_cg_clif-2025-05-25, r=bjorn3
Subtree sync for rustc_codegen_cranelift The main highlights this time are a Cranelift update and (thanks for beetrees) f16/f128 support. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2 parents 283db70 + 4aed799 commit 9f8929f

37 files changed

+1112
-265
lines changed

compiler/rustc_codegen_cranelift/.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ jobs:
3434
- name: Rustfmt
3535
run: |
3636
cargo fmt --check
37-
rustfmt --check build_system/main.rs
38-
rustfmt --check example/*
39-
rustfmt --check scripts/*.rs
37+
rustfmt --check --edition 2024 build_system/main.rs
38+
rustfmt --check --edition 2024 example/*
39+
rustfmt --check --edition 2024 scripts/*.rs
4040
4141
4242
test:

compiler/rustc_codegen_cranelift/Cargo.lock

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,39 +43,42 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
4343

4444
[[package]]
4545
name = "cranelift-assembler-x64"
46-
version = "0.118.0"
46+
version = "0.120.0"
4747
source = "registry+https://github.com/rust-lang/crates.io-index"
48-
checksum = "3e4b56ebe316895d3fa37775d0a87b0c889cc933f5c8b253dbcc7c7bcb7fe7e4"
48+
checksum = "9ff8e35182c7372df00447cb90a04e584e032c42b9b9b6e8c50ddaaf0d7900d5"
4949
dependencies = [
5050
"cranelift-assembler-x64-meta",
5151
]
5252

5353
[[package]]
5454
name = "cranelift-assembler-x64-meta"
55-
version = "0.118.0"
55+
version = "0.120.0"
5656
source = "registry+https://github.com/rust-lang/crates.io-index"
57-
checksum = "95cabbc01dfbd7dcd6c329ca44f0212910309c221797ac736a67a5bc8857fe1b"
57+
checksum = "14220f9c2698015c3b94dc6b84ae045c1c45509ddc406e43c6139252757fdb7a"
58+
dependencies = [
59+
"cranelift-srcgen",
60+
]
5861

5962
[[package]]
6063
name = "cranelift-bforest"
61-
version = "0.118.0"
64+
version = "0.120.0"
6265
source = "registry+https://github.com/rust-lang/crates.io-index"
63-
checksum = "76ffe46df300a45f1dc6f609dc808ce963f0e3a2e971682c479a2d13e3b9b8ef"
66+
checksum = "d372ef2777ceefd75829e1390211ac240e9196bc60699218f7ea2419038288ee"
6467
dependencies = [
6568
"cranelift-entity",
6669
]
6770

6871
[[package]]
6972
name = "cranelift-bitset"
70-
version = "0.118.0"
73+
version = "0.120.0"
7174
source = "registry+https://github.com/rust-lang/crates.io-index"
72-
checksum = "b265bed7c51e1921fdae6419791d31af77d33662ee56d7b0fa0704dc8d231cab"
75+
checksum = "56323783e423818fa89ce8078e90a3913d2a6e0810399bfce8ebd7ee87baa81f"
7376

7477
[[package]]
7578
name = "cranelift-codegen"
76-
version = "0.118.0"
79+
version = "0.120.0"
7780
source = "registry+https://github.com/rust-lang/crates.io-index"
78-
checksum = "e606230a7e3a6897d603761baee0d19f88d077f17b996bb5089488a29ae96e41"
81+
checksum = "74ffb780aab6186c6e9ba26519654b1ac55a09c0a866f6088a4efbbd84da68ed"
7982
dependencies = [
8083
"bumpalo",
8184
"cranelift-assembler-x64",
@@ -98,43 +101,44 @@ dependencies = [
98101

99102
[[package]]
100103
name = "cranelift-codegen-meta"
101-
version = "0.118.0"
104+
version = "0.120.0"
102105
source = "registry+https://github.com/rust-lang/crates.io-index"
103-
checksum = "8a63bffafc23bc60969ad528e138788495999d935f0adcfd6543cb151ca8637d"
106+
checksum = "c23ef13814d3b39c869650d5961128cbbecad83fbdff4e6836a03ecf6862d7ed"
104107
dependencies = [
105-
"cranelift-assembler-x64",
108+
"cranelift-assembler-x64-meta",
106109
"cranelift-codegen-shared",
110+
"cranelift-srcgen",
107111
]
108112

109113
[[package]]
110114
name = "cranelift-codegen-shared"
111-
version = "0.118.0"
115+
version = "0.120.0"
112116
source = "registry+https://github.com/rust-lang/crates.io-index"
113-
checksum = "af50281b67324b58e843170a6a5943cf6d387c06f7eeacc9f5696e4ab7ae7d7e"
117+
checksum = "b9f623300657679f847803ce80811454bfff89cea4f6bf684be5c468d4a73631"
114118

115119
[[package]]
116120
name = "cranelift-control"
117-
version = "0.118.0"
121+
version = "0.120.0"
118122
source = "registry+https://github.com/rust-lang/crates.io-index"
119-
checksum = "8c20c1b38d1abfbcebb0032e497e71156c0e3b8dcb3f0a92b9863b7bcaec290c"
123+
checksum = "31f4168af69989aa6b91fab46799ed4df6096f3209f4a6c8fb4358f49c60188f"
120124
dependencies = [
121125
"arbitrary",
122126
]
123127

124128
[[package]]
125129
name = "cranelift-entity"
126-
version = "0.118.0"
130+
version = "0.120.0"
127131
source = "registry+https://github.com/rust-lang/crates.io-index"
128-
checksum = "0c2c67d95507c51b4a1ff3f3555fe4bfec36b9e13c1b684ccc602736f5d5f4a2"
132+
checksum = "ca6fa9bae1c8de26d71ac2162f069447610fd91e7780cb480ee0d76ac81eabb8"
129133
dependencies = [
130134
"cranelift-bitset",
131135
]
132136

133137
[[package]]
134138
name = "cranelift-frontend"
135-
version = "0.118.0"
139+
version = "0.120.0"
136140
source = "registry+https://github.com/rust-lang/crates.io-index"
137-
checksum = "4e002691cc69c38b54fc7ec93e5be5b744f627d027031d991cc845d1d512d0ce"
141+
checksum = "b8219205608aa0b0e6769b580284a7e055c7e0c323c1041cde7ca078add3e412"
138142
dependencies = [
139143
"cranelift-codegen",
140144
"log",
@@ -144,15 +148,15 @@ dependencies = [
144148

145149
[[package]]
146150
name = "cranelift-isle"
147-
version = "0.118.0"
151+
version = "0.120.0"
148152
source = "registry+https://github.com/rust-lang/crates.io-index"
149-
checksum = "e93588ed1796cbcb0e2ad160403509e2c5d330d80dd6e0014ac6774c7ebac496"
153+
checksum = "588d0c5964f10860b04043e55aab26d7f7a206b0fd4f10c5260e8aa5773832bd"
150154

151155
[[package]]
152156
name = "cranelift-jit"
153-
version = "0.118.0"
157+
version = "0.120.0"
154158
source = "registry+https://github.com/rust-lang/crates.io-index"
155-
checksum = "17f6682f0b193d6b7873cc8e7ed67e8776a8a26f50eeabf88534e9be618b9a03"
159+
checksum = "56bd917ddc524f84f4066f954062875bdfc0dffea068ee94e906d98de5ac7c33"
156160
dependencies = [
157161
"anyhow",
158162
"cranelift-codegen",
@@ -170,9 +174,9 @@ dependencies = [
170174

171175
[[package]]
172176
name = "cranelift-module"
173-
version = "0.118.0"
177+
version = "0.120.0"
174178
source = "registry+https://github.com/rust-lang/crates.io-index"
175-
checksum = "ff19784c6de05116e63e6a34791012bd927b2a4eac56233039c46f1b6a4edac8"
179+
checksum = "68a03c057d8a992e06596c871341e446af43ff9224f941e5b8adea39137a5391"
176180
dependencies = [
177181
"anyhow",
178182
"cranelift-codegen",
@@ -181,9 +185,9 @@ dependencies = [
181185

182186
[[package]]
183187
name = "cranelift-native"
184-
version = "0.118.0"
188+
version = "0.120.0"
185189
source = "registry+https://github.com/rust-lang/crates.io-index"
186-
checksum = "e5b09bdd6407bf5d89661b80cf926ce731c9e8cc184bf49102267a2369a8358e"
190+
checksum = "19ed3c94cb97b14f92b6a94a1d45ef8c851f6a2ad9114e5d91d233f7da638fed"
187191
dependencies = [
188192
"cranelift-codegen",
189193
"libc",
@@ -192,9 +196,9 @@ dependencies = [
192196

193197
[[package]]
194198
name = "cranelift-object"
195-
version = "0.118.0"
199+
version = "0.120.0"
196200
source = "registry+https://github.com/rust-lang/crates.io-index"
197-
checksum = "685e8661a30d1cb69509f589ac643adeee79c5f63c0da316431b9fad29e6d3b4"
201+
checksum = "a64dacef362a69375a604f6636e5e9a174fb96dba3b273646fcd9fa85c1d0997"
198202
dependencies = [
199203
"anyhow",
200204
"cranelift-codegen",
@@ -205,6 +209,12 @@ dependencies = [
205209
"target-lexicon",
206210
]
207211

212+
[[package]]
213+
name = "cranelift-srcgen"
214+
version = "0.120.0"
215+
source = "registry+https://github.com/rust-lang/crates.io-index"
216+
checksum = "85256fac1519a7d25a040c1d850fba67478f3f021ad5fdf738ba4425ee862dbf"
217+
208218
[[package]]
209219
name = "crc32fast"
210220
version = "1.4.2"
@@ -331,9 +341,9 @@ dependencies = [
331341

332342
[[package]]
333343
name = "regalloc2"
334-
version = "0.11.1"
344+
version = "0.12.2"
335345
source = "registry+https://github.com/rust-lang/crates.io-index"
336-
checksum = "145c1c267e14f20fb0f88aa76a1c5ffec42d592c1d28b3cd9148ae35916158d3"
346+
checksum = "5216b1837de2149f8bc8e6d5f88a9326b63b8c836ed58ce4a0a29ec736a59734"
337347
dependencies = [
338348
"allocator-api2",
339349
"bumpalo",
@@ -436,9 +446,9 @@ checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
436446

437447
[[package]]
438448
name = "wasmtime-jit-icache-coherence"
439-
version = "31.0.0"
449+
version = "33.0.0"
440450
source = "registry+https://github.com/rust-lang/crates.io-index"
441-
checksum = "a54f6c6c7e9d7eeee32dfcc10db7f29d505ee7dd28d00593ea241d5f70698e64"
451+
checksum = "175e924dbc944c185808466d1e90b5a7feb610f3b9abdfe26f8ee25fd1086d1c"
442452
dependencies = [
443453
"anyhow",
444454
"cfg-if",

compiler/rustc_codegen_cranelift/Cargo.toml

Lines changed: 12 additions & 12 deletions
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.118.0", default-features = false, features = ["std", "timing", "unwind", "all-native-arch"] }
12-
cranelift-frontend = { version = "0.118.0" }
13-
cranelift-module = { version = "0.118.0" }
14-
cranelift-native = { version = "0.118.0" }
15-
cranelift-jit = { version = "0.118.0", optional = true }
16-
cranelift-object = { version = "0.118.0" }
11+
cranelift-codegen = { version = "0.120.0", default-features = false, features = ["std", "timing", "unwind", "all-native-arch"] }
12+
cranelift-frontend = { version = "0.120.0" }
13+
cranelift-module = { version = "0.120.0" }
14+
cranelift-native = { version = "0.120.0" }
15+
cranelift-jit = { version = "0.120.0", optional = true }
16+
cranelift-object = { version = "0.120.0" }
1717
target-lexicon = "0.13"
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"] }
@@ -24,12 +24,12 @@ smallvec = "1.8.1"
2424

2525
[patch.crates-io]
2626
# Uncomment to use an unreleased version of cranelift
27-
#cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-31.0.0", version = "0.118.0" }
28-
#cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-31.0.0", version = "0.118.0" }
29-
#cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-31.0.0", version = "0.118.0" }
30-
#cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-31.0.0", version = "0.118.0" }
31-
#cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-31.0.0", version = "0.118.0" }
32-
#cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-31.0.0", version = "0.118.0" }
27+
#cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-33.0.0", version = "0.120.0" }
28+
#cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-33.0.0", version = "0.120.0" }
29+
#cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-33.0.0", version = "0.120.0" }
30+
#cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-33.0.0", version = "0.120.0" }
31+
#cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-33.0.0", version = "0.120.0" }
32+
#cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-33.0.0", version = "0.120.0" }
3333

3434
# Uncomment to use local checkout of cranelift
3535
#cranelift-codegen = { path = "../wasmtime/cranelift/codegen" }

compiler/rustc_codegen_cranelift/Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ If not please open an issue.
77

88
## Download using Rustup
99

10-
The Cranelift codegen backend is distributed in nightly builds on Linux and x86_64 macOS. If you want to
10+
The Cranelift codegen backend is distributed in nightly builds on Linux, macOS and x86_64 Windows. If you want to
1111
install it using Rustup, you can do that by running:
1212

1313
```bash
@@ -79,7 +79,7 @@ For more docs on how to build and test see [build_system/usage.txt](build_system
7979
Not all targets are available as rustup component for nightly. See notes in the platform support matrix.
8080

8181
[^xcoff]: XCOFF object file format is not supported.
82-
[^no-rustup]: Not available as rustup component for nightly. You can build it yourself.
82+
[^no-rustup]: Not available as [rustup component for nightly](https://rust-lang.github.io/rustup-components-history/). You can build it yourself.
8383

8484
## Usage
8585

compiler/rustc_codegen_cranelift/build_system/build_backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) fn build_backend(
1818
let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, dirs);
1919

2020
let mut rustflags = rustflags_from_env("RUSTFLAGS");
21-
rustflags.push("-Zallow-features=rustc_private".to_owned());
21+
rustflags.push("-Zallow-features=rustc_private,f16,f128".to_owned());
2222
rustflags_to_cmd_env(&mut cmd, "RUSTFLAGS", &rustflags);
2323

2424
if env::var("CG_CLIF_EXPENSIVE_CHECKS").is_ok() {

compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ fn build_llvm_sysroot_for_triple(compiler: Compiler) -> SysrootTarget {
168168
let file_name_str = file.file_name().unwrap().to_str().unwrap();
169169
if (file_name_str.contains("rustc_")
170170
&& !file_name_str.contains("rustc_std_workspace_")
171-
&& !file_name_str.contains("rustc_demangle"))
171+
&& !file_name_str.contains("rustc_demangle")
172+
&& !file_name_str.contains("rustc_literal_escaper"))
172173
|| file_name_str.contains("chalk")
173174
|| file_name_str.contains("tracing")
174175
|| file_name_str.contains("regex")
@@ -234,7 +235,7 @@ fn build_clif_sysroot_for_triple(
234235
compiler.rustflags.extend(rustflags);
235236
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
236237
build_cmd.arg("--release");
237-
build_cmd.arg("--features").arg("backtrace panic-unwind compiler-builtins-no-f16-f128");
238+
build_cmd.arg("--features").arg("backtrace panic-unwind");
238239
build_cmd.arg(format!("-Zroot-dir={}", STDLIB_SRC.to_path(dirs).display()));
239240
build_cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "true");
240241
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");

compiler/rustc_codegen_cranelift/docs/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ These are a few functions that allow you to easily run rust code from the shell
4747

4848
```bash
4949
function jit_naked() {
50-
echo "$@" | $cg_clif_dir/dist/rustc-clif - -Zunstable-options -Cllvm-args=jit-mode-Cprefer-dynamic
50+
echo "$@" | $cg_clif_dir/dist/rustc-clif - -Zunstable-options -Cllvm-args=jit-mode -Cprefer-dynamic
5151
}
5252

5353
function jit() {

compiler/rustc_codegen_cranelift/example/mini_core.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,28 @@ fn panic_cannot_unwind() -> ! {
521521
}
522522

523523
#[lang = "eh_personality"]
524-
fn eh_personality() -> ! {
524+
// FIXME personality signature depends on target
525+
fn eh_personality(
526+
_version: i32,
527+
_actions: i32,
528+
_exception_class: u64,
529+
_exception_object: *mut (),
530+
_context: *mut (),
531+
) -> i32 {
525532
loop {}
526533
}
527534

535+
#[lang = "panic_in_cleanup"]
536+
fn panic_in_cleanup() -> ! {
537+
loop {}
538+
}
539+
540+
#[cfg(all(unix, not(target_vendor = "apple")))]
541+
#[link(name = "gcc_s")]
542+
extern "C" {
543+
fn _Unwind_Resume(exc: *mut ()) -> !;
544+
}
545+
528546
#[lang = "drop_in_place"]
529547
#[allow(unconditional_recursion)]
530548
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {

compiler/rustc_codegen_cranelift/example/std_example.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ fn main() {
166166
enum Never {}
167167
}
168168

169+
#[cfg(not(target_arch = "s390x"))] // s390x doesn't have vector instructions enabled by default
169170
foo(I64X2([0, 0]));
170171

171172
transmute_wide_pointer();
@@ -203,9 +204,11 @@ fn rust_call_abi() {
203204
rust_call_abi_callee((1, 2));
204205
}
205206

207+
#[cfg_attr(target_arch = "s390x", allow(dead_code))]
206208
#[repr(simd)]
207209
struct I64X2([i64; 2]);
208210

211+
#[cfg_attr(target_arch = "s390x", allow(dead_code))]
209212
#[allow(improper_ctypes_definitions)]
210213
extern "C" fn foo(_a: I64X2) {}
211214

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
3737
index bf2b6d59f88..d5ccce03bbf 100644
3838
--- a/library/core/src/sync/atomic.rs
3939
+++ b/library/core/src/sync/atomic.rs
40+
@@ -300,8 +300,6 @@ impl_atomic_primitive!(AtomicI32(i32), size("32"), align(4));
41+
impl_atomic_primitive!(AtomicU32(u32), size("32"), align(4));
42+
impl_atomic_primitive!(AtomicI64(i64), size("64"), align(8));
43+
impl_atomic_primitive!(AtomicU64(u64), size("64"), align(8));
44+
-impl_atomic_primitive!(AtomicI128(i128), size("128"), align(16));
45+
-impl_atomic_primitive!(AtomicU128(u128), size("128"), align(16));
46+
47+
#[cfg(target_pointer_width = "16")]
48+
impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(2));
4049
@@ -3585,44 +3585,6 @@ pub const fn as_ptr(&self) -> *mut $int_type {
4150
8,
4251
u64 AtomicU64
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "nightly-2025-03-30"
2+
channel = "nightly-2025-05-25"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]
44
profile = "minimal"

compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ verbose-tests = false
4343
# disabled bootstrap will crash trying to copy llvm tools for the bootstrap
4444
# compiler.
4545
llvm-tools = false
46-
std-features = ["panic-unwind", "compiler-builtins-no-f16-f128"]
46+
std-features = ["panic-unwind"]
4747
4848
EOF
4949

0 commit comments

Comments
 (0)