Libtest support

This commit is contained in:
bjorn3 2019-07-31 14:04:00 +02:00
parent e7a507863c
commit dbac219207
6 changed files with 79 additions and 3 deletions

1
.gitignore vendored
View File

@ -7,5 +7,6 @@ perf.data.old
/build_sysroot/sysroot /build_sysroot/sysroot
/build_sysroot/sysroot_src /build_sysroot/sysroot_src
/build_sysroot/Cargo.lock /build_sysroot/Cargo.lock
/build_sysroot/test_target/Cargo.lock
/rust /rust
/regex /regex

View File

@ -7,7 +7,7 @@ version = "0.0.0"
core = { path = "./sysroot_src/src/libcore" } core = { path = "./sysroot_src/src/libcore" }
compiler_builtins = "0.1" compiler_builtins = "0.1"
alloc = { path = "./sysroot_src/src/liballoc" } alloc = { path = "./sysroot_src/src/liballoc" }
std = { path = "./sysroot_src/src/libstd" } std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind"] }
alloc_system = { path = "./alloc_system" } alloc_system = { path = "./alloc_system" }

View File

@ -12,7 +12,8 @@ popd >/dev/null
# Cleanup for previous run # Cleanup for previous run
# v Clean target dir except for build scripts and incremental cache # v Clean target dir except for build scripts and incremental cache
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true
rm Cargo.lock 2>/dev/null || true rm -r sysroot_src/src/{libcore,libtest}/target/$TARGET_TRIPLE/$sysroot_channel/ || true
rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true
rm -r sysroot 2>/dev/null || true rm -r sysroot 2>/dev/null || true
# Build libs # Build libs
@ -28,3 +29,14 @@ fi
# Copy files to sysroot # Copy files to sysroot
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
if [[ "$1" == "--release" ]]; then
channel='release'
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release --manifest-path ./sysroot_src/src/libtest/Cargo.toml
else
channel='debug'
cargo build --target $TARGET_TRIPLE --manifest-path ./sysroot_src/src/libtest/Cargo.toml
fi
# Copy files to sysroot
cp sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/

View File

@ -0,0 +1,49 @@
From a25405f1fc4a168c9c370524be48aff8c8ebc529 Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Wed, 12 Jun 2019 18:07:23 +0200
Subject: [PATCH] Fix libtest compilation
---
src/libtest/lib.rs | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 810a98e..4fdde0e 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -1441,11 +1441,11 @@ pub fn run_test(
return;
}
- fn run_test_inner(
+ fn run_test_inner<F: FnOnce() + Send + 'static>(
desc: TestDesc,
monitor_ch: Sender<MonitorMsg>,
nocapture: bool,
- testfn: Box<dyn FnOnce() + Send>,
+ testfn: F,
concurrency: Concurrent,
) {
// Buffer for capturing standard I/O
@@ -1500,15 +1500,14 @@ pub fn run_test(
(benchfn.clone())(harness)
});
}
- DynTestFn(f) => {
- let cb = move || __rust_begin_short_backtrace(f);
- run_test_inner(desc, monitor_ch, opts.nocapture, Box::new(cb), concurrency)
+ DynTestFn(_f) => {
+ unimplemented!();
}
StaticTestFn(f) => run_test_inner(
desc,
monitor_ch,
opts.nocapture,
- Box::new(move || __rust_begin_short_backtrace(f)),
+ move || __rust_begin_short_backtrace(f),
concurrency,
),
}
--
2.11.0

View File

@ -1011,6 +1011,20 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
simd_fmax, (c x, c y) { simd_fmax, (c x, c y) {
simd_flt_binop!(fx, intrinsic, fmax(x, y) -> ret); simd_flt_binop!(fx, intrinsic, fmax(x, y) -> ret);
}; };
try, (v f, v data, v _local_ptr) {
// FIXME once unwinding is supported, change this to actually catch panics
let f_sig = fx.bcx.func.import_signature(Signature {
call_conv: cranelift::codegen::isa::CallConv::SystemV,
params: vec![AbiParam::new(fx.bcx.func.dfg.value_type(data))],
returns: vec![],
});
fx.bcx.ins().call_indirect(f_sig, f, &[data]);
let ret_val = CValue::const_val(fx, ret.layout().ty, 0);
ret.write_cvalue(fx, ret_val);
};
} }
if let Some((_, dest)) = destination { if let Some((_, dest)) = destination {

View File

@ -58,7 +58,7 @@ echo "[TEST] rust-lang/regex example shootout-regex-dna"
cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt
diff -u res.txt examples/regexdna-output.txt diff -u res.txt examples/regexdna-output.txt
# FIXME compile libtest # FIXME fix "memory allocation of k bytes failed"
# echo "[TEST] rust-lang/regex standalone tests" # echo "[TEST] rust-lang/regex standalone tests"
# ../cargo.sh test # ../cargo.sh test
popd popd