Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync rustc_codegen_cranelift #84749

Merged
merged 61 commits into from
May 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
07968a0
Merge commit '0969bc6dde001e01e7e1f58c8ccd7750f8a49ae1' into sync_cg_…
bjorn3 Mar 29, 2021
5417278
Sync from rust 3aedcf06b73fc36feeebca3d579e1d2a6c40acc5
bjorn3 Mar 29, 2021
6e79943
Add an Mmap wrapper to rustc_data_structures
bjorn3 Mar 29, 2021
afe74d7
Build with `-Cpanic=unwind` by default
bjorn3 Mar 31, 2021
a793be8
Remove the stack2reg optimization completely
bjorn3 Mar 31, 2021
2ceb527
Remove the cold block optimization
bjorn3 Mar 31, 2021
ab425a4
Revert "Build with `-Cpanic=unwind` by default"
bjorn3 Mar 31, 2021
2cb13ca
Sync from rust 354cc751b74e813f180755fa67bebcb669825755
bjorn3 Apr 6, 2021
8114d93
Rustup to rustc 1.53.0-nightly (d32238532 2021-04-05)
bjorn3 Apr 6, 2021
7a1cf88
Fix rustc test suite by ignoring rustdoc test
bjorn3 Apr 6, 2021
0c1725f
Fixup previous commit
bjorn3 Apr 6, 2021
e1a2f0f
Rustup to rustc 1.53.0-nightly (c051c5ddd 2021-04-06)
bjorn3 Apr 7, 2021
3d7d08f
Simplify write_metadata
bjorn3 Apr 7, 2021
1ee0aa9
Move BackendConfig to config.rs
bjorn3 Apr 7, 2021
53bfc67
Centralize all configuration into config.rs
bjorn3 Apr 7, 2021
a7c4c3e
Fix outdated crate names in compiler docs
pierwill Apr 7, 2021
29a4a55
Rustfmt
bjorn3 Apr 12, 2021
b6f7e71
Update Cranelift
bjorn3 Apr 14, 2021
f3b0f42
Don't deduplicate vtables between functions
bjorn3 Apr 7, 2021
65420b5
Don't deduplicate anonymous allocations
bjorn3 Apr 8, 2021
542e73e
Merge pull request #1158 from bjorn3/isolate_mono_items_pr
bjorn3 Apr 14, 2021
b4bf4b5
Enable and disable some rust-analyzer diagnostics
bjorn3 Apr 8, 2021
b09b8b1
Re-use Context in codegen_shim
bjorn3 Apr 8, 2021
3e2bdb9
Don't store TyCtxt in UnwindContext
bjorn3 Apr 8, 2021
d9e9fed
Remove CodegenCx::finalize and pass Module separately from CodegenCx
bjorn3 Apr 8, 2021
ba8e610
Inline driver::codegen_crate
bjorn3 Apr 8, 2021
86530f8
Use maybe_create_entry_wrapper again in jit mode
bjorn3 Apr 8, 2021
6fac7f0
Don't unregister unwind tables after the JIT is done
bjorn3 Apr 8, 2021
d4d270d
Merge BACKEND_CONFIG and CURRENT_MODULE thread locals
bjorn3 Apr 8, 2021
eed9aaa
Extract create_jit_module function
bjorn3 Apr 8, 2021
ff38b37
Fix docs
bjorn3 Apr 9, 2021
69102db
Add some documentation
bjorn3 Apr 9, 2021
0319b31
Merge pull request #1159 from bjorn3/driver_refactorings
bjorn3 Apr 14, 2021
56bf873
Time object file writing
bjorn3 Apr 10, 2021
b477a54
Avoid file name formatting when debug file writing is disabled
bjorn3 Apr 11, 2021
607ed91
Sync from rust b203b0d240b67916cfa77f640aedaf1c87d50f6d
bjorn3 Apr 14, 2021
ea3398a
Add more SIMD math.h intrinsics
workingjubilee Apr 14, 2021
73c0db0
Rustup to rustc 1.53.0-nightly (132b4e5d1 2021-04-13)
bjorn3 Apr 16, 2021
24cac8f
Fix rustc tests by updating compiler-builtins dep to 0.1.40
bjorn3 Apr 16, 2021
9443080
Disable new test
bjorn3 Apr 16, 2021
6d6c574
Fix rotate_left and rotate_right with 128bit shift amount
bjorn3 Apr 16, 2021
7f0e351
Fix overflow checking when multiplying two i64
bjorn3 Apr 16, 2021
f3b5e14
Upload artifacts for cross compiling to MinGW
bjorn3 Apr 16, 2021
9a3d98d
Call Termination::report on main result in jit mode
bjorn3 Apr 18, 2021
a569cb4
Fix test
bjorn3 Apr 18, 2021
e01de0f
Avoid .to_string() for symbol names where possible
bjorn3 Apr 18, 2021
bf85572
Extend Termination::report return value as necessary
bjorn3 Apr 18, 2021
5285856
Match on Symbol instead of &str in intrinsics handling
bjorn3 Apr 19, 2021
05f9602
Sync from rust 6df26f897cffb2d86880544bb451c6b5f8509b2d
bjorn3 Apr 21, 2021
cdc0aa1
Rustup to rustc 1.53.0-nightly (6df26f897 2021-04-20)
bjorn3 Apr 21, 2021
e16ccba
Support -Ctarget-cpu
mominul Apr 23, 2021
8eb96b8
Handle native target-cpu variant
mominul Apr 23, 2021
c4f50fb
Update the error messsage
mominul Apr 23, 2021
31b2963
Merge pull request #1163 from mominul/target_cpu
bjorn3 Apr 23, 2021
beb4e31
Rustup to rustc 1.53.0-nightly (727d10156 2021-04-27)
bjorn3 Apr 28, 2021
88901ca
Ignore new failing rustc test
bjorn3 Apr 29, 2021
ddd4ce2
Remove unused parameter
bjorn3 Apr 30, 2021
505aa48
Sync rustc_codegen_cranelift 'ddd4ce25535cf71203ba3700896131ce55fde795'
XAMPPRocky Apr 30, 2021
9d07b92
[cg_clif] Fix run_jit from sync
XAMPPRocky Apr 30, 2021
15c8d31
No-op register_jit on Windows (#1170)
XAMPPRocky Apr 30, 2021
ef53ebc
Merge commit '15c8d31392b9fbab3b3368b67acc4bbe5983115a' into cranelif…
XAMPPRocky Apr 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ jobs:
with:
name: cg_clif-${{ runner.os }}
path: cg_clif.tar.xz

- name: Upload prebuilt cg_clif (cross compile)
if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
uses: actions/upload-artifact@v2
with:
name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
path: cg_clif.tar.xz
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// source for rustc_* is not included in the rust-src component; disable the errors about this
"rust-analyzer.diagnostics.disabled": ["unresolved-extern-crate", "macro-error"],
"rust-analyzer.diagnostics.disabled": ["unresolved-extern-crate", "unresolved-macro-call"],
"rust-analyzer.assist.importMergeBehavior": "last",
"rust-analyzer.cargo.runBuildScripts": true,
"rust-analyzer.linkedProjects": [
Expand Down
45 changes: 23 additions & 22 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "cranelift-bforest"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"
dependencies = [
"cranelift-entity",
]

[[package]]
name = "cranelift-codegen"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"
dependencies = [
"byteorder",
"cranelift-bforest",
Expand All @@ -65,27 +65,27 @@ dependencies = [

[[package]]
name = "cranelift-codegen-meta"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"
dependencies = [
"cranelift-codegen-shared",
"cranelift-entity",
]

[[package]]
name = "cranelift-codegen-shared"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"

[[package]]
name = "cranelift-entity"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"

[[package]]
name = "cranelift-frontend"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"
dependencies = [
"cranelift-codegen",
"log",
Expand All @@ -95,8 +95,8 @@ dependencies = [

[[package]]
name = "cranelift-jit"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -113,8 +113,8 @@ dependencies = [

[[package]]
name = "cranelift-module"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -125,17 +125,17 @@ dependencies = [

[[package]]
name = "cranelift-native"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"
dependencies = [
"cranelift-codegen",
"target-lexicon",
]

[[package]]
name = "cranelift-object"
version = "0.72.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8e43e96410a14143d368273cf1e708f8094bb8e0"
version = "0.73.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand Down Expand Up @@ -306,6 +306,7 @@ dependencies = [
"cranelift-frontend",
"cranelift-jit",
"cranelift-module",
"cranelift-native",
"cranelift-object",
"gimli",
"indexmap",
Expand Down Expand Up @@ -334,9 +335,9 @@ dependencies = [

[[package]]
name = "target-lexicon"
version = "0.11.2"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95"
checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834"

[[package]]
name = "thiserror"
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ crate-type = ["dylib"]

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind", "x64"] }
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] }
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
target-lexicon = "0.11.0"
target-lexicon = "0.12.0"
gimli = { version = "0.23.0", default-features = false, features = ["write"]}
object = { version = "0.23.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

Expand All @@ -28,6 +29,7 @@ smallvec = "1.6.1"
#cranelift-codegen = { path = "../wasmtime/cranelift/codegen" }
#cranelift-frontend = { path = "../wasmtime/cranelift/frontend" }
#cranelift-module = { path = "../wasmtime/cranelift/module" }
#cranelift-native = { path = ../wasmtime/cranelift/native" }
#cranelift-jit = { path = "../wasmtime/cranelift/jit" }
#cranelift-object = { path = "../wasmtime/cranelift/object" }

Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_cranelift/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ This will build your project with rustc_codegen_cranelift instead of the usual L

For additional ways to use rustc_codegen_cranelift like the JIT mode see [usage.md](docs/usage.md).

## Env vars
## Configuration

See [env_vars.md](docs/env_vars.md) for all env vars used by rustc_codegen_cranelift.
See the documentation on the `BackendConfig` struct in [config.rs](src/config.rs) for all
configuration options.

## Not yet supported

Expand Down
19 changes: 16 additions & 3 deletions compiler/rustc_codegen_cranelift/build_sysroot/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.39"
version = "0.1.40"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -132,9 +132,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.91"
version = "0.2.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7"
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -167,6 +167,7 @@ dependencies = [
name = "panic_abort"
version = "0.0.0"
dependencies = [
"alloc",
"cfg-if",
"compiler_builtins",
"core",
Expand Down Expand Up @@ -242,10 +243,22 @@ dependencies = [
"panic_abort",
"panic_unwind",
"rustc-demangle",
"std_detect",
"unwind",
"wasi",
]

[[package]]
name = "std_detect"
version = "0.1.5"
dependencies = [
"cfg-if",
"compiler_builtins",
"libc",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
]

[[package]]
name = "sysroot"
version = "0.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ popd
git clone https://github.com/rust-lang/compiler-builtins.git || echo "rust-lang/compiler-builtins has already been cloned"
pushd compiler-builtins
git checkout -- .
git checkout 0.1.39
git checkout 0.1.40
git apply ../../crate_patches/000*-compiler-builtins-*.patch
popd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ index 06054c8..3bea17b 100644
fn wrapping_shr(self, other: u32) -> Self;
- fn rotate_left(self, other: u32) -> Self;
fn overflowing_add(self, other: Self) -> (Self, bool);
fn aborting_div(self, other: Self) -> Self;
fn aborting_rem(self, other: Self) -> Self;
fn leading_zeros(self) -> u32;
}
@@ -209,10 +208,6 @@ macro_rules! int_impl_common {
<Self>::wrapping_shr(self, other)
}
Expand Down
15 changes: 0 additions & 15 deletions compiler/rustc_codegen_cranelift/docs/env_vars.md

This file was deleted.

43 changes: 24 additions & 19 deletions compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ unsafe extern "C" fn my_puts(s: *const i8) {
puts(s);
}

macro_rules! assert {
($e:expr) => {
if !$e {
panic(stringify!(! $e));
}
};
}

macro_rules! assert_eq {
($l:expr, $r: expr) => {
if $l != $r {
panic(stringify!($l != $r));
}
}
}

#[lang = "termination"]
trait Termination {
fn report(self) -> i32;
Expand All @@ -20,8 +36,9 @@ impl Termination for () {
fn report(self) -> i32 {
unsafe {
NUM = 6 * 7 + 1 + (1u8 == 1u8) as u8; // 44
*NUM_REF as i32
assert_eq!(*NUM_REF as i32, 44);
}
0
}
}

Expand Down Expand Up @@ -82,29 +99,12 @@ fn start<T: Termination + 'static>(
unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const i8)); }
}

main().report();
0
main().report() as isize
}

static mut NUM: u8 = 6 * 7;
static NUM_REF: &'static u8 = unsafe { &NUM };

macro_rules! assert {
($e:expr) => {
if !$e {
panic(stringify!(! $e));
}
};
}

macro_rules! assert_eq {
($l:expr, $r: expr) => {
if $l != $r {
panic(stringify!($l != $r));
}
}
}

struct Unique<T: ?Sized> {
pointer: *const T,
_marker: PhantomData<T>,
Expand Down Expand Up @@ -296,6 +296,11 @@ fn main() {
unsafe {
global_asm_test();
}

// Both statics have a reference that points to the same anonymous allocation.
static REF1: &u8 = &42;
static REF2: &u8 = REF1;
assert_eq!(*REF1, *REF2);
}

#[cfg(all(not(jit), target_os = "linux"))]
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_cranelift/example/std_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ fn main() {
assert_eq!(2.3f32.copysign(-1.0), -2.3f32);
println!("{}", 2.3f32.powf(2.0));

assert_eq!(i64::MAX.checked_mul(2), None);

assert_eq!(-128i8, (-128i8).saturating_sub(1));
assert_eq!(127i8, 127i8.saturating_sub(-128));
assert_eq!(-128i8, (-128i8).saturating_add(-128));
Expand Down Expand Up @@ -84,6 +86,7 @@ fn main() {
assert_eq!(houndred_i128 as f64, 100.0);
assert_eq!(houndred_f32 as i128, 100);
assert_eq!(houndred_f64 as i128, 100);
assert_eq!(1u128.rotate_left(2), 4);

// Test signed 128bit comparing
let max = usize::MAX as i128;
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-2021-03-29"
channel = "nightly-2021-04-28"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/scripts/ext_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
set -e

export CG_CLIF_DISPLAY_CG_TIME=1
export CG_CLIF_INCR_CACHE_DISABLED=1
export CG_CLIF_DISABLE_INCR_CACHE=1

export HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
export TARGET_TRIPLE=${TARGET_TRIPLE:-$HOST_TRIPLE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ index d95b5b7f17f..00b6f0e3635 100644
[dependencies]
core = { path = "../core" }
-compiler_builtins = { version = "0.1.39", features = ['rustc-dep-of-std'] }
+compiler_builtins = { version = "0.1.39", features = ['rustc-dep-of-std', 'no-asm'] }
+compiler_builtins = { version = "0.1.40", features = ['rustc-dep-of-std', 'no-asm'] }
[dev-dependencies]
rand = "0.7"
Expand Down
Loading