Skip to content

Commit 648d024

Browse files
committed
Auto merge of #130716 - bjorn3:sync_cg_clif-2024-09-22, r=bjorn3
Subtree sync for rustc_codegen_cranelift The main highlight this time is a fix for a miscompilation of RwLock on macOS. Also a Cranelift update and a couple of extra vendor intrinsics on arm64. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2 parents c22a421 + 6b042f5 commit 648d024

31 files changed

+479
-337
lines changed

compiler/rustc_codegen_cranelift/.cirrus.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ task:
33
freebsd_instance:
44
image: freebsd-13-2-release-amd64
55
setup_rust_script:
6-
- pkg install -y git bash binutils
6+
- pkg install -y git-tiny binutils
77
- curl https://sh.rustup.rs -sSf --output rustup.sh
88
- sh rustup.sh --default-toolchain none -y --profile=minimal
99
target_cache:

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ jobs:
279279
runs-on: ubuntu-latest
280280
timeout-minutes: 10
281281
if: ${{ github.ref == 'refs/heads/master' }}
282-
# FIXME add the bench job back to the dependency list once rust-lang/rust#125493 gets merged
283-
needs: [rustfmt, test, dist]
282+
needs: [rustfmt, test, bench, dist]
284283

285284
permissions:
286285
contents: write # for creating the dev tag and release

compiler/rustc_codegen_cranelift/Cargo.lock

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

4747
[[package]]
4848
name = "cranelift-bforest"
49-
version = "0.110.1"
49+
version = "0.111.0"
5050
source = "registry+https://github.com/rust-lang/crates.io-index"
51-
checksum = "effa84ab2023f7138045ece6b326588c17447ca22e66db71ec15cb0a6c0c4ad2"
51+
checksum = "b80c3a50b9c4c7e5b5f73c0ed746687774fc9e36ef652b110da8daebf0c6e0e6"
5252
dependencies = [
5353
"cranelift-entity",
5454
]
5555

5656
[[package]]
5757
name = "cranelift-bitset"
58-
version = "0.110.1"
58+
version = "0.111.0"
5959
source = "registry+https://github.com/rust-lang/crates.io-index"
60-
checksum = "38a1dfc50dca188a15d938867c4400589530bcb0138f7022aae6d059d1d8c309"
60+
checksum = "38778758c2ca918b05acb2199134e0c561fb577c50574259b26190b6c2d95ded"
6161

6262
[[package]]
6363
name = "cranelift-codegen"
64-
version = "0.110.1"
64+
version = "0.111.0"
6565
source = "registry+https://github.com/rust-lang/crates.io-index"
66-
checksum = "821c20c639350158ecca928dc2a244d0d1c9cef2377a378fc62a445a286eb1ca"
66+
checksum = "58258667ad10e468bfc13a8d620f50dfcd4bb35d668123e97defa2549b9ad397"
6767
dependencies = [
6868
"bumpalo",
6969
"cranelift-bforest",
@@ -84,42 +84,42 @@ dependencies = [
8484

8585
[[package]]
8686
name = "cranelift-codegen-meta"
87-
version = "0.110.1"
87+
version = "0.111.0"
8888
source = "registry+https://github.com/rust-lang/crates.io-index"
89-
checksum = "064473f2fd59b44fa2c9aaa60de1f9c44db5e13521e28bc85d2b92ee535ef625"
89+
checksum = "043f0b702e529dcb07ff92bd7d40e7d5317b5493595172c5eb0983343751ee06"
9090
dependencies = [
9191
"cranelift-codegen-shared",
9292
]
9393

9494
[[package]]
9595
name = "cranelift-codegen-shared"
96-
version = "0.110.1"
96+
version = "0.111.0"
9797
source = "registry+https://github.com/rust-lang/crates.io-index"
98-
checksum = "d0f39b9ebfd2febdc2acfb9a0fca110665bcd5a6839502576307735ed07b2177"
98+
checksum = "7763578888ab53eca5ce7da141953f828e82c2bfadcffc106d10d1866094ffbb"
9999

100100
[[package]]
101101
name = "cranelift-control"
102-
version = "0.110.1"
102+
version = "0.111.0"
103103
source = "registry+https://github.com/rust-lang/crates.io-index"
104-
checksum = "94e125c189c3a1ca8dfe209fc6f46edba058a6d24e0b92aff69459a15f4711e7"
104+
checksum = "32db15f08c05df570f11e8ab33cb1ec449a64b37c8a3498377b77650bef33d8b"
105105
dependencies = [
106106
"arbitrary",
107107
]
108108

109109
[[package]]
110110
name = "cranelift-entity"
111-
version = "0.110.1"
111+
version = "0.111.0"
112112
source = "registry+https://github.com/rust-lang/crates.io-index"
113-
checksum = "ea62eb109baec2247e1a6fa7b74c0f584b1e76e289cfd7017385b4b031fc8450"
113+
checksum = "5289cdb399381a27e7bbfa1b42185916007c3d49aeef70b1d01cb4caa8010130"
114114
dependencies = [
115115
"cranelift-bitset",
116116
]
117117

118118
[[package]]
119119
name = "cranelift-frontend"
120-
version = "0.110.1"
120+
version = "0.111.0"
121121
source = "registry+https://github.com/rust-lang/crates.io-index"
122-
checksum = "722b089357aacb6c7528b2e59a5fe00917d61ce63448b25a3e477a5b7819fac8"
122+
checksum = "31ba8ab24eb9470477e98ddfa3c799a649ac5a0d9a2042868c4c952133c234e8"
123123
dependencies = [
124124
"cranelift-codegen",
125125
"log",
@@ -129,15 +129,15 @@ dependencies = [
129129

130130
[[package]]
131131
name = "cranelift-isle"
132-
version = "0.110.1"
132+
version = "0.111.0"
133133
source = "registry+https://github.com/rust-lang/crates.io-index"
134-
checksum = "c4b5005a48288e7fc2a2991a377831c534e26929b063c379c018060727785a9b"
134+
checksum = "2b72a3c5c166a70426dcb209bdd0bb71a787c1ea76023dc0974fbabca770e8f9"
135135

136136
[[package]]
137137
name = "cranelift-jit"
138-
version = "0.110.1"
138+
version = "0.111.0"
139139
source = "registry+https://github.com/rust-lang/crates.io-index"
140-
checksum = "f843932baf8d1025c5f114b929eda172d74b7163d058e0de2597c308b567c7e9"
140+
checksum = "df32578a47582e49b4fc1f9a5786839d9be1fedaa9f00bea7612c54425663c6b"
141141
dependencies = [
142142
"anyhow",
143143
"cranelift-codegen",
@@ -155,9 +155,9 @@ dependencies = [
155155

156156
[[package]]
157157
name = "cranelift-module"
158-
version = "0.110.1"
158+
version = "0.111.0"
159159
source = "registry+https://github.com/rust-lang/crates.io-index"
160-
checksum = "449819ef1c4af139cf1b9717916fcaea0e23248853d3e95135139773a842d3eb"
160+
checksum = "96094a758cdb543c9143f70817cd31069fecd49f50981a0fac06820ac011dc2f"
161161
dependencies = [
162162
"anyhow",
163163
"cranelift-codegen",
@@ -166,9 +166,9 @@ dependencies = [
166166

167167
[[package]]
168168
name = "cranelift-native"
169-
version = "0.110.1"
169+
version = "0.111.0"
170170
source = "registry+https://github.com/rust-lang/crates.io-index"
171-
checksum = "3ae2d48f38081a9e679ad795bd36bb29bedeb5552fc1c195185bf9885fa1b16e"
171+
checksum = "46a42424c956bbc31fc5c2706073df896156c5420ae8fa2a5d48dbc7b295d71b"
172172
dependencies = [
173173
"cranelift-codegen",
174174
"libc",
@@ -177,9 +177,9 @@ dependencies = [
177177

178178
[[package]]
179179
name = "cranelift-object"
180-
version = "0.110.1"
180+
version = "0.111.0"
181181
source = "registry+https://github.com/rust-lang/crates.io-index"
182-
checksum = "3a39ee2cfd0ec485eca76f6b4dc17701a280fa406bc05137bb43f1635ed12c9f"
182+
checksum = "1cf5e2484ab47fe38a3150747cdd2016535f13542a925acca152b63383a6591b"
183183
dependencies = [
184184
"anyhow",
185185
"cranelift-codegen",
@@ -213,9 +213,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
213213

214214
[[package]]
215215
name = "gimli"
216-
version = "0.28.1"
216+
version = "0.29.0"
217217
source = "registry+https://github.com/rust-lang/crates.io-index"
218-
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
218+
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
219219
dependencies = [
220220
"fallible-iterator",
221221
"indexmap",
@@ -403,9 +403,9 @@ dependencies = [
403403

404404
[[package]]
405405
name = "target-lexicon"
406-
version = "0.12.15"
406+
version = "0.12.16"
407407
source = "registry+https://github.com/rust-lang/crates.io-index"
408-
checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2"
408+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
409409

410410
[[package]]
411411
name = "unicode-ident"
@@ -421,9 +421,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
421421

422422
[[package]]
423423
name = "wasmtime-jit-icache-coherence"
424-
version = "23.0.1"
424+
version = "24.0.0"
425425
source = "registry+https://github.com/rust-lang/crates.io-index"
426-
checksum = "7fddf3e2980fb1d123d1fcac55189e417fdd3dba4f62139b5a0a1f9efe5669d5"
426+
checksum = "d15de8429db996f0d17a4163a35eccc3f874cbfb50f29c379951ea1bbb39452e"
427427
dependencies = [
428428
"anyhow",
429429
"cfg-if",

compiler/rustc_codegen_cranelift/Cargo.toml

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

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

2121
indexmap = "2.0.0"

compiler/rustc_codegen_cranelift/build_system/abi_cafe.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ static ABI_CAFE_REPO: GitRepo = GitRepo::github(
1414
static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe_target");
1515

1616
pub(crate) fn run(
17-
channel: &str,
1817
sysroot_kind: SysrootKind,
1918
dirs: &Dirs,
2019
cg_clif_dylib: &CodegenBackend,
@@ -28,7 +27,6 @@ pub(crate) fn run(
2827
eprintln!("Building sysroot for abi-cafe");
2928
build_sysroot::build_sysroot(
3029
dirs,
31-
channel,
3230
sysroot_kind,
3331
cg_clif_dylib,
3432
bootstrap_host_compiler,
@@ -38,12 +36,11 @@ pub(crate) fn run(
3836

3937
eprintln!("Running abi-cafe");
4038

41-
let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
42-
let pairs =
39+
let pairs: &[_] =
4340
if cfg!(not(any(target_os = "macos", all(target_os = "windows", target_env = "msvc")))) {
44-
&pairs[..]
41+
&["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"]
4542
} else {
46-
&pairs[..2]
43+
&["rustc_calls_cgclif", "cgclif_calls_rustc"]
4744
};
4845

4946
let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs);

compiler/rustc_codegen_cranelift/build_system/bench.rs

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::env;
22
use std::io::Write;
33
use std::path::Path;
4+
use std::process::Command;
45

56
use crate::path::{Dirs, RelPath};
67
use crate::prepare::GitRepo;
78
use crate::rustc_info::get_file_name;
8-
use crate::utils::{Compiler, hyperfine_command, spawn_and_wait};
9+
use crate::utils::{Compiler, spawn_and_wait};
910

1011
static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
1112
"ebobby",
@@ -128,3 +129,37 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
128129
gha_step_summary.write_all(b"\n").unwrap();
129130
}
130131
}
132+
133+
#[must_use]
134+
fn hyperfine_command(
135+
warmup: u64,
136+
runs: u64,
137+
prepare: Option<&str>,
138+
cmds: &[(&str, &str)],
139+
markdown_export: &Path,
140+
) -> Command {
141+
let mut bench = Command::new("hyperfine");
142+
143+
bench.arg("--export-markdown").arg(markdown_export);
144+
145+
if warmup != 0 {
146+
bench.arg("--warmup").arg(warmup.to_string());
147+
}
148+
149+
if runs != 0 {
150+
bench.arg("--runs").arg(runs.to_string());
151+
}
152+
153+
if let Some(prepare) = prepare {
154+
bench.arg("--prepare").arg(prepare);
155+
}
156+
157+
for &(name, cmd) in cmds {
158+
if name != "" {
159+
bench.arg("-n").arg(name);
160+
}
161+
bench.arg(cmd);
162+
}
163+
164+
bench
165+
}

compiler/rustc_codegen_cranelift/build_system/build_backend.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ 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-
pub(crate) 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,
13-
channel: &str,
1413
bootstrap_host_compiler: &Compiler,
1514
use_unstable_features: bool,
1615
) -> PathBuf {
@@ -19,8 +18,8 @@ pub(crate) fn build_backend(
1918
let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, dirs);
2019

2120
let mut rustflags = rustflags_from_env("RUSTFLAGS");
22-
2321
rustflags.push("-Zallow-features=rustc_private".to_owned());
22+
rustflags_to_cmd_env(&mut cmd, "RUSTFLAGS", &rustflags);
2423

2524
if env::var("CG_CLIF_EXPENSIVE_CHECKS").is_ok() {
2625
// Enabling debug assertions implicitly enables the clif ir verifier
@@ -32,22 +31,14 @@ pub(crate) fn build_backend(
3231
cmd.arg("--features").arg("unstable-features");
3332
}
3433

35-
match channel {
36-
"debug" => {}
37-
"release" => {
38-
cmd.arg("--release");
39-
}
40-
_ => unreachable!(),
41-
}
42-
43-
rustflags_to_cmd_env(&mut cmd, "RUSTFLAGS", &rustflags);
34+
cmd.arg("--release");
4435

4536
eprintln!("[BUILD] rustc_codegen_cranelift");
4637
crate::utils::spawn_and_wait(cmd);
4738

4839
CG_CLIF
4940
.target_dir(dirs)
5041
.join(&bootstrap_host_compiler.triple)
51-
.join(channel)
42+
.join("release")
5243
.join(get_file_name(&bootstrap_host_compiler.rustc, "rustc_codegen_cranelift", "dylib"))
5344
}

0 commit comments

Comments
 (0)