Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 77f74ed

Browse files
committed
Merge commit 'dbee13661efa269cb4cd57bb4c6b99a19732b484' into sync_cg_clif-2020-12-27
1 parent 6c1fc32 commit 77f74ed

28 files changed

+489
-274
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
// source for rustc_* is not included in the rust-src component; disable the errors about this
33
"rust-analyzer.diagnostics.disabled": ["unresolved-extern-crate"],
4+
"rust-analyzer.assist.importMergeBehaviour": "last",
45
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
56
"rust-analyzer.linkedProjects": [
67
"./Cargo.toml",

Cargo.lock

Lines changed: 28 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ crate-type = ["dylib"]
1212
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] }
1313
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
1414
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
15-
cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
15+
cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
1616
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
1717
target-lexicon = "0.11.0"
1818
gimli = { version = "0.23.0", default-features = false, features = ["write"]}
@@ -27,15 +27,15 @@ libloading = { version = "0.6.0", optional = true }
2727
#cranelift-codegen = { path = "../wasmtime/cranelift/codegen" }
2828
#cranelift-frontend = { path = "../wasmtime/cranelift/frontend" }
2929
#cranelift-module = { path = "../wasmtime/cranelift/module" }
30-
#cranelift-simplejit = { path = "../wasmtime/cranelift/simplejit" }
30+
#cranelift-jit = { path = "../wasmtime/cranelift/jit" }
3131
#cranelift-object = { path = "../wasmtime/cranelift/object" }
3232

3333
#[patch.crates-io]
3434
#gimli = { path = "../" }
3535

3636
[features]
3737
default = ["jit", "inline_asm"]
38-
jit = ["cranelift-simplejit", "libloading"]
38+
jit = ["cranelift-jit", "libloading"]
3939
inline_asm = []
4040

4141
[profile.dev]

Readme.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> ⚠⚠⚠ Certain kinds of FFI don't work yet. ⚠⚠⚠
44
5-
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).
5+
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/main/cranelift).
66
This has the potential to improve compilation times in debug mode.
77
If your project doesn't use any of the things listed under "Not yet supported", it should work fine.
88
If not please open an issue.
@@ -68,7 +68,15 @@ $ $cg_clif_dir/build/cargo.sh jit
6868
or
6969

7070
```bash
71-
$ $cg_clif_dir/build/bin/cg_clif --jit my_crate.rs
71+
$ $cg_clif_dir/build/bin/cg_clif -Cllvm-args=mode=jit -Cprefer-dynamic my_crate.rs
72+
```
73+
74+
There is also an experimental lazy jit mode. In this mode functions are only compiled once they are
75+
first called. It currently does not work with multi-threaded programs. When a not yet compiled
76+
function is called from another thread than the main thread, you will get an ICE.
77+
78+
```bash
79+
$ $cg_clif_dir/build/cargo.sh lazy-jit
7280
```
7381

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

7886
```bash
7987
function jit_naked() {
80-
echo "$@" | $cg_clif_dir/build/bin/cg_clif - --jit
88+
echo "$@" | $cg_clif_dir/build/bin/cg_clif - -Cllvm-args=mode=jit -Cprefer-dynamic
8189
}
8290

8391
function jit() {

build_sysroot/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_sysroot/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ version = "0.0.0"
55

66
[dependencies]
77
core = { path = "./sysroot_src/library/core" }
8-
compiler_builtins = "0.1"
98
alloc = { path = "./sysroot_src/library/alloc" }
109
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
1110
test = { path = "./sysroot_src/library/test" }
1211

1312
alloc_system = { path = "./alloc_system" }
1413

14+
compiler_builtins = { version = "=0.1.36", default-features = false }
15+
1516
[patch.crates-io]
1617
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
1718
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }

example/std_example.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ fn main() {
1515
let stderr = ::std::io::stderr();
1616
let mut stderr = stderr.lock();
1717

18+
// FIXME support lazy jit when multi threading
19+
#[cfg(not(lazy_jit))]
1820
std::thread::spawn(move || {
1921
println!("Hello from another thread!");
2022
});

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2020-11-27
1+
nightly-2020-12-23

scripts/cargo.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ cmd=$1
1010
shift || true
1111

1212
if [[ "$cmd" = "jit" ]]; then
13-
cargo "+${TOOLCHAIN}" rustc "$@" -- --jit
13+
cargo "+${TOOLCHAIN}" rustc "$@" -- -Cllvm-args=mode=jit -Cprefer-dynamic
14+
elif [[ "$cmd" = "lazy-jit" ]]; then
15+
cargo "+${TOOLCHAIN}" rustc "$@" -- -Cllvm-args=mode=jit-lazy -Cprefer-dynamic
1416
else
1517
cargo "+${TOOLCHAIN}" "$cmd" "$@"
1618
fi

scripts/filter_profile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pushd $(dirname "$0")/../
55
source build/config.sh
66
popd
7-
PROFILE=$1 OUTPUT=$2 exec $RUSTC $RUSTFLAGS --jit $0
7+
PROFILE=$1 OUTPUT=$2 exec $RUSTC $RUSTFLAGS -Cllvm-args=mode=jit -Cprefer-dynamic $0
88
#*/
99

1010
//! This program filters away uninteresting samples and trims uninteresting frames for stackcollapse

0 commit comments

Comments
 (0)