Skip to content

Commit 0a833ba

Browse files
committed
[WIP]
1 parent b46c8bf commit 0a833ba

File tree

8 files changed

+9
-101
lines changed

8 files changed

+9
-101
lines changed

build_sysroot/Cargo.toml

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ version = "0.0.0"
55

66
[dependencies]
77
core = { path = "./sysroot_src/src/libcore" }
8-
compiler_builtins = "0.1"
9-
alloc = { path = "./sysroot_src/src/liballoc" }
10-
std = { path = "./sysroot_src/src/libstd" }
11-
12-
alloc_system = { path = "./alloc_system" }
8+
compiler_builtins = { version = "0.1", features = ["rustc-dep-of-std"] }
139

1410
[patch.crates-io]
1511
rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" }
1612
rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" }
17-
#compiler_builtins = { path = "./compiler_builtins" }
13+
compiler_builtins = { path = "./compiler-builtins" }
1814

1915
[profile.release]
2016
debug = true

build_sysroot/build_sysroot.sh

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ cd $(dirname "$0")
44

55
# Cleanup for previous run
66
# v Clean target dir except for build scripts and incremental cache
7-
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true
8-
rm Cargo.lock 2>/dev/null || true
97
rm -r sysroot 2>/dev/null || true
108

119
# FIXME find a better way to get the target triple

build_sysroot/compiler-builtins

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 36da64f20e96206ac279f700586817c8abe3bdf8

build_sysroot/compiler_builtins/Cargo.toml

-20
This file was deleted.

build_sysroot/compiler_builtins/lib.rs

-9
This file was deleted.

example/alloc_example.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc_prelude, alloc_error_handler)]
1+
#![feature(start, box_syntax, core_intrinsics, alloc_error_handler)]
22
#![no_std]
33

4-
extern crate alloc;
5-
extern crate alloc_system;
6-
7-
use alloc::prelude::v1::*;
8-
9-
use alloc_system::System;
10-
11-
#[global_allocator]
12-
static ALLOC: System = System;
13-
144
#[link(name = "c")]
155
extern "C" {
166
fn puts(s: *const u8);
@@ -23,19 +13,12 @@ fn panic_handler(_: &core::panic::PanicInfo) -> ! {
2313
}
2414
}
2515

26-
#[alloc_error_handler]
27-
fn alloc_error_handler(_: alloc::alloc::Layout) -> ! {
28-
unsafe {
29-
core::intrinsics::abort();
30-
}
31-
}
32-
3316
#[start]
3417
fn main(_argc: isize, _argv: *const *const u8) -> isize {
35-
let world: Box<&str> = box "Hello World!\0";
36-
unsafe {
37-
puts(*world as *const str as *const u8);
18+
extern "C" {
19+
fn __rust_u128_mulo(a: u128, b: u128) -> (u128, bool);
3820
}
3921

22+
assert_eq!(unsafe { __rust_u128_mulo(353985398u128, 932490u128).0 }, 330087843781020u128);
4023
0
4124
}

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ fn build_isa(sess: &Session) -> Box<dyn isa::TargetIsa + 'static> {
243243
"false"
244244
}).unwrap();
245245

246+
flags_builder.set("opt_level", "best").unwrap();
247+
246248
// FIXME enable again when https://github.com/CraneStation/cranelift/issues/664 is fixed
247249
/*
248250
use rustc::session::config::OptLevel;

test.sh

-43
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,9 @@ source config.sh
44
rm -r target/out || true
55
mkdir -p target/out/clif
66

7-
echo "[BUILD] mini_core"
8-
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib
9-
10-
echo "[BUILD] example"
11-
$RUSTC example/example.rs --crate-type lib
12-
13-
echo "[JIT] mini_core_hello_world"
14-
SHOULD_RUN=1 JIT_ARGS="abc bcd" $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit
15-
16-
echo "[AOT] mini_core_hello_world"
17-
$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin
18-
./target/out/mini_core_hello_world abc bcd
19-
20-
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
21-
$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin
22-
./target/out/arbitrary_self_types_pointers_and_wrappers
23-
247
echo "[BUILD] sysroot"
258
time ./build_sysroot/build_sysroot.sh
269

2710
echo "[BUILD+RUN] alloc_example"
2811
$RUSTC example/alloc_example.rs --crate-type bin
2912
./target/out/alloc_example
30-
31-
echo "[BUILD+RUN] std_example"
32-
$RUSTC example/std_example.rs --crate-type bin
33-
./target/out/std_example
34-
35-
echo "[BUILD] mod_bench"
36-
$RUSTC example/mod_bench.rs --crate-type bin
37-
38-
# FIXME linker gives multiple definitions error on Linux
39-
#echo "[BUILD] sysroot in release mode"
40-
#./build_sysroot/build_sysroot.sh --release
41-
42-
COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"
43-
COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort"
44-
COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort"
45-
COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort"
46-
COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort"
47-
48-
# Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow
49-
hyperfine --runs 100 "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3"
50-
51-
echo
52-
echo "[Bench] mod_bench"
53-
hyperfine ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_*
54-
55-
cat target/out/log.txt | sort | uniq -c

0 commit comments

Comments
 (0)