Skip to content

Commit ef3d6fd

Browse files
committed
Auto merge of rust-lang#127162 - bjorn3:sync_cg_clif-2024-06-30, r=bjorn3
Subtree sync for rustc_codegen_cranelift The main highlight this time is support for arm64 macOS in cg_clif. A future PR will enable distributing it as rustup component. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2 parents 6c34855 + 9ec6a02 commit ef3d6fd

23 files changed

+440
-291
lines changed

compiler/rustc_codegen_cranelift/.github/workflows/abi-cafe.yml

-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ jobs:
5555
if: matrix.os == 'macos-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-apple-darwin'
5656
run: rustup set default-host x86_64-apple-darwin
5757

58-
- name: Select XCode version
59-
if: matrix.os == 'macos-latest'
60-
run: sudo xcode-select -s /Applications/Xcode_14.3.1.app
61-
6258
- name: Prepare dependencies
6359
run: ./y.sh prepare
6460

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ jobs:
6666
env:
6767
TARGET_TRIPLE: aarch64-unknown-linux-gnu
6868
apt_deps: gcc-aarch64-linux-gnu qemu-user
69+
- os: macos-latest
70+
env:
71+
TARGET_TRIPLE: aarch64-apple-darwin
6972
- os: ubuntu-latest
7073
env:
7174
TARGET_TRIPLE: s390x-unknown-linux-gnu
@@ -108,10 +111,6 @@ jobs:
108111
sudo apt-get update
109112
sudo apt-get install -y ${{ matrix.apt_deps }}
110113
111-
- name: Select XCode version
112-
if: matrix.os == 'macos-latest'
113-
run: sudo xcode-select -s /Applications/Xcode_14.3.1.app
114-
115114
- name: Prepare dependencies
116115
run: ./y.sh prepare
117116

@@ -214,6 +213,9 @@ jobs:
214213
- os: macos-latest
215214
env:
216215
TARGET_TRIPLE: x86_64-apple-darwin
216+
- os: macos-latest
217+
env:
218+
TARGET_TRIPLE: aarch64-apple-darwin
217219
# cross-compile from Linux to Windows using mingw
218220
- os: ubuntu-latest
219221
env:
@@ -248,10 +250,6 @@ jobs:
248250
sudo apt-get update
249251
sudo apt-get install -y gcc-mingw-w64-x86-64
250252
251-
- name: Select XCode version
252-
if: matrix.os == 'macos-latest'
253-
run: sudo xcode-select -s /Applications/Xcode_14.3.1.app
254-
255253
- name: Prepare dependencies
256254
run: ./y.sh prepare
257255

@@ -282,7 +280,8 @@ jobs:
282280
runs-on: ubuntu-latest
283281
timeout-minutes: 10
284282
if: ${{ github.ref == 'refs/heads/master' }}
285-
needs: [rustfmt, test, bench, dist]
283+
# FIXME add the bench job back to the dependency list once rust-lang/rust#125493 gets merged
284+
needs: [rustfmt, test, dist]
286285

287286
permissions:
288287
contents: write # for creating the dev tag and release

compiler/rustc_codegen_cranelift/Cargo.lock

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

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

5656
[[package]]
5757
name = "cranelift-codegen"
58-
version = "0.107.0"
58+
version = "0.109.0"
5959
source = "registry+https://github.com/rust-lang/crates.io-index"
60-
checksum = "304c455b28bf56372729acb356afbb55d622f2b0f2f7837aa5e57c138acaac4d"
60+
checksum = "b9acf15cb22be42d07c3b57d7856329cb228b7315d385346149df2566ad5e4aa"
6161
dependencies = [
6262
"bumpalo",
6363
"cranelift-bforest",
@@ -70,45 +70,46 @@ dependencies = [
7070
"hashbrown 0.14.3",
7171
"log",
7272
"regalloc2",
73+
"rustc-hash",
7374
"smallvec",
7475
"target-lexicon",
7576
]
7677

7778
[[package]]
7879
name = "cranelift-codegen-meta"
79-
version = "0.107.0"
80+
version = "0.109.0"
8081
source = "registry+https://github.com/rust-lang/crates.io-index"
81-
checksum = "1653c56b99591d07f67c5ca7f9f25888948af3f4b97186bff838d687d666f613"
82+
checksum = "e934d301392b73b3f8b0540391fb82465a0f179a3cee7c726482ac4727efcc97"
8283
dependencies = [
8384
"cranelift-codegen-shared",
8485
]
8586

8687
[[package]]
8788
name = "cranelift-codegen-shared"
88-
version = "0.107.0"
89+
version = "0.109.0"
8990
source = "registry+https://github.com/rust-lang/crates.io-index"
90-
checksum = "f5b6a9cf6b6eb820ee3f973a0db313c05dc12d370f37b4fe9630286e1672573f"
91+
checksum = "8afb2a2566b3d54b854dfb288b3b187f6d3d17d6f762c92898207eba302931da"
9192

9293
[[package]]
9394
name = "cranelift-control"
94-
version = "0.107.0"
95+
version = "0.109.0"
9596
source = "registry+https://github.com/rust-lang/crates.io-index"
96-
checksum = "d9d06e6bf30075fb6bed9e034ec046475093392eea1aff90eb5c44c4a033d19a"
97+
checksum = "0100f33b704cdacd01ad66ff41f8c5030d57cbff078e2a4e49ab1822591299fa"
9798
dependencies = [
9899
"arbitrary",
99100
]
100101

101102
[[package]]
102103
name = "cranelift-entity"
103-
version = "0.107.0"
104+
version = "0.109.0"
104105
source = "registry+https://github.com/rust-lang/crates.io-index"
105-
checksum = "29be04f931b73cdb9694874a295027471817f26f26d2f0ebe5454153176b6e3a"
106+
checksum = "a8cfdc315e5d18997093e040a8d234bea1ac1e118a716d3e30f40d449e78207b"
106107

107108
[[package]]
108109
name = "cranelift-frontend"
109-
version = "0.107.0"
110+
version = "0.109.0"
110111
source = "registry+https://github.com/rust-lang/crates.io-index"
111-
checksum = "a07fd7393041d7faa2f37426f5dc7fc04003b70988810e8c063beefeff1cd8f9"
112+
checksum = "0f74b84f16af2e982b0c0c72233503d9d55cbfe3865dbe807ca28dc6642a28b5"
112113
dependencies = [
113114
"cranelift-codegen",
114115
"log",
@@ -118,15 +119,15 @@ dependencies = [
118119

119120
[[package]]
120121
name = "cranelift-isle"
121-
version = "0.107.0"
122+
version = "0.109.0"
122123
source = "registry+https://github.com/rust-lang/crates.io-index"
123-
checksum = "f341d7938caa6dff8149dac05bb2b53fc680323826b83b4cf175ab9f5139a3c9"
124+
checksum = "adf306d3dde705fb94bd48082f01d38c4ededc74293a4c007805f610bf08bc6e"
124125

125126
[[package]]
126127
name = "cranelift-jit"
127-
version = "0.107.0"
128+
version = "0.109.0"
128129
source = "registry+https://github.com/rust-lang/crates.io-index"
129-
checksum = "42733555e06433f1461570e09dbd756dafc228b4dac75c597cdbdc518de07522"
130+
checksum = "f5c5cfb8bbd3339cd25cca30e7516ff8fe5cb1feeddde6980cc4d5ef34df97bb"
130131
dependencies = [
131132
"anyhow",
132133
"cranelift-codegen",
@@ -144,9 +145,9 @@ dependencies = [
144145

145146
[[package]]
146147
name = "cranelift-module"
147-
version = "0.107.0"
148+
version = "0.109.0"
148149
source = "registry+https://github.com/rust-lang/crates.io-index"
149-
checksum = "84950af02bb85f3da764d53a953b43bb29a732e793d4fe24637a61591be9a024"
150+
checksum = "7c9b0d4269b36fd858e6d8f20cd4938941186fb831488c361888cb2d6b33a9a6"
150151
dependencies = [
151152
"anyhow",
152153
"cranelift-codegen",
@@ -155,9 +156,9 @@ dependencies = [
155156

156157
[[package]]
157158
name = "cranelift-native"
158-
version = "0.107.0"
159+
version = "0.109.0"
159160
source = "registry+https://github.com/rust-lang/crates.io-index"
160-
checksum = "82af6066e6448d26eeabb7aa26a43f7ff79f8217b06bade4ee6ef230aecc8880"
161+
checksum = "1ea0ebdef7aff4a79bcbc8b6495f31315f16b3bf311152f472eaa8d679352581"
161162
dependencies = [
162163
"cranelift-codegen",
163164
"libc",
@@ -166,9 +167,9 @@ dependencies = [
166167

167168
[[package]]
168169
name = "cranelift-object"
169-
version = "0.107.0"
170+
version = "0.109.0"
170171
source = "registry+https://github.com/rust-lang/crates.io-index"
171-
checksum = "00af56107039ed150391df6f753298c7b08f2b6a2e0727d216b5fa599d684d8b"
172+
checksum = "19e33439ec20db058bc7cc3410f9748ab1ad90a35cef713d625c736f43e3820d"
172173
dependencies = [
173174
"anyhow",
174175
"cranelift-codegen",
@@ -278,9 +279,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
278279

279280
[[package]]
280281
name = "object"
281-
version = "0.33.0"
282+
version = "0.36.1"
282283
source = "registry+https://github.com/rust-lang/crates.io-index"
283-
checksum = "d8dd6c0cdf9429bce006e1362bfce61fa1bfd8c898a643ed8d2b471934701d3d"
284+
checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce"
284285
dependencies = [
285286
"crc32fast",
286287
"hashbrown 0.14.3",
@@ -410,10 +411,11 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
410411

411412
[[package]]
412413
name = "wasmtime-jit-icache-coherence"
413-
version = "20.0.0"
414+
version = "22.0.0"
414415
source = "registry+https://github.com/rust-lang/crates.io-index"
415-
checksum = "7a9f93a3289057b26dc75eb84d6e60d7694f7d169c7c09597495de6e016a13ff"
416+
checksum = "5afe2f0499542f9a4bcfa1b55bfdda803b6ade4e7c93c6b99e0f39dba44b0a91"
416417
dependencies = [
418+
"anyhow",
417419
"cfg-if",
418420
"libc",
419421
"windows-sys",

compiler/rustc_codegen_cranelift/Cargo.toml

+7-7
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.107.0", default-features = false, features = ["std", "unwind", "all-arch"] }
12-
cranelift-frontend = { version = "0.107.0" }
13-
cranelift-module = { version = "0.107.0" }
14-
cranelift-native = { version = "0.107.0" }
15-
cranelift-jit = { version = "0.107.0", optional = true }
16-
cranelift-object = { version = "0.107.0" }
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" }
1717
target-lexicon = "0.12.0"
1818
gimli = { version = "0.28", default-features = false, features = ["write"]}
19-
object = { version = "0.33", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
19+
object = { version = "0.36", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
2020

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

compiler/rustc_codegen_cranelift/Readme.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ For more docs on how to build and test see [build_system/usage.txt](build_system
7070
|FreeBSD|[^no-rustup]||||
7171
|AIX|[^xcoff]|N/A|N/A|[^xcoff]|
7272
|Other unixes|||||
73-
|macOS||[^apple-silicon]|N/A|N/A|
73+
|macOS||[^no-rustup]|N/A|N/A|
7474
|Windows|[^no-rustup]||N/A|N/A|
7575

7676
✅: Fully supported and tested
@@ -80,7 +80,6 @@ For more docs on how to build and test see [build_system/usage.txt](build_system
8080
Not all targets are available as rustup component for nightly. See notes in the platform support matrix.
8181

8282
[^xcoff]: XCOFF object file format is not supported.
83-
[^apple-silicon]: Tracked in [#1248](https://github.com/rust-lang/rustc_codegen_cranelift/issues/1248).
8483
[^no-rustup]: Not available as rustup component for nightly. You can build it yourself.
8584

8685
## Usage

compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs

-35
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,6 @@ fn build_clif_sysroot_for_triple(
267267
prefix.to_str().unwrap()
268268
));
269269
}
270-
rustflags.push("-Zunstable-options".to_owned());
271-
for (name, values) in EXTRA_CHECK_CFGS {
272-
rustflags.push(check_cfg_arg(name, *values));
273-
}
274270
compiler.rustflags.extend(rustflags);
275271
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
276272
if channel == "release" {
@@ -330,34 +326,3 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
330326

331327
Some(target_libs)
332328
}
333-
334-
// Copied from https://github.com/rust-lang/rust/blob/4fd98a4b1b100f5329c6efae18031791f64372d2/src/bootstrap/src/utils/helpers.rs#L569-L585
335-
/// Create a `--check-cfg` argument invocation for a given name
336-
/// and it's values.
337-
fn check_cfg_arg(name: &str, values: Option<&[&str]>) -> String {
338-
// Creating a string of the values by concatenating each value:
339-
// ',values("tvos","watchos")' or '' (nothing) when there are no values.
340-
let next = match values {
341-
Some(values) => {
342-
let mut tmp = values.iter().flat_map(|val| [",", "\"", val, "\""]).collect::<String>();
343-
344-
tmp.insert_str(1, "values(");
345-
tmp.push(')');
346-
tmp
347-
}
348-
None => "".to_string(),
349-
};
350-
format!("--check-cfg=cfg({name}{next})")
351-
}
352-
353-
const EXTRA_CHECK_CFGS: &[(&str, Option<&[&str]>)] = &[
354-
("bootstrap", None),
355-
("stdarch_intel_sde", None),
356-
("no_fp_fmt_parse", None),
357-
("no_global_oom_handling", None),
358-
("no_rc", None),
359-
("no_sync", None),
360-
("netbsd10", None),
361-
("backtrace_in_libstd", None),
362-
("target_arch", Some(&["xtensa"])),
363-
];

compiler/rustc_codegen_cranelift/build_system/tests.rs

+4-32
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ pub(crate) fn run_tests(
329329
struct TestRunner<'a> {
330330
is_native: bool,
331331
jit_supported: bool,
332-
use_unstable_features: bool,
333332
skip_tests: &'a [&'a str],
334333
dirs: Dirs,
335334
target_compiler: Compiler,
@@ -361,15 +360,7 @@ impl<'a> TestRunner<'a> {
361360
&& target_compiler.triple.contains("x86_64")
362361
&& !target_compiler.triple.contains("windows");
363362

364-
Self {
365-
is_native,
366-
jit_supported,
367-
use_unstable_features,
368-
skip_tests,
369-
dirs,
370-
target_compiler,
371-
stdlib_source,
372-
}
363+
Self { is_native, jit_supported, skip_tests, dirs, target_compiler, stdlib_source }
373364
}
374365

375366
fn run_testsuite(&self, tests: &[TestCase]) {
@@ -393,31 +384,13 @@ impl<'a> TestRunner<'a> {
393384
match *cmd {
394385
TestCaseCmd::Custom { func } => func(self),
395386
TestCaseCmd::BuildLib { source, crate_types } => {
396-
if self.use_unstable_features {
397-
self.run_rustc([source, "--crate-type", crate_types]);
398-
} else {
399-
self.run_rustc([
400-
source,
401-
"--crate-type",
402-
crate_types,
403-
"--cfg",
404-
"no_unstable_features",
405-
]);
406-
}
387+
self.run_rustc([source, "--crate-type", crate_types]);
407388
}
408389
TestCaseCmd::BuildBin { source } => {
409-
if self.use_unstable_features {
410-
self.run_rustc([source]);
411-
} else {
412-
self.run_rustc([source, "--cfg", "no_unstable_features"]);
413-
}
390+
self.run_rustc([source]);
414391
}
415392
TestCaseCmd::BuildBinAndRun { source, args } => {
416-
if self.use_unstable_features {
417-
self.run_rustc([source]);
418-
} else {
419-
self.run_rustc([source, "--cfg", "no_unstable_features"]);
420-
}
393+
self.run_rustc([source]);
421394
self.run_out_command(
422395
source.split('/').last().unwrap().split('.').next().unwrap(),
423396
args,
@@ -472,7 +445,6 @@ impl<'a> TestRunner<'a> {
472445
cmd.arg(&self.target_compiler.triple);
473446
cmd.arg("-Cpanic=abort");
474447
cmd.arg("-Zunstable-options");
475-
cmd.arg("--check-cfg=cfg(no_unstable_features)");
476448
cmd.arg("--check-cfg=cfg(jit)");
477449
cmd.args(args);
478450
cmd

0 commit comments

Comments
 (0)