Skip to content

Commit ca5d25e

Browse files
committed
Auto merge of #128896 - bjorn3:sync_cg_clif-2024-08-09, r=bjorn3
Subtree sync for rustc_codegen_cranelift The main highlight this time is support for raw-dylib on Windows thanks to `@dpaoliello.` Compiling the ring crate for arm64 macOS has been fixed too. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2 parents 19ebdce + 57dd967 commit ca5d25e

30 files changed

+390
-850
lines changed

Diff for: compiler/rustc_codegen_cranelift/.github/workflows/abi-cafe.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ name: Abi-cafe
22

33
on:
44
- push
5+
- pull_request
56

67
permissions: {}
78

89
jobs:
910
abi_cafe:
1011
runs-on: ${{ matrix.os }}
11-
timeout-minutes: 60
12+
timeout-minutes: 30
1213
concurrency:
1314
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.env.TARGET_TRIPLE }}
1415
cancel-in-progress: true
@@ -27,12 +28,16 @@ jobs:
2728
- os: macos-latest
2829
env:
2930
TARGET_TRIPLE: x86_64-apple-darwin
30-
- os: windows-latest
31+
- os: macos-latest
3132
env:
32-
TARGET_TRIPLE: x86_64-pc-windows-msvc
33+
TARGET_TRIPLE: aarch64-apple-darwin
3334
- os: windows-latest
3435
env:
35-
TARGET_TRIPLE: x86_64-pc-windows-gnu
36+
TARGET_TRIPLE: x86_64-pc-windows-msvc
37+
# FIXME Currently hangs. Re-enable once this is fixed or abi-cafe adds a timeout.
38+
#- os: windows-latest
39+
# env:
40+
# TARGET_TRIPLE: x86_64-pc-windows-gnu
3641

3742
steps:
3843
- uses: actions/checkout@v4

Diff for: compiler/rustc_codegen_cranelift/.github/workflows/audit.yml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- run: |
1515
sed -i 's/components.*/components = []/' rust-toolchain
16-
echo 'profile = "minimal"' >> rust-toolchain
1716
- uses: rustsec/[email protected]
1817
with:
1918
token: ${{ secrets.GITHUB_TOKEN }}

Diff for: compiler/rustc_codegen_cranelift/.github/workflows/main.yml

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
- name: Avoid installing rustc-dev
3030
run: |
3131
sed -i 's/components.*/components = ["rustfmt"]/' rust-toolchain
32-
echo 'profile = "minimal"' >> rust-toolchain
3332
rustfmt -v
3433
3534
- name: Rustfmt

Diff for: compiler/rustc_codegen_cranelift/.zed/settings.json

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"format_on_save": "on",
3+
"lsp": {
4+
"rust-analyzer": {
5+
"initialization_options": {
6+
"diagnostics": {
7+
// in case rustc.source is disabled for performance reasons; disable the errors about this
8+
"disabled": ["unresolved-extern-crate", "unresolved-macro-call"]
9+
},
10+
"rustc": {
11+
"source": "discover"
12+
},
13+
"imports": {
14+
"granularity": {
15+
"enforce": true,
16+
"group": "module"
17+
},
18+
"prefix": "crate"
19+
},
20+
"cargo": {
21+
"features": ["unstable-features"]
22+
},
23+
"linkedProjects": [
24+
"./Cargo.toml",
25+
"./build_system/Cargo.toml",
26+
{
27+
"crates": [
28+
{
29+
"root_module": "./example/mini_core.rs",
30+
"edition": "2018",
31+
"deps": [],
32+
"cfg": []
33+
},
34+
{
35+
"root_module": "./example/mini_core_hello_world.rs",
36+
"edition": "2018",
37+
"deps": [
38+
{
39+
"crate": 0,
40+
"name": "mini_core"
41+
}
42+
],
43+
"cfg": []
44+
},
45+
{
46+
"root_module": "./example/mod_bench.rs",
47+
"edition": "2018",
48+
"deps": [],
49+
"cfg": []
50+
}
51+
]
52+
},
53+
{
54+
"sysroot_src": "./build/stdlib/library",
55+
"crates": [
56+
{
57+
"root_module": "./example/std_example.rs",
58+
"edition": "2015",
59+
"deps": [],
60+
"cfg": []
61+
}
62+
]
63+
}
64+
]
65+
}
66+
}
67+
}
68+
}

Diff for: compiler/rustc_codegen_cranelift/Cargo.lock

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

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

56+
[[package]]
57+
name = "cranelift-bitset"
58+
version = "0.110.1"
59+
source = "registry+https://github.com/rust-lang/crates.io-index"
60+
checksum = "38a1dfc50dca188a15d938867c4400589530bcb0138f7022aae6d059d1d8c309"
61+
5662
[[package]]
5763
name = "cranelift-codegen"
58-
version = "0.109.0"
64+
version = "0.110.1"
5965
source = "registry+https://github.com/rust-lang/crates.io-index"
60-
checksum = "b9acf15cb22be42d07c3b57d7856329cb228b7315d385346149df2566ad5e4aa"
66+
checksum = "821c20c639350158ecca928dc2a244d0d1c9cef2377a378fc62a445a286eb1ca"
6167
dependencies = [
6268
"bumpalo",
6369
"cranelift-bforest",
70+
"cranelift-bitset",
6471
"cranelift-codegen-meta",
6572
"cranelift-codegen-shared",
6673
"cranelift-control",
@@ -77,39 +84,42 @@ dependencies = [
7784

7885
[[package]]
7986
name = "cranelift-codegen-meta"
80-
version = "0.109.0"
87+
version = "0.110.1"
8188
source = "registry+https://github.com/rust-lang/crates.io-index"
82-
checksum = "e934d301392b73b3f8b0540391fb82465a0f179a3cee7c726482ac4727efcc97"
89+
checksum = "064473f2fd59b44fa2c9aaa60de1f9c44db5e13521e28bc85d2b92ee535ef625"
8390
dependencies = [
8491
"cranelift-codegen-shared",
8592
]
8693

8794
[[package]]
8895
name = "cranelift-codegen-shared"
89-
version = "0.109.0"
96+
version = "0.110.1"
9097
source = "registry+https://github.com/rust-lang/crates.io-index"
91-
checksum = "8afb2a2566b3d54b854dfb288b3b187f6d3d17d6f762c92898207eba302931da"
98+
checksum = "d0f39b9ebfd2febdc2acfb9a0fca110665bcd5a6839502576307735ed07b2177"
9299

93100
[[package]]
94101
name = "cranelift-control"
95-
version = "0.109.0"
102+
version = "0.110.1"
96103
source = "registry+https://github.com/rust-lang/crates.io-index"
97-
checksum = "0100f33b704cdacd01ad66ff41f8c5030d57cbff078e2a4e49ab1822591299fa"
104+
checksum = "94e125c189c3a1ca8dfe209fc6f46edba058a6d24e0b92aff69459a15f4711e7"
98105
dependencies = [
99106
"arbitrary",
100107
]
101108

102109
[[package]]
103110
name = "cranelift-entity"
104-
version = "0.109.0"
111+
version = "0.110.1"
105112
source = "registry+https://github.com/rust-lang/crates.io-index"
106-
checksum = "a8cfdc315e5d18997093e040a8d234bea1ac1e118a716d3e30f40d449e78207b"
113+
checksum = "ea62eb109baec2247e1a6fa7b74c0f584b1e76e289cfd7017385b4b031fc8450"
114+
dependencies = [
115+
"cranelift-bitset",
116+
]
107117

108118
[[package]]
109119
name = "cranelift-frontend"
110-
version = "0.109.0"
120+
version = "0.110.1"
111121
source = "registry+https://github.com/rust-lang/crates.io-index"
112-
checksum = "0f74b84f16af2e982b0c0c72233503d9d55cbfe3865dbe807ca28dc6642a28b5"
122+
checksum = "722b089357aacb6c7528b2e59a5fe00917d61ce63448b25a3e477a5b7819fac8"
113123
dependencies = [
114124
"cranelift-codegen",
115125
"log",
@@ -119,15 +129,15 @@ dependencies = [
119129

120130
[[package]]
121131
name = "cranelift-isle"
122-
version = "0.109.0"
132+
version = "0.110.1"
123133
source = "registry+https://github.com/rust-lang/crates.io-index"
124-
checksum = "adf306d3dde705fb94bd48082f01d38c4ededc74293a4c007805f610bf08bc6e"
134+
checksum = "c4b5005a48288e7fc2a2991a377831c534e26929b063c379c018060727785a9b"
125135

126136
[[package]]
127137
name = "cranelift-jit"
128-
version = "0.109.0"
138+
version = "0.110.1"
129139
source = "registry+https://github.com/rust-lang/crates.io-index"
130-
checksum = "f5c5cfb8bbd3339cd25cca30e7516ff8fe5cb1feeddde6980cc4d5ef34df97bb"
140+
checksum = "f843932baf8d1025c5f114b929eda172d74b7163d058e0de2597c308b567c7e9"
131141
dependencies = [
132142
"anyhow",
133143
"cranelift-codegen",
@@ -145,9 +155,9 @@ dependencies = [
145155

146156
[[package]]
147157
name = "cranelift-module"
148-
version = "0.109.0"
158+
version = "0.110.1"
149159
source = "registry+https://github.com/rust-lang/crates.io-index"
150-
checksum = "7c9b0d4269b36fd858e6d8f20cd4938941186fb831488c361888cb2d6b33a9a6"
160+
checksum = "449819ef1c4af139cf1b9717916fcaea0e23248853d3e95135139773a842d3eb"
151161
dependencies = [
152162
"anyhow",
153163
"cranelift-codegen",
@@ -156,9 +166,9 @@ dependencies = [
156166

157167
[[package]]
158168
name = "cranelift-native"
159-
version = "0.109.0"
169+
version = "0.110.1"
160170
source = "registry+https://github.com/rust-lang/crates.io-index"
161-
checksum = "1ea0ebdef7aff4a79bcbc8b6495f31315f16b3bf311152f472eaa8d679352581"
171+
checksum = "3ae2d48f38081a9e679ad795bd36bb29bedeb5552fc1c195185bf9885fa1b16e"
162172
dependencies = [
163173
"cranelift-codegen",
164174
"libc",
@@ -167,9 +177,9 @@ dependencies = [
167177

168178
[[package]]
169179
name = "cranelift-object"
170-
version = "0.109.0"
180+
version = "0.110.1"
171181
source = "registry+https://github.com/rust-lang/crates.io-index"
172-
checksum = "19e33439ec20db058bc7cc3410f9748ab1ad90a35cef713d625c736f43e3820d"
182+
checksum = "3a39ee2cfd0ec485eca76f6b4dc17701a280fa406bc05137bb43f1635ed12c9f"
173183
dependencies = [
174184
"anyhow",
175185
"cranelift-codegen",
@@ -279,9 +289,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
279289

280290
[[package]]
281291
name = "object"
282-
version = "0.36.1"
292+
version = "0.36.2"
283293
source = "registry+https://github.com/rust-lang/crates.io-index"
284-
checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce"
294+
checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e"
285295
dependencies = [
286296
"crc32fast",
287297
"hashbrown 0.14.5",
@@ -411,9 +421,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
411421

412422
[[package]]
413423
name = "wasmtime-jit-icache-coherence"
414-
version = "22.0.0"
424+
version = "23.0.1"
415425
source = "registry+https://github.com/rust-lang/crates.io-index"
416-
checksum = "5afe2f0499542f9a4bcfa1b55bfdda803b6ade4e7c93c6b99e0f39dba44b0a91"
426+
checksum = "7fddf3e2980fb1d123d1fcac55189e417fdd3dba4f62139b5a0a1f9efe5669d5"
417427
dependencies = [
418428
"anyhow",
419429
"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.109.0", default-features = false, features = ["std", "unwind", "all-arch"] }
12-
cranelift-frontend = { version = "0.109.0" }
13-
cranelift-module = { version = "0.109.0" }
14-
cranelift-native = { version = "0.109.0" }
15-
cranelift-jit = { version = "0.109.0", optional = true }
16-
cranelift-object = { version = "0.109.0" }
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" }
1717
target-lexicon = "0.12.0"
1818
gimli = { version = "0.28", 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/Readme.md

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $ rustup component add rustc-codegen-cranelift-preview --toolchain nightly
1616

1717
Once it is installed, you can enable it with one of the following approaches:
1818
- `CARGO_PROFILE_DEV_CODEGEN_BACKEND=cranelift cargo +nightly build -Zcodegen-backend`
19-
- `RUSTFLAGS="-Zcodegen-backend=cranelift" cargo +nightly build`
2019
- Add the following to `.cargo/config.toml`:
2120
```toml
2221
[unstable]

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

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use crate::path::Dirs;
1+
use crate::path::{Dirs, RelPath};
22
use crate::prepare::GitRepo;
33
use crate::utils::{spawn_and_wait, CargoProject, Compiler};
44
use crate::{build_sysroot, CodegenBackend, SysrootKind};
55

66
static ABI_CAFE_REPO: GitRepo = GitRepo::github(
77
"Gankra",
88
"abi-cafe",
9-
"4c6dc8c9c687e2b3a760ff2176ce236872b37212",
10-
"588df6d66abbe105",
9+
"f1220cfd13b57f5c0082c26529163865ee25e115",
10+
"fe93a9acd461425d",
1111
"abi-cafe",
1212
);
1313

@@ -21,6 +21,7 @@ pub(crate) fn run(
2121
rustup_toolchain_name: Option<&str>,
2222
bootstrap_host_compiler: &Compiler,
2323
) {
24+
RelPath::DOWNLOAD.ensure_exists(dirs);
2425
ABI_CAFE_REPO.fetch(dirs);
2526
ABI_CAFE_REPO.patch(dirs);
2627

@@ -38,17 +39,23 @@ pub(crate) fn run(
3839
eprintln!("Running abi-cafe");
3940

4041
let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
41-
42-
let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs);
43-
cmd.arg("--");
44-
cmd.arg("--pairs");
45-
cmd.args(
42+
let pairs =
4643
if cfg!(not(any(target_os = "macos", all(target_os = "windows", target_env = "msvc")))) {
4744
&pairs[..]
4845
} else {
4946
&pairs[..2]
50-
},
51-
);
47+
};
48+
49+
let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs);
50+
cmd.arg("--");
51+
52+
// stdcall, vectorcall and such don't work yet
53+
cmd.arg("--conventions").arg("c").arg("--conventions").arg("rust");
54+
55+
for pair in pairs {
56+
cmd.arg("--pairs").arg(pair);
57+
}
58+
5259
cmd.arg("--add-rustc-codegen-backend");
5360
match cg_clif_dylib {
5461
CodegenBackend::Local(path) => {
@@ -58,6 +65,7 @@ pub(crate) fn run(
5865
cmd.arg(format!("cgclif:{name}"));
5966
}
6067
}
68+
6169
cmd.current_dir(ABI_CAFE.source_dir(dirs));
6270

6371
spawn_and_wait(cmd);

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

-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
312312
let obj = RTSTARTUP_SYSROOT.to_path(dirs).join(format!("{file}.o"));
313313
let mut build_rtstartup_cmd = Command::new(&compiler.rustc);
314314
build_rtstartup_cmd
315-
.arg("-Ainternal_features") // Missing #[allow(internal_features)]
316315
.arg("--target")
317316
.arg(&compiler.triple)
318317
.arg("--emit=obj")

0 commit comments

Comments
 (0)