Skip to content

Commit

Permalink
Auto merge of #77975 - bjorn3:cg_clif_subtree3, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Add cg_clif as optional codegen backend

Rustc_codegen_cranelift is an alternative codegen backend for rustc based on Cranelift. It has the potential to improve compilation times in debug mode. In my experience the compile time improvements over debug mode LLVM for a clean build are about 20-30% in most cases.

This PR adds cg_clif as optional codegen backend. By default it is only enabled for `./x.py check`. It can be enabled for `./x.py build` too by adding `cranelift` to the `rust.codegen-backends` array in `config.toml`.

MCP: rust-lang/compiler-team#270

r? `@Mark-Simulacrum`
  • Loading branch information
bors committed Oct 26, 2020
2 parents c96e11c + ac4f7de commit 35debd4
Show file tree
Hide file tree
Showing 98 changed files with 17,049 additions and 39 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -31,6 +31,7 @@ members = [
]
exclude = [
"build",
"compiler/rustc_codegen_cranelift",
# HACK(eddyb) This hardcodes the fact that our CI uses `/checkout/obj`.
"obj",
]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/.gitattributes
@@ -0,0 +1 @@
* text=auto eol=lf
54 changes: 54 additions & 0 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
@@ -0,0 +1,54 @@
name: CI

on:
- push
- pull_request

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v2

- name: Cache cargo installed crates
uses: actions/cache@v2
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-installed-crates

- name: Cache cargo registry and index
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}

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

- name: Prepare dependencies
run: |
git config --global user.email "user@example.com"
git config --global user.name "User"
./prepare.sh
- name: Test
run: |
# Enable backtraces for easier debugging
export RUST_BACKTRACE=1
# Reduce amount of benchmark runs as they are slow
export COMPILE_RUNS=2
export RUN_RUNS=2
./test.sh --release
14 changes: 14 additions & 0 deletions compiler/rustc_codegen_cranelift/.gitignore
@@ -0,0 +1,14 @@
target
**/*.rs.bk
*.rlib
*.o
perf.data
perf.data.old
*.events
*.string*
/build_sysroot/sysroot
/build_sysroot/sysroot_src
/rust
/rand
/regex
/simple-raytracer
53 changes: 53 additions & 0 deletions compiler/rustc_codegen_cranelift/.vscode/settings.json
@@ -0,0 +1,53 @@
{
// source for rustc_* is not included in the rust-src component; disable the errors about this
"rust-analyzer.diagnostics.disabled": ["unresolved-extern-crate"],
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
//"./build_sysroot/sysroot_src/src/libstd/Cargo.toml",
{
"roots": [
"./example/mini_core.rs",
"./example/mini_core_hello_world.rs",
"./example/mod_bench.rs"
],
"crates": [
{
"root_module": "./example/mini_core.rs",
"edition": "2018",
"deps": [],
"cfg": [],
},
{
"root_module": "./example/mini_core_hello_world.rs",
"edition": "2018",
"deps": [{ "crate": 0, "name": "mini_core" }],
"cfg": [],
},
{
"root_module": "./example/mod_bench.rs",
"edition": "2018",
"deps": [],
"cfg": [],
},
]
},
{
"roots": ["./scripts/filter_profile.rs"],
"crates": [
{
"root_module": "./scripts/filter_profile.rs",
"edition": "2018",
"deps": [{ "crate": 1, "name": "std" }],
"cfg": [],
},
{
"root_module": "./build_sysroot/sysroot_src/library/std/src/lib.rs",
"edition": "2018",
"deps": [],
"cfg": [],
},
]
}
]
}

0 comments on commit 35debd4

Please sign in to comment.