Skip to content

Commit

Permalink
Auto merge of #109169 - bjorn3:sync_cg_clif-2023-03-15, r=bjorn3
Browse files Browse the repository at this point in the history
Sync rustc_codegen_cranelift

Bunch of bug fixes this time. Also an update to Cranelift 0.93 which adds a brand new optimization pass which cg_clif exposes when using `--release`. And various improvements to cg_clif's test suite, making it faster to run. And finally two small perf improvements.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
  • Loading branch information
bors committed Mar 15, 2023
2 parents a167cbd + fce629d commit ab65486
Show file tree
Hide file tree
Showing 52 changed files with 873 additions and 792 deletions.
64 changes: 64 additions & 0 deletions compiler/rustc_codegen_cranelift/.github/workflows/abi-cafe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Abi-cafe

on:
- push

jobs:
abi_cafe:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.env.TARGET_TRIPLE }}
cancel-in-progress: true

defaults:
run:
shell: bash

strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
env:
TARGET_TRIPLE: x86_64-unknown-linux-gnu
- os: macos-latest
env:
TARGET_TRIPLE: x86_64-apple-darwin
- os: windows-latest
env:
TARGET_TRIPLE: x86_64-pc-windows-msvc
- os: windows-latest
env:
TARGET_TRIPLE: x86_64-pc-windows-gnu

steps:
- uses: actions/checkout@v3

- name: Cache cargo target dir
uses: actions/cache@v3
with:
path: build/cg_clif
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}

- name: Set MinGW as the default toolchain
if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
run: rustup set default-host x86_64-pc-windows-gnu

- name: Use sparse cargo registry
run: |
cat >> ~/.cargo/config.toml <<EOF
[unstable]
sparse-registry = true
EOF
- name: Prepare dependencies
run: ./y.rs prepare

- name: Build
run: ./y.rs build --sysroot none

- name: Test abi-cafe
env:
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
run: ./y.rs abi-cafe
59 changes: 1 addition & 58 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
rustfmt --check build_system/mod.rs
build:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 60

Expand Down Expand Up @@ -114,63 +114,6 @@ jobs:
run: ./y.rs test


abi_cafe:
runs-on: ${{ matrix.os }}
timeout-minutes: 60

defaults:
run:
shell: bash

strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
env:
TARGET_TRIPLE: x86_64-unknown-linux-gnu
- os: macos-latest
env:
TARGET_TRIPLE: x86_64-apple-darwin
- os: windows-latest
env:
TARGET_TRIPLE: x86_64-pc-windows-msvc
- os: windows-latest
env:
TARGET_TRIPLE: x86_64-pc-windows-gnu

steps:
- uses: actions/checkout@v3

- name: Cache cargo target dir
uses: actions/cache@v3
with:
path: build/cg_clif
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}

- name: Set MinGW as the default toolchain
if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
run: rustup set default-host x86_64-pc-windows-gnu

- name: Use sparse cargo registry
run: |
cat >> ~/.cargo/config.toml <<EOF
[unstable]
sparse-registry = true
EOF
- name: Prepare dependencies
run: ./y.rs prepare

- name: Build
run: ./y.rs build --sysroot none

- name: Test abi-cafe
env:
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
run: ./y.rs abi-cafe


bench:
runs-on: ubuntu-latest
timeout-minutes: 60
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ perf.data.old
/dist
/rust
/download
/git-fixed-subtree.sh
49 changes: 25 additions & 24 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "cranelift-bforest"
version = "0.92.0"
version = "0.93.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f3d54eab028f5805ae3b26fd60eca3f3a9cfb76b989d9bab173be3f61356cc3"
checksum = "a7379abaacee0f14abf3204a7606118f0465785252169d186337bcb75030815a"
dependencies = [
"cranelift-entity",
]

[[package]]
name = "cranelift-codegen"
version = "0.92.0"
version = "0.93.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2be1d5f2c3cca1efb691844bc1988b89c77291f13f778499a3f3c0cf49c0ed61"
checksum = "9489fa336927df749631f1008007ced2871068544f40a202ce6d93fbf2366a7b"
dependencies = [
"arrayvec",
"bumpalo",
Expand All @@ -87,30 +87,30 @@ dependencies = [

[[package]]
name = "cranelift-codegen-meta"
version = "0.92.0"
version = "0.93.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9b1b1089750ce4005893af7ee00bb08a2cf1c9779999c0f7164cbc8ad2e0d2"
checksum = "05bbb67da91ec721ed57cef2f7c5ef7728e1cd9bde9ffd3ef8601022e73e3239"
dependencies = [
"cranelift-codegen-shared",
]

[[package]]
name = "cranelift-codegen-shared"
version = "0.92.0"
version = "0.93.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc5fbaec51de47297fd7304986fd53c8c0030abbe69728a60d72e1c63559318d"
checksum = "418ecb2f36032f6665dc1a5e2060a143dbab41d83b784882e97710e890a7a16d"

[[package]]
name = "cranelift-entity"
version = "0.92.0"
version = "0.93.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dab984c94593f876090fae92e984bdcc74d9b1acf740ab5f79036001c65cba13"
checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705"

[[package]]
name = "cranelift-frontend"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e0cb3102d21a2fe5f3210af608748ddd0cd09825ac12d42dc56ed5ed8725fe0"
checksum = "7d361ed0373cf5f086b49c499aa72227b646a64f899f32e34312f97c0fadff75"
dependencies = [
"cranelift-codegen",
"log",
Expand All @@ -120,15 +120,15 @@ dependencies = [

[[package]]
name = "cranelift-isle"
version = "0.92.0"
version = "0.93.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72101dd1f441d629735143c41e00b3428f9267738176983ef588ff43382af0a0"
checksum = "649782a39ce99798dd6b4029e2bb318a2fbeaade1b4fa25330763c10c65bc358"

[[package]]
name = "cranelift-jit"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6557f8ce44d498777f2495aa58d9692a4a37d6f84aa445750d666cef770b6a5c"
checksum = "9c9909222db472fcc98d9e4e7192fa9d064dac63a3fa657df8c6daae86fb2604"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -145,19 +145,19 @@ dependencies = [

[[package]]
name = "cranelift-module"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88807e1c0c47ec02fe433333ccbe56b480425418b1470e333205e11650697d72"
checksum = "68689b83e52e605ba48652882d3fccc2e2e136abf139eb64ae667888ba0d52f8"
dependencies = [
"anyhow",
"cranelift-codegen",
]

[[package]]
name = "cranelift-native"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c22b0d9fcbe3fc5a1af9e7021b44ce42b930bcefac446ce22e02e8f9a0d67120"
checksum = "f98e4e99a353703475d5acb402b9c13482d41d8a4008b352559bd560afb90363"
dependencies = [
"cranelift-codegen",
"libc",
Expand All @@ -166,9 +166,9 @@ dependencies = [

[[package]]
name = "cranelift-object"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "341375758d7c3fedc0b5315f552e6f0feac46baf87c450a15e9455ef47c2b261"
checksum = "b7a006ce1d8dd11df67567d8673e5920f3a56441812aed52a007ffce8f1b20e9"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand Down Expand Up @@ -333,6 +333,7 @@ dependencies = [
"cranelift-frontend",
"cranelift-jit",
"cranelift-module",
"cranelift-native",
"cranelift-object",
"gimli",
"indexmap",
Expand Down Expand Up @@ -381,9 +382,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"

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

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { version = "0.92", features = ["unwind", "all-arch"] }
cranelift-frontend = { version = "0.92" }
cranelift-module = { version = "0.92" }
# NOTE vendored as src/cranelift_native.rs
# FIXME revert back to the external crate with Cranelift 0.93
#cranelift-native = { version = "0.92" }
cranelift-jit = { version = "0.92", optional = true }
cranelift-object = { version = "0.92" }
cranelift-codegen = { version = "0.93", features = ["unwind", "all-arch"] }
cranelift-frontend = { version = "0.93" }
cranelift-module = { version = "0.93" }
cranelift-native = { version = "0.93" }
cranelift-jit = { version = "0.93", optional = true }
cranelift-object = { version = "0.93" }
target-lexicon = "0.12.0"
gimli = { version = "0.26.0", default-features = false, features = ["write"]}
object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
Expand Down
15 changes: 6 additions & 9 deletions compiler/rustc_codegen_cranelift/build_sysroot/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.86"
version = "0.1.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dae98c88e576098d7ab13ebcb40cc43e5114b2beafe61a87cda9200649ff205"
checksum = "9fc9c2080d347a2c316518840ac9194644a9993dfa1e9778ef38979a339f5d8b"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -117,21 +117,20 @@ dependencies = [

[[package]]
name = "hermit-abi"
version = "0.2.6"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
dependencies = [
"compiler_builtins",
"libc",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
]

[[package]]
name = "libc"
version = "0.2.139"
version = "0.2.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -282,10 +281,8 @@ dependencies = [
name = "test"
version = "0.0.0"
dependencies = [
"cfg-if",
"core",
"getopts",
"libc",
"panic_abort",
"panic_unwind",
"proc_macro",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/build_sysroot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ alloc = { path = "./sysroot_src/library/alloc" }
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
test = { path = "./sysroot_src/library/test" }

compiler_builtins = { version = "0.1.39", default-features = false, features = ["no-asm"] }
compiler_builtins = { version = "0.1.87", default-features = false, features = ["no-asm"] }

[patch.crates-io]
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ pub(crate) fn build_sysroot(
let wrapper_name = wrapper_base_name.replace("____", wrapper);

let mut build_cargo_wrapper_cmd = Command::new(&bootstrap_host_compiler.rustc);
let wrapper_path = DIST_DIR.to_path(dirs).join(&wrapper_name);
build_cargo_wrapper_cmd
.env("TOOLCHAIN_NAME", toolchain_name.clone())
.arg(RelPath::SCRIPTS.to_path(dirs).join(&format!("{wrapper}.rs")))
.arg("-o")
.arg(DIST_DIR.to_path(dirs).join(wrapper_name))
.arg(&wrapper_path)
.arg("-Cstrip=debuginfo");
spawn_and_wait(build_cargo_wrapper_cmd);
try_hard_link(wrapper_path, BIN_DIR.to_path(dirs).join(wrapper_name));
}

let host = build_sysroot_for_triple(
Expand Down Expand Up @@ -247,6 +249,7 @@ fn build_clif_sysroot_for_triple(
if channel == "release" {
build_cmd.arg("--release");
}
build_cmd.arg("--locked");
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");
if compiler.triple.contains("apple") {
build_cmd.env("CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO", "packed");
Expand Down
Loading

0 comments on commit ab65486

Please sign in to comment.