Skip to content

Commit

Permalink
Auto merge of #122208 - bjorn3:sync_cg_clif-2024-03-08, r=bjorn3
Browse files Browse the repository at this point in the history
Subtree sync for rustc_codegen_cranelift

The main highlight this time is a bunch of new vendor intrinsics. Cranelift has also been updated to 0.105. And there were a bunch of big-endian fixes.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
  • Loading branch information
bors committed Mar 8, 2024
2 parents 46b180e + 8960fe0 commit 01d73d4
Show file tree
Hide file tree
Showing 20 changed files with 308 additions and 122 deletions.
17 changes: 9 additions & 8 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ jobs:
env:
TARGET_TRIPLE: x86_64-apple-darwin
# cross-compile from Linux to Windows using mingw
- os: ubuntu-latest
env:
TARGET_TRIPLE: x86_64-pc-windows-gnu
# FIXME The wine version in Ubuntu 22.04 is missing ProcessPrng
#- os: ubuntu-latest
# env:
# TARGET_TRIPLE: x86_64-pc-windows-gnu
- os: ubuntu-latest
env:
TARGET_TRIPLE: aarch64-unknown-linux-gnu
Expand Down Expand Up @@ -80,11 +81,11 @@ jobs:
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
run: rustup set default-host x86_64-pc-windows-gnu

- name: Install MinGW toolchain and wine
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
#- name: Install MinGW toolchain and wine
# if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
# run: |
# sudo apt-get update
# sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable

- name: Install AArch64 toolchain and qemu
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
Expand Down
23 changes: 13 additions & 10 deletions compiler/rustc_codegen_cranelift/.gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
/target
/build_system/target
**/*.rs.bk
*.rlib
*.o
perf.data
perf.data.old
*.events
*.string*
# Build artifacts during normal use
/y.bin
/y.bin.dSYM
/y.exe
/y.pdb
/download
/build
/dist
/target
/build_system/target

# Downloaded by certain scripts
/rust
/download
/git-fixed-subtree.sh

# Various things that can be created during development
*.rlib
*.o
perf.data
perf.data.old
*.mm_profdata
56 changes: 28 additions & 28 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "cranelift-bforest"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d819feeda4c420a18f1e28236ca0ce1177b22bf7c8a44ddee92dfe40de15bcf0"
checksum = "9515fcc42b6cb5137f76b84c1a6f819782d0cf12473d145d3bc5cd67eedc8bc2"
dependencies = [
"cranelift-entity",
]

[[package]]
name = "cranelift-codegen"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9b8d03d5bdbca7e5f72b0e0a0f69933ed1f09e24be6c075aa6fe3f802b0cc0c"
checksum = "1ad827c6071bfe6d22de1bc331296a29f9ddc506ff926d8415b435ec6a6efce0"
dependencies = [
"bumpalo",
"cranelift-bforest",
Expand All @@ -76,39 +76,39 @@ dependencies = [

[[package]]
name = "cranelift-codegen-meta"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3fd3664e38e51649b17dc30cfdd561273fe2f590dcd013fb75d9eabc6272dfb"
checksum = "10e6b36237a9ca2ce2fb4cc7741d418a080afa1327402138412ef85d5367bef1"
dependencies = [
"cranelift-codegen-shared",
]

[[package]]
name = "cranelift-codegen-shared"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b031ec5e605828975952622b5a77d49126f20ffe88d33719a0af66b23a0fc36"
checksum = "c36bf4bfb86898a94ccfa773a1f86e8a5346b1983ff72059bdd2db4600325251"

[[package]]
name = "cranelift-control"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fada054d017cf2ed8f7ed2336e0517fc1b19e6825be1790de9eb00c94788362b"
checksum = "7cbf36560e7a6bd1409ca91e7b43b2cc7ed8429f343d7605eadf9046e8fac0d0"
dependencies = [
"arbitrary",
]

[[package]]
name = "cranelift-entity"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "177b6f94ae8de6348eb45bf977c79ab9e3c40fc3ac8cb7ed8109560ea39bee7d"
checksum = "a71e11061a75b1184c09bea97c026a88f08b59ade96a7bb1f259d4ea0df2e942"

[[package]]
name = "cranelift-frontend"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebebd23a69a23e3ddea78e98ff3a2de222e88c8e045d81ef4a72f042e0d79dbd"
checksum = "af5d4da63143ee3485c7bcedde0a818727d737d1083484a0ceedb8950c89e495"
dependencies = [
"cranelift-codegen",
"log",
Expand All @@ -118,15 +118,15 @@ dependencies = [

[[package]]
name = "cranelift-isle"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1571bfc14df8966d12c6121b5325026591a4b4009e22fea0fe3765ab7cd33b96"
checksum = "457a9832b089e26f5eea70dcf49bed8ec6edafed630ce7c83161f24d46ab8085"

[[package]]
name = "cranelift-jit"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f61e236d7622c3c43016e8b0f3ba27136e21ac7de328c7fda902e61db1de851"
checksum = "0af95fe68d5a10919012c8db82b1d59820405b8001c8c6d05f94b08031334fa9"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -144,9 +144,9 @@ dependencies = [

[[package]]
name = "cranelift-module"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30c6820342015c5009070e3e48d1da7b13521399de904663f1c84f5ee839657"
checksum = "11b0b201fa10a4014062d4c56c307c8d18fdf9a84cb5279efe6080241f42c7a7"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -155,9 +155,9 @@ dependencies = [

[[package]]
name = "cranelift-native"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35a69c37e0c10b46fe5527f2397ac821046efbf5f7ec112c8b84df25712f465b"
checksum = "9b490d579df1ce365e1ea359e24ed86d82289fa785153327c2f6a69a59a731e4"
dependencies = [
"cranelift-codegen",
"libc",
Expand All @@ -166,9 +166,9 @@ dependencies = [

[[package]]
name = "cranelift-object"
version = "0.104.0"
version = "0.105.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24425a329b4343177d5f1852243841dcec17f929d72c0e7f41262140155e55e7"
checksum = "fb7e821ac6db471bcdbd004e5a4fa0d374f1046bd3a2ce278c332e0b0c01ca63"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand Down Expand Up @@ -241,9 +241,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.148"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"

[[package]]
name = "libloading"
Expand Down Expand Up @@ -410,9 +410,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "wasmtime-jit-icache-coherence"
version = "17.0.0"
version = "18.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdc26415bb89e9ccd3bdc498fef63aabf665c4c0dd710c107691deb9694955da"
checksum = "33f4121cb29dda08139b2824a734dd095d83ce843f2d613a84eb580b9cfc17ac"
dependencies = [
"cfg-if",
"libc",
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ crate-type = ["dylib"]

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { version = "0.104", default-features = false, features = ["std", "unwind", "all-arch"] }
cranelift-frontend = { version = "0.104" }
cranelift-module = { version = "0.104" }
cranelift-native = { version = "0.104" }
cranelift-jit = { version = "0.104", optional = true }
cranelift-object = { version = "0.104" }
cranelift-codegen = { version = "0.105.2", default-features = false, features = ["std", "unwind", "all-arch"] }
cranelift-frontend = { version = "0.105.2" }
cranelift-module = { version = "0.105.2" }
cranelift-native = { version = "0.105.2" }
cranelift-jit = { version = "0.105.2", optional = true }
cranelift-object = { version = "0.105.2" }
target-lexicon = "0.12.0"
gimli = { version = "0.28", default-features = false, features = ["write"]}
object = { version = "0.32", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_codegen_cranelift/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ You need to do this steps to successfully compile and use the cranelift backend

You can also set `rust-analyzer.rustc.source` to your rust workspace to get rust-analyzer to understand your changes.

## Configuration

See the documentation on the `BackendConfig` struct in [config.rs](src/config.rs) for all
configuration options.

## Not yet supported

* SIMD ([tracked here](https://github.com/rust-lang/rustc_codegen_cranelift/issues/171), `std::simd` fully works, `std::arch` is partially supported)
Expand Down
27 changes: 21 additions & 6 deletions compiler/rustc_codegen_cranelift/build_system/prepare.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::ffi::OsStr;
use std::fs;
use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
use std::process::Command;

Expand Down Expand Up @@ -71,7 +72,11 @@ fn hash_file(file: &std::path::Path) -> u64 {
let contents = std::fs::read(file).unwrap();
#[allow(deprecated)]
let mut hasher = std::hash::SipHasher::new();
std::hash::Hash::hash(&contents, &mut hasher);
// The following is equivalent to
// std::hash::Hash::hash(&contents, &mut hasher);
// but gives the same result independent of host byte order.
hasher.write_usize(contents.len().to_le());
Hash::hash_slice(&contents, &mut hasher);
std::hash::Hasher::finish(&hasher)
}

Expand All @@ -80,16 +85,26 @@ fn hash_dir(dir: &std::path::Path) -> u64 {
for entry in std::fs::read_dir(dir).unwrap() {
let entry = entry.unwrap();
if entry.file_type().unwrap().is_dir() {
sub_hashes
.insert(entry.file_name().to_str().unwrap().to_owned(), hash_dir(&entry.path()));
sub_hashes.insert(
entry.file_name().to_str().unwrap().to_owned(),
hash_dir(&entry.path()).to_le(),
);
} else {
sub_hashes
.insert(entry.file_name().to_str().unwrap().to_owned(), hash_file(&entry.path()));
sub_hashes.insert(
entry.file_name().to_str().unwrap().to_owned(),
hash_file(&entry.path()).to_le(),
);
}
}
#[allow(deprecated)]
let mut hasher = std::hash::SipHasher::new();
std::hash::Hash::hash(&sub_hashes, &mut hasher);
// The following is equivalent to
// std::hash::Hash::hash(&sub_hashes, &mut hasher);
// but gives the same result independent of host byte order.
hasher.write_usize(sub_hashes.len().to_le());
for elt in sub_hashes {
elt.hash(&mut hasher);
}
std::hash::Hasher::finish(&hasher)
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
"rust-lang",
"portable-simd",
"97007cc2e70df8c97326ce896a79e2f0ce4dd98b",
"e54a16035cedf205",
"5794c837bc605c4cd9dbb884285976dfdb293cce",
"a64d8fdd0ed0d9c4",
"portable-simd",
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ index 42a26ae..5ac1042 100644
+#![cfg(test)]
#![feature(alloc_layout_extra)]
#![feature(array_chunks)]
#![feature(array_methods)]
#![feature(array_windows)]
--
2.21.0 (Apple Git-122)

This file was deleted.

9 changes: 5 additions & 4 deletions compiler/rustc_codegen_cranelift/patches/stdlib-lock.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ dependencies = [

[[package]]
name = "hermit-abi"
version = "0.3.3"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
Expand All @@ -161,9 +161,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.150"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -398,6 +398,7 @@ version = "0.0.0"
dependencies = [
"core",
"getopts",
"libc",
"panic_abort",
"panic_unwind",
"std",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-01-26"
channel = "nightly-2024-03-08"
components = ["rust-src", "rustc-dev", "llvm-tools"]
1 change: 0 additions & 1 deletion compiler/rustc_codegen_cranelift/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ignore = [
"y.rs",
"example/gen_block_iterate.rs", # uses edition 2024
]

Expand Down
Loading

0 comments on commit 01d73d4

Please sign in to comment.