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

Commit ffa34ae

Browse files
committed
Remove unnecessary changes
1 parent 0a833ba commit ffa34ae

File tree

6 files changed

+71
-15
lines changed

6 files changed

+71
-15
lines changed

build_sysroot/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ version = "0.0.0"
55

66
[dependencies]
77
core = { path = "./sysroot_src/src/libcore" }
8-
compiler_builtins = { version = "0.1", features = ["rustc-dep-of-std"] }
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" }
913

1014
[patch.crates-io]
1115
rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" }
1216
rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" }
13-
compiler_builtins = { path = "./compiler-builtins" }
1417

1518
[profile.release]
1619
debug = true

build_sysroot/build_sysroot.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ 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
79
rm -r sysroot 2>/dev/null || true
810

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

build_sysroot/compiler-builtins

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/alloc_example.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
#![feature(start, box_syntax, core_intrinsics, alloc_error_handler)]
1+
#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc_prelude, 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+
414
#[link(name = "c")]
515
extern "C" {
616
fn puts(s: *const u8);
@@ -13,12 +23,19 @@ fn panic_handler(_: &core::panic::PanicInfo) -> ! {
1323
}
1424
}
1525

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

22-
assert_eq!(unsafe { __rust_u128_mulo(353985398u128, 932490u128).0 }, 330087843781020u128);
2340
0
2441
}

example/mini_core.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,6 @@ impl Neg for i16 {
318318
}
319319
}
320320

321-
impl Neg for i128 {
322-
type Output = i128;
323-
324-
fn neg(self) -> i128 {
325-
-self
326-
}
327-
}
328-
329321
impl Neg for isize {
330322
type Output = isize;
331323

test.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,52 @@ 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+
724
echo "[BUILD] sysroot"
825
time ./build_sysroot/build_sysroot.sh
926

1027
echo "[BUILD+RUN] alloc_example"
1128
$RUSTC example/alloc_example.rs --crate-type bin
1229
./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)