Skip to content

Commit

Permalink
Auto merge of rust-lang#78711 - m-ou-se:rollup-pxqnny7, r=m-ou-se
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#77950 (Add support for SHA256 source file hashing)
 - rust-lang#78624 (Sync rustc_codegen_cranelift)
 - rust-lang#78626 (Improve errors about #[deprecated] attribute)
 - rust-lang#78659 (Corrected suggestion for generic parameters in `function_item_references` lint)
 - rust-lang#78687 (Suggest library/std when running all stage 0 tests)
 - rust-lang#78699 (Show more error information in lldb_batchmode)
 - rust-lang#78709 (Fix panic in bootstrap for non-workspace path dependencies.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Nov 3, 2020
2 parents 5cdf5b8 + a65507b commit 5629309
Show file tree
Hide file tree
Showing 77 changed files with 886 additions and 488 deletions.
35 changes: 30 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,17 @@ dependencies = [
"opaque-debug 0.2.3",
]

[[package]]
name = "md-5"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
dependencies = [
"block-buffer 0.9.0",
"digest 0.9.0",
"opaque-debug 0.3.0",
]

[[package]]
name = "mdbook"
version = "0.4.3"
Expand Down Expand Up @@ -2467,7 +2478,7 @@ checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
dependencies = [
"maplit",
"pest",
"sha-1",
"sha-1 0.8.2",
]

[[package]]
Expand Down Expand Up @@ -3281,14 +3292,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c267f15c3cfc82a8a441d2bf86bcccf299d1eb625822468e3d8ee6f7c5a1c89"
dependencies = [
"cfg-if 0.1.10",
"md-5",
"md-5 0.8.0",
"rustc-ap-rustc_arena",
"rustc-ap-rustc_data_structures",
"rustc-ap-rustc_index",
"rustc-ap-rustc_macros",
"rustc-ap-rustc_serialize",
"scoped-tls",
"sha-1",
"sha-1 0.8.2",
"tracing",
"unicode-width",
]
Expand Down Expand Up @@ -4138,14 +4149,15 @@ name = "rustc_span"
version = "0.0.0"
dependencies = [
"cfg-if 0.1.10",
"md-5",
"md-5 0.9.1",
"rustc_arena",
"rustc_data_structures",
"rustc_index",
"rustc_macros",
"rustc_serialize",
"scoped-tls",
"sha-1",
"sha-1 0.9.1",
"sha2",
"tracing",
"unicode-width",
]
Expand Down Expand Up @@ -4510,6 +4522,19 @@ dependencies = [
"opaque-debug 0.2.3",
]

[[package]]
name = "sha-1"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770"
dependencies = [
"block-buffer 0.9.0",
"cfg-if 0.1.10",
"cpuid-bool",
"digest 0.9.0",
"opaque-debug 0.3.0",
]

[[package]]
name = "sha2"
version = "0.9.1"
Expand Down
21 changes: 10 additions & 11 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,19 +637,15 @@ pub struct Deprecation {
}

/// Finds the deprecation attribute. `None` if none exists.
pub fn find_deprecation(sess: &Session, attrs: &[Attribute], item_sp: Span) -> Option<Deprecation> {
find_deprecation_generic(sess, attrs.iter(), item_sp)
pub fn find_deprecation(sess: &Session, attrs: &[Attribute]) -> Option<(Deprecation, Span)> {
find_deprecation_generic(sess, attrs.iter())
}

fn find_deprecation_generic<'a, I>(
sess: &Session,
attrs_iter: I,
item_sp: Span,
) -> Option<Deprecation>
fn find_deprecation_generic<'a, I>(sess: &Session, attrs_iter: I) -> Option<(Deprecation, Span)>
where
I: Iterator<Item = &'a Attribute>,
{
let mut depr: Option<Deprecation> = None;
let mut depr: Option<(Deprecation, Span)> = None;
let diagnostic = &sess.parse_sess.span_diagnostic;

'outer: for attr in attrs_iter {
Expand All @@ -658,8 +654,11 @@ where
continue;
}

if depr.is_some() {
struct_span_err!(diagnostic, item_sp, E0550, "multiple deprecated attributes").emit();
if let Some((_, span)) = &depr {
struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes")
.span_label(attr.span, "repeated deprecation attribute")
.span_label(*span, "first deprecation attribute")
.emit();
break;
}

Expand Down Expand Up @@ -780,7 +779,7 @@ where
sess.mark_attr_used(&attr);

let is_since_rustc_version = sess.check_name(attr, sym::rustc_deprecated);
depr = Some(Deprecation { since, note, suggestion, is_since_rustc_version });
depr = Some((Deprecation { since, note, suggestion, is_since_rustc_version }, attr.span));
}

depr
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Bootstrap rustc using cg_clif

on:
- push

jobs:
bootstrap_rustc:
runs-on: ubuntu-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
./scripts/test_bootstrap.sh
11 changes: 10 additions & 1 deletion compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ jobs:
export COMPILE_RUNS=2
export RUN_RUNS=2
./test.sh --release
./test.sh
- name: Package prebuilt cg_clif
run: tar cvfJ cg_clif.tar.xz build

- name: Upload prebuilt cg_clif
uses: actions/upload-artifact@v2
with:
name: cg_clif-${{ runner.os }}
path: cg_clif.tar.xz
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ perf.data
perf.data.old
*.events
*.string*
/build_sysroot/sysroot
/build
/build_sysroot/sysroot_src
/rust
/rand
Expand Down
20 changes: 10 additions & 10 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cranelift-bforest"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
dependencies = [
"cranelift-entity",
]

[[package]]
name = "cranelift-codegen"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
dependencies = [
"byteorder",
"cranelift-bforest",
Expand All @@ -70,7 +70,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
dependencies = [
"cranelift-codegen-shared",
"cranelift-entity",
Expand All @@ -79,17 +79,17 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"

[[package]]
name = "cranelift-entity"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"

[[package]]
name = "cranelift-frontend"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
dependencies = [
"cranelift-codegen",
"log",
Expand All @@ -100,7 +100,7 @@ dependencies = [
[[package]]
name = "cranelift-module"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -112,7 +112,7 @@ dependencies = [
[[package]]
name = "cranelift-native"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
dependencies = [
"cranelift-codegen",
"raw-cpuid",
Expand All @@ -122,7 +122,7 @@ dependencies = [
[[package]]
name = "cranelift-object"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -135,7 +135,7 @@ dependencies = [
[[package]]
name = "cranelift-simplejit"
version = "0.67.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
dependencies = [
"cranelift-codegen",
"cranelift-entity",
Expand Down
37 changes: 26 additions & 11 deletions compiler/rustc_codegen_cranelift/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,56 @@

> ⚠⚠⚠ Certain kinds of FFI don't work yet. ⚠⚠⚠
The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). This has the potential to improve compilation times in debug mode. If your project doesn't use any of the things listed under "Not yet supported", it should work fine. If not please open an issue.
The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift).
This has the potential to improve compilation times in debug mode.
If your project doesn't use any of the things listed under "Not yet supported", it should work fine.
If not please open an issue.

## Building
## Building and testing

```bash
$ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git
$ cd rustc_codegen_cranelift
$ ./prepare.sh # download and patch sysroot src and install hyperfine for benchmarking
$ ./test.sh --release
$ ./build.sh
```

To run the test suite replace the last command with:

```bash
$ ./test.sh
```

This will implicitly build cg_clif too. Both `build.sh` and `test.sh` accept a `--debug` argument to
build in debug mode.

Alternatively you can download a pre built version from [GHA]. It is listed in the artifacts section
of workflow runs. Unfortunately due to GHA restrictions you need to be logged in to access it.

[GHA]: https://github.com/bjorn3/rustc_codegen_cranelift/actions?query=branch%3Amaster+event%3Apush+is%3Asuccess

## Usage

rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects.

Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`prepare.sh` and `test.sh`).
Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`prepare.sh` and `build.sh` or `test.sh`).

### Cargo

In the directory with your project (where you can do the usual `cargo build`), run:

```bash
$ $cg_clif_dir/cargo.sh run
$ $cg_clif_dir/build/cargo.sh run
```

This should build and run your project with rustc_codegen_cranelift instead of the usual LLVM backend.

If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./test.sh`) you should set `CHANNEL="debug"`.

### Rustc

> You should prefer using the Cargo method.
```bash
$ $cg_clif_dir/target/release/cg_clif my_crate.rs
$ $cg_clif_dir/build/cg_clif my_crate.rs
```

### Jit mode
Expand All @@ -47,13 +62,13 @@ In jit mode cg_clif will immediately execute your code without creating an execu
> The jit mode will probably need cargo integration to make this possible.
```bash
$ $cg_clif_dir/cargo.sh jit
$ $cg_clif_dir/build/cargo.sh jit
```

or

```bash
$ $cg_clif_dir/target/release/cg_clif --jit my_crate.rs
$ $cg_clif_dir/build/cg_clif --jit my_crate.rs
```

### Shell
Expand All @@ -62,7 +77,7 @@ These are a few functions that allow you to easily run rust code from the shell

```bash
function jit_naked() {
echo "$@" | $cg_clif_dir/target/release/cg_clif - --jit
echo "$@" | $cg_clif_dir/build/cg_clif - --jit
}

function jit() {
Expand Down
Loading

0 comments on commit 5629309

Please sign in to comment.