diff --git a/config.sh b/config.sh index 43280c09141..4b7fe76d690 100644 --- a/config.sh +++ b/config.sh @@ -12,7 +12,7 @@ fi TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") -export RUSTFLAGS='-Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +export RUSTFLAGS='-Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUSTC_LOG=warn # display metadata load errors diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index ee550af8301..05b5675d43b 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -1,68 +1,35 @@ -From e77c222bb7ec0a99a69dcbb039c75fd1ea9db368 Mon Sep 17 00:00:00 2001 +From e06143d3373293d0490df482261cd4a842f1a5c5 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Thu, 3 Oct 2019 16:22:21 +0200 +Date: Thu, 3 Oct 2019 16:51:34 +0200 Subject: [PATCH] Fix libtest compilation --- - src/libtest/lib.rs | 30 +++++------------------------- - 1 file changed, 5 insertions(+), 25 deletions(-) + src/libtest/lib.rs | 28 ++++++++-------------------- + 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs -index e441514..8e8b4df 100644 +index 8b76080..9e65de2 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs -@@ -24,7 +24,6 @@ - #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))] - #![feature(nll)] - #![feature(set_stdio)] --#![feature(panic_unwind)] - #![feature(staged_api)] - #![feature(termination_trait_lib)] - #![feature(test)] -@@ -34,16 +33,6 @@ use getopts; - extern crate libc; - use term; - --// FIXME(#54291): rustc and/or LLVM don't yet support building with panic-unwind --// on aarch64-pc-windows-msvc, or thumbv7a-pc-windows-msvc --// so we don't link libtest against libunwind (for the time being) --// even though it means that libtest won't be fully functional on --// these platforms. --// --// See also: https://github.com/rust-lang/rust/issues/54190#issuecomment-422904437 --#[cfg(not(all(windows, any(target_arch = "aarch64", target_arch = "arm"))))] --extern crate panic_unwind; -- - pub use self::ColorConfig::*; - use self::NamePadding::*; - use self::OutputLocation::*; -@@ -61,7 +50,6 @@ use std::fmt; +@@ -52,7 +52,7 @@ use std::fmt; use std::fs::File; use std::io; use std::io::prelude::*; --use std::panic::{catch_unwind, AssertUnwindSafe}; +-use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo}; ++use std::panic::{self, PanicInfo}; use std::path::PathBuf; use std::process; - use std::process::Termination; -@@ -1434,7 +1422,7 @@ pub fn run_test( - monitor_ch: Sender, - nocapture: bool, + use std::process::{ExitStatus, Command, Termination}; +@@ -1493,7 +1493,7 @@ pub fn run_test( report_time: bool, + strategy: RunStrategy, + monitor_ch: Sender, - testfn: Box, + testfn: Box, concurrency: Concurrent, ) { - // Buffer for capturing standard I/O -@@ -1457,7 +1445,7 @@ pub fn run_test( - } else { - None - }; -- let result = catch_unwind(AssertUnwindSafe(testfn)); -+ let result = Ok(testfn()); - let exec_time = start.map(|start| { - let duration = start.elapsed(); - TestExecTime(duration) -@@ -1478,7 +1466,7 @@ pub fn run_test( + let name = desc.name.clone(); +@@ -1509,7 +1509,7 @@ pub fn run_test( // If the platform is single-threaded we're just going to run // the test synchronously, regardless of the concurrency // level. @@ -71,25 +38,56 @@ index e441514..8e8b4df 100644 if concurrency == Concurrent::Yes && supports_threads { let cfg = thread::Builder::new().name(name.as_slice().to_owned()); cfg.spawn(runtest).unwrap(); -@@ -1498,16 +1486,8 @@ pub fn run_test( +@@ -1531,20 +1531,8 @@ pub fn run_test( (benchfn.clone())(harness) }); } - DynTestFn(f) => { -- let cb = move || __rust_begin_short_backtrace(f); +- match strategy { +- RunStrategy::InProcess => (), +- _ => panic!("Cannot run dynamic test fn out-of-process"), +- }; - run_test_inner( - desc, -- monitor_ch, - opts.nocapture, - opts.report_time, -- Box::new(cb), -- concurrency, -- ) +- strategy, +- monitor_ch, +- Box::new(move || __rust_begin_short_backtrace(f)), +- concurrency +- ); + DynTestFn(_f) => { + unimplemented!(); } StaticTestFn(f) => run_test_inner( desc, +@@ -1604,7 +1592,7 @@ fn get_result_from_exit_code(desc: &TestDesc, code: i32) -> TestResult { + fn run_test_in_process(desc: TestDesc, + nocapture: bool, + report_time: bool, +- testfn: Box, ++ testfn: Box, + monitor_ch: Sender) { + // Buffer for capturing standard I/O + let data = Arc::new(Mutex::new(Vec::new())); +@@ -1623,7 +1611,7 @@ fn run_test_in_process(desc: TestDesc, + } else { + None + }; +- let result = catch_unwind(AssertUnwindSafe(testfn)); ++ let result = Ok::<(), Box>(testfn()); + let exec_time = start.map(|start| { + let duration = start.elapsed(); + TestExecTime(duration) +@@ -1688,7 +1676,7 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender) -> ! { ++fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box) -> ! { + let builtin_panic_hook = panic::take_hook(); + let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| { + let test_result = match panic_info { -- 2.20.1 diff --git a/src/driver.rs b/src/driver.rs index c8b17208500..f02ba35904f 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -219,7 +219,7 @@ fn run_aot( rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); let metadata_module = if need_metadata_module { - tcx.sess.profiler(|p| p.start_activity("codegen crate metadata")); + let _timer = tcx.prof.generic_activity("codegen crate metadata"); let (metadata_cgu_name, tmp_file) = rustc::util::common::time(tcx.sess, "write compressed metadata", || { use rustc::mir::mono::CodegenUnitNameBuilder; @@ -244,7 +244,6 @@ fn run_aot( (metadata_cgu_name, tmp_file) }); - tcx.sess.profiler(|p| p.end_activity("codegen crate metadata")); Some(CompiledModule { name: metadata_cgu_name, diff --git a/src/lib.rs b/src/lib.rs index 81b03ba5f35..17b667daf0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,7 @@ extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_fs_util; extern crate rustc_incremental; +extern crate rustc_index; extern crate rustc_mir; extern crate rustc_target; extern crate syntax; @@ -74,11 +75,14 @@ mod prelude { self, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; + pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, - indexed_vec::Idx, sync::Lrc, }; + + pub use rustc_index::vec::Idx; + pub use rustc_mir::monomorphize::collector; pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; @@ -225,7 +229,8 @@ impl CodegenBackend for CraneliftCodegenBackend { .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); - sess.profiler(|p| p.start_activity("link_crate")); + let _timer = sess.prof.generic_activity("link_crate"); + rustc::util::common::time(sess, "linking", || { let target_cpu = crate::target_triple(sess).to_string(); link_binary::>( @@ -236,7 +241,6 @@ impl CodegenBackend for CraneliftCodegenBackend { &target_cpu, ); }); - sess.profiler(|p| p.end_activity("link_crate")); Ok(()) }