Skip to content

Commit 97a2894

Browse files
committed
Auto merge of #117031 - bjorn3:sync_cg_clif-2023-10-21, r=bjorn3
Sync rustc_codegen_cranelift The main highlights this time is new support for riscv64 linux enabled by a cranelift update. I have also updated some of the crates built as part of cg_clif's test suite which enabled removing several patches for them. And finally I have fixed a couple of tests in rustc's test suite with cg_clif. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler +subtree-sync
2 parents 1c05d50 + e07f47b commit 97a2894

20 files changed

+163
-493
lines changed

compiler/rustc_codegen_cranelift/.cirrus.yml

Lines changed: 1 addition & 1 deletion
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
6+
- pkg install -y git bash 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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ jobs:
5050
- os: ubuntu-latest
5151
env:
5252
TARGET_TRIPLE: aarch64-unknown-linux-gnu
53-
# s390x requires QEMU 6.1 or greater, we could build it from source, but ubuntu 22.04 comes with 6.2 by default
5453
- os: ubuntu-latest
5554
env:
5655
TARGET_TRIPLE: s390x-unknown-linux-gnu
56+
- os: ubuntu-latest
57+
env:
58+
TARGET_TRIPLE: riscv64gc-unknown-linux-gnu
5759
- os: windows-latest
5860
env:
5961
TARGET_TRIPLE: x86_64-pc-windows-msvc
@@ -92,6 +94,12 @@ jobs:
9294
sudo apt-get update
9395
sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
9496
97+
- name: Install riscv64gc toolchain and qemu
98+
if: matrix.env.TARGET_TRIPLE == 'riscv64gc-unknown-linux-gnu'
99+
run: |
100+
sudo apt-get update
101+
sudo apt-get install -y gcc-riscv64-linux-gnu qemu-user
102+
95103
- name: Prepare dependencies
96104
run: ./y.sh prepare
97105

compiler/rustc_codegen_cranelift/Cargo.lock

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
4545

4646
[[package]]
4747
name = "cranelift-bforest"
48-
version = "0.100.0"
48+
version = "0.101.0"
4949
source = "registry+https://github.com/rust-lang/crates.io-index"
50-
checksum = "03b9d1a9e776c27ad55d7792a380785d1fe8c2d7b099eed8dbd8f4af2b598192"
50+
checksum = "8e5e1df0da8488dd03b34afc134ba84b754d61862cc465932a9e5d07952f661e"
5151
dependencies = [
5252
"cranelift-entity",
5353
]
5454

5555
[[package]]
5656
name = "cranelift-codegen"
57-
version = "0.100.0"
57+
version = "0.101.0"
5858
source = "registry+https://github.com/rust-lang/crates.io-index"
59-
checksum = "5528483314c2dd5da438576cd8a9d0b3cedad66fb8a4727f90cd319a81950038"
59+
checksum = "77a17ca4e699a0aaf49a0c88f6311a864f321048aa63f6b787cab20eb5f93f10"
6060
dependencies = [
6161
"bumpalo",
6262
"cranelift-bforest",
@@ -75,39 +75,39 @@ dependencies = [
7575

7676
[[package]]
7777
name = "cranelift-codegen-meta"
78-
version = "0.100.0"
78+
version = "0.101.0"
7979
source = "registry+https://github.com/rust-lang/crates.io-index"
80-
checksum = "0f46a8318163f7682e35b8730ba93c1b586a2da8ce12a0ed545efc1218550f70"
80+
checksum = "022f2793cdade1d37a1f755ac42938a3f832f533eac6cafc8b26b209544c3c06"
8181
dependencies = [
8282
"cranelift-codegen-shared",
8383
]
8484

8585
[[package]]
8686
name = "cranelift-codegen-shared"
87-
version = "0.100.0"
87+
version = "0.101.0"
8888
source = "registry+https://github.com/rust-lang/crates.io-index"
89-
checksum = "37d1239cfd50eecfaed468d46943f8650e32969591868ad50111613704da6c70"
89+
checksum = "a4d72dbb83c2ad788dec4ad0843070973cb48c35a3ca19b1e7437ac40834fd9c"
9090

9191
[[package]]
9292
name = "cranelift-control"
93-
version = "0.100.0"
93+
version = "0.101.0"
9494
source = "registry+https://github.com/rust-lang/crates.io-index"
95-
checksum = "bcc530560c8f16cc1d4dd7ea000c56f519c60d1a914977abe849ce555c35a61d"
95+
checksum = "ae07cf26dcc90d546826d747ac63b6c40c916f34b03e92a6ae0422c28d771b8a"
9696
dependencies = [
9797
"arbitrary",
9898
]
9999

100100
[[package]]
101101
name = "cranelift-entity"
102-
version = "0.100.0"
102+
version = "0.101.0"
103103
source = "registry+https://github.com/rust-lang/crates.io-index"
104-
checksum = "f333fa641a9ad2bff0b107767dcb972c18c2bfab7969805a1d7e42449ccb0408"
104+
checksum = "c2fe6b7e49820893691aea497f36257e9d6f52061d8c4758d61d802d5f101a3d"
105105

106106
[[package]]
107107
name = "cranelift-frontend"
108-
version = "0.100.0"
108+
version = "0.101.0"
109109
source = "registry+https://github.com/rust-lang/crates.io-index"
110-
checksum = "06abf6563015a80f03f8bc4df307d0a81363f4eb73108df3a34f6e66fb6d5307"
110+
checksum = "44f497576ca3674581581601b6a55ccc1b43447217648c880e5bce70db3cf659"
111111
dependencies = [
112112
"cranelift-codegen",
113113
"log",
@@ -117,15 +117,15 @@ dependencies = [
117117

118118
[[package]]
119119
name = "cranelift-isle"
120-
version = "0.100.0"
120+
version = "0.101.0"
121121
source = "registry+https://github.com/rust-lang/crates.io-index"
122-
checksum = "0eb29d0edc8a5c029ed0f7ca77501f272738e3c410020b4a00f42ffe8ad2a8aa"
122+
checksum = "b96aa02eac00fffee13b0cd37d17874ccdb3d5458983041accd825ef78ce6454"
123123

124124
[[package]]
125125
name = "cranelift-jit"
126-
version = "0.100.0"
126+
version = "0.101.0"
127127
source = "registry+https://github.com/rust-lang/crates.io-index"
128-
checksum = "d16e8c5e212b1e63658aada17553497e7a259acab61f044d1f185527efa609fb"
128+
checksum = "b1d6e0e308c873eefc185745a6b21daec2a10f7554c9fb67e334c2d7d756d979"
129129
dependencies = [
130130
"anyhow",
131131
"cranelift-codegen",
@@ -143,9 +143,9 @@ dependencies = [
143143

144144
[[package]]
145145
name = "cranelift-module"
146-
version = "0.100.0"
146+
version = "0.101.0"
147147
source = "registry+https://github.com/rust-lang/crates.io-index"
148-
checksum = "d3b5fd273e1a959e920c7a9d790b1646d31acc8782bb549bad5ab85dd2fc9aa7"
148+
checksum = "c1aa8ebb06eced4e478c3f94f1d65d4e7c93493f4640057912b27a3e34b84841"
149149
dependencies = [
150150
"anyhow",
151151
"cranelift-codegen",
@@ -154,9 +154,9 @@ dependencies = [
154154

155155
[[package]]
156156
name = "cranelift-native"
157-
version = "0.100.0"
157+
version = "0.101.0"
158158
source = "registry+https://github.com/rust-lang/crates.io-index"
159-
checksum = "006056a7fa920870bad06bf8e1b3033d70cbb7ee625b035efa9d90882a931868"
159+
checksum = "2870170ca44054b202c737626607b87be6e35655084bd94a6ff807a5812ba7df"
160160
dependencies = [
161161
"cranelift-codegen",
162162
"libc",
@@ -165,9 +165,9 @@ dependencies = [
165165

166166
[[package]]
167167
name = "cranelift-object"
168-
version = "0.100.0"
168+
version = "0.101.0"
169169
source = "registry+https://github.com/rust-lang/crates.io-index"
170-
checksum = "9c8be1b0e7720f30fec31be0c0b0b23caef2a73fa751190c6a251c1362e8f8c9"
170+
checksum = "20647761742d17dabac8205da958910ede78599550e06418a16711a3ee2fc897"
171171
dependencies = [
172172
"anyhow",
173173
"cranelift-codegen",
@@ -374,9 +374,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
374374

375375
[[package]]
376376
name = "wasmtime-jit-icache-coherence"
377-
version = "13.0.0"
377+
version = "14.0.0"
378378
source = "registry+https://github.com/rust-lang/crates.io-index"
379-
checksum = "c6ff5f3707a5e3797deeeeac6ac26b2e1dd32dbc06693c0ab52e8ac4d18ec706"
379+
checksum = "a3a5dda53ad6993f9b0a2d65fb49e0348a7232a27a8794064122870d6ee19eb2"
380380
dependencies = [
381381
"cfg-if",
382382
"libc",

compiler/rustc_codegen_cranelift/Cargo.toml

Lines changed: 6 additions & 6 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.100", features = ["unwind", "all-arch"] }
12-
cranelift-frontend = { version = "0.100" }
13-
cranelift-module = { version = "0.100" }
14-
cranelift-native = { version = "0.100" }
15-
cranelift-jit = { version = "0.100", optional = true }
16-
cranelift-object = { version = "0.100" }
11+
cranelift-codegen = { version = "0.101", features = ["unwind", "all-arch"] }
12+
cranelift-frontend = { version = "0.101" }
13+
cranelift-module = { version = "0.101" }
14+
cranelift-native = { version = "0.101" }
15+
cranelift-jit = { version = "0.101", optional = true }
16+
cranelift-object = { version = "0.101" }
1717
target-lexicon = "0.12.0"
1818
gimli = { version = "0.28", default-features = false, features = ["write"]}
1919
object = { version = "0.32", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::env;
12
use std::fs;
23
use std::path::{Path, PathBuf};
34
use std::process::Command;
@@ -259,6 +260,14 @@ fn build_clif_sysroot_for_triple(
259260
// inlining.
260261
rustflags.push("-Zinline-mir".to_owned());
261262
}
263+
if let Some(prefix) = env::var_os("CG_CLIF_STDLIB_REMAP_PATH_PREFIX") {
264+
rustflags.push("--remap-path-prefix".to_owned());
265+
rustflags.push(format!(
266+
"{}={}",
267+
STDLIB_SRC.to_path(dirs).to_str().unwrap(),
268+
prefix.to_str().unwrap()
269+
));
270+
}
262271
compiler.rustflags.extend(rustflags);
263272
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
264273
maybe_incremental(&mut build_cmd);

compiler/rustc_codegen_cranelift/build_system/prepare.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ impl GitRepo {
143143
RelPath::PATCHES.to_path(dirs).join(format!("{}-lock.toml", self.patch_name));
144144
let target_lockfile = download_dir.join("Cargo.lock");
145145
if source_lockfile.exists() {
146+
assert!(!target_lockfile.exists());
146147
fs::copy(source_lockfile, target_lockfile).unwrap();
147148
} else {
148149
assert!(target_lockfile.exists());

compiler/rustc_codegen_cranelift/build_system/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
104104
pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
105105
"rust-random",
106106
"rand",
107-
"f3dd0b885c4597b9617ca79987a0dd899ab29fcb",
108-
"3f869e4fcd602b66",
107+
"9a02c819cc1e4ec6959ae25eafbb5cf6acb68234",
108+
"4934f0afb1d1c2ca",
109109
"rand",
110110
);
111111

@@ -125,7 +125,7 @@ pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
125125
"rust-lang",
126126
"portable-simd",
127127
"4825b2a64d765317066948867e8714674419359b",
128-
"8b188cc41f5af835",
128+
"9e67d07c00f5fb0b",
129129
"portable-simd",
130130
);
131131

compiler/rustc_codegen_cranelift/build_system/utils.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ impl Compiler {
4242
"/usr/s390x-linux-gnu".to_owned(),
4343
];
4444
}
45+
"riscv64gc-unknown-linux-gnu" => {
46+
// We are cross-compiling for riscv64. Use the correct linker and run tests in qemu.
47+
self.rustflags.push("-Clinker=riscv64-linux-gnu-gcc".to_owned());
48+
self.rustdocflags.push("-Clinker=riscv64-linux-gnu-gcc".to_owned());
49+
self.runner = vec![
50+
"qemu-riscv64".to_owned(),
51+
"-L".to_owned(),
52+
"/usr/riscv64-linux-gnu".to_owned(),
53+
];
54+
}
4555
"x86_64-pc-windows-gnu" => {
4656
// We are cross-compiling for Windows. Run tests in wine.
4757
self.runner = vec!["wine".to_owned()];

compiler/rustc_codegen_cranelift/patches/0002-rand-Disable-failing-test.patch

Lines changed: 0 additions & 24 deletions
This file was deleted.

compiler/rustc_codegen_cranelift/patches/0003-rand-Disable-rand-tests-on-mingw.patch

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)