Skip to content

Commit

Permalink
Rollup merge of rust-lang#130716 - bjorn3:sync_cg_clif-2024-09-22, r=…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
workingjubilee authored Sep 23, 2024
2 parents fc5b4d3 + afad3fb commit 9546c83
Show file tree
Hide file tree
Showing 31 changed files with 479 additions and 337 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/.cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ task:
freebsd_instance:
image: freebsd-13-2-release-amd64
setup_rust_script:
- pkg install -y git bash binutils
- pkg install -y git-tiny binutils
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh --default-toolchain none -y --profile=minimal
target_cache:
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.ref == 'refs/heads/master' }}
# FIXME add the bench job back to the dependency list once rust-lang/rust#125493 gets merged
needs: [rustfmt, test, dist]
needs: [rustfmt, test, bench, dist]

permissions:
contents: write # for creating the dev tag and release
Expand Down
64 changes: 32 additions & 32 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "cranelift-bforest"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "effa84ab2023f7138045ece6b326588c17447ca22e66db71ec15cb0a6c0c4ad2"
checksum = "b80c3a50b9c4c7e5b5f73c0ed746687774fc9e36ef652b110da8daebf0c6e0e6"
dependencies = [
"cranelift-entity",
]

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

[[package]]
name = "cranelift-codegen"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "821c20c639350158ecca928dc2a244d0d1c9cef2377a378fc62a445a286eb1ca"
checksum = "58258667ad10e468bfc13a8d620f50dfcd4bb35d668123e97defa2549b9ad397"
dependencies = [
"bumpalo",
"cranelift-bforest",
Expand All @@ -84,42 +84,42 @@ dependencies = [

[[package]]
name = "cranelift-codegen-meta"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "064473f2fd59b44fa2c9aaa60de1f9c44db5e13521e28bc85d2b92ee535ef625"
checksum = "043f0b702e529dcb07ff92bd7d40e7d5317b5493595172c5eb0983343751ee06"
dependencies = [
"cranelift-codegen-shared",
]

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

[[package]]
name = "cranelift-control"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94e125c189c3a1ca8dfe209fc6f46edba058a6d24e0b92aff69459a15f4711e7"
checksum = "32db15f08c05df570f11e8ab33cb1ec449a64b37c8a3498377b77650bef33d8b"
dependencies = [
"arbitrary",
]

[[package]]
name = "cranelift-entity"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea62eb109baec2247e1a6fa7b74c0f584b1e76e289cfd7017385b4b031fc8450"
checksum = "5289cdb399381a27e7bbfa1b42185916007c3d49aeef70b1d01cb4caa8010130"
dependencies = [
"cranelift-bitset",
]

[[package]]
name = "cranelift-frontend"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "722b089357aacb6c7528b2e59a5fe00917d61ce63448b25a3e477a5b7819fac8"
checksum = "31ba8ab24eb9470477e98ddfa3c799a649ac5a0d9a2042868c4c952133c234e8"
dependencies = [
"cranelift-codegen",
"log",
Expand All @@ -129,15 +129,15 @@ dependencies = [

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

[[package]]
name = "cranelift-jit"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f843932baf8d1025c5f114b929eda172d74b7163d058e0de2597c308b567c7e9"
checksum = "df32578a47582e49b4fc1f9a5786839d9be1fedaa9f00bea7612c54425663c6b"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -155,9 +155,9 @@ dependencies = [

[[package]]
name = "cranelift-module"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "449819ef1c4af139cf1b9717916fcaea0e23248853d3e95135139773a842d3eb"
checksum = "96094a758cdb543c9143f70817cd31069fecd49f50981a0fac06820ac011dc2f"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -166,9 +166,9 @@ dependencies = [

[[package]]
name = "cranelift-native"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ae2d48f38081a9e679ad795bd36bb29bedeb5552fc1c195185bf9885fa1b16e"
checksum = "46a42424c956bbc31fc5c2706073df896156c5420ae8fa2a5d48dbc7b295d71b"
dependencies = [
"cranelift-codegen",
"libc",
Expand All @@ -177,9 +177,9 @@ dependencies = [

[[package]]
name = "cranelift-object"
version = "0.110.1"
version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a39ee2cfd0ec485eca76f6b4dc17701a280fa406bc05137bb43f1635ed12c9f"
checksum = "1cf5e2484ab47fe38a3150747cdd2016535f13542a925acca152b63383a6591b"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand Down Expand Up @@ -213,9 +213,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"

[[package]]
name = "gimli"
version = "0.28.1"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
dependencies = [
"fallible-iterator",
"indexmap",
Expand Down Expand Up @@ -403,9 +403,9 @@ dependencies = [

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

[[package]]
name = "unicode-ident"
Expand All @@ -421,9 +421,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "wasmtime-jit-icache-coherence"
version = "23.0.1"
version = "24.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fddf3e2980fb1d123d1fcac55189e417fdd3dba4f62139b5a0a1f9efe5669d5"
checksum = "d15de8429db996f0d17a4163a35eccc3f874cbfb50f29c379951ea1bbb39452e"
dependencies = [
"anyhow",
"cfg-if",
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ crate-type = ["dylib"]

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

indexmap = "2.0.0"
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_codegen_cranelift/build_system/abi_cafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ static ABI_CAFE_REPO: GitRepo = GitRepo::github(
static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe_target");

pub(crate) fn run(
channel: &str,
sysroot_kind: SysrootKind,
dirs: &Dirs,
cg_clif_dylib: &CodegenBackend,
Expand All @@ -28,7 +27,6 @@ pub(crate) fn run(
eprintln!("Building sysroot for abi-cafe");
build_sysroot::build_sysroot(
dirs,
channel,
sysroot_kind,
cg_clif_dylib,
bootstrap_host_compiler,
Expand All @@ -38,12 +36,11 @@ pub(crate) fn run(

eprintln!("Running abi-cafe");

let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
let pairs =
let pairs: &[_] =
if cfg!(not(any(target_os = "macos", all(target_os = "windows", target_env = "msvc")))) {
&pairs[..]
&["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"]
} else {
&pairs[..2]
&["rustc_calls_cgclif", "cgclif_calls_rustc"]
};

let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs);
Expand Down
37 changes: 36 additions & 1 deletion compiler/rustc_codegen_cranelift/build_system/bench.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::env;
use std::io::Write;
use std::path::Path;
use std::process::Command;

use crate::path::{Dirs, RelPath};
use crate::prepare::GitRepo;
use crate::rustc_info::get_file_name;
use crate::utils::{hyperfine_command, spawn_and_wait, Compiler};
use crate::utils::{spawn_and_wait, Compiler};

static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
"ebobby",
Expand Down Expand Up @@ -128,3 +129,37 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
gha_step_summary.write_all(b"\n").unwrap();
}
}

#[must_use]
fn hyperfine_command(
warmup: u64,
runs: u64,
prepare: Option<&str>,
cmds: &[(&str, &str)],
markdown_export: &Path,
) -> Command {
let mut bench = Command::new("hyperfine");

bench.arg("--export-markdown").arg(markdown_export);

if warmup != 0 {
bench.arg("--warmup").arg(warmup.to_string());
}

if runs != 0 {
bench.arg("--runs").arg(runs.to_string());
}

if let Some(prepare) = prepare {
bench.arg("--prepare").arg(prepare);
}

for &(name, cmd) in cmds {
if name != "" {
bench.arg("-n").arg(name);
}
bench.arg(cmd);
}

bench
}
17 changes: 4 additions & 13 deletions compiler/rustc_codegen_cranelift/build_system/build_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ use crate::rustc_info::get_file_name;
use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env};
use crate::utils::{CargoProject, Compiler, LogGroup};

pub(crate) static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");

pub(crate) fn build_backend(
dirs: &Dirs,
channel: &str,
bootstrap_host_compiler: &Compiler,
use_unstable_features: bool,
) -> PathBuf {
Expand All @@ -19,8 +18,8 @@ pub(crate) fn build_backend(
let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, dirs);

let mut rustflags = rustflags_from_env("RUSTFLAGS");

rustflags.push("-Zallow-features=rustc_private".to_owned());
rustflags_to_cmd_env(&mut cmd, "RUSTFLAGS", &rustflags);

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

match channel {
"debug" => {}
"release" => {
cmd.arg("--release");
}
_ => unreachable!(),
}

rustflags_to_cmd_env(&mut cmd, "RUSTFLAGS", &rustflags);
cmd.arg("--release");

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

CG_CLIF
.target_dir(dirs)
.join(&bootstrap_host_compiler.triple)
.join(channel)
.join("release")
.join(get_file_name(&bootstrap_host_compiler.rustc, "rustc_codegen_cranelift", "dylib"))
}
Loading

0 comments on commit 9546c83

Please sign in to comment.