mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Implement basic incremental compilation
This commit is contained in:
parent
5859b9b65d
commit
23b4db227a
2
build.sh
2
build.sh
@ -20,6 +20,6 @@ $RUSTC mini_core.rs --crate-name mini_core --crate-type lib &&
|
||||
$RUSTC example.rs --crate-type lib &&
|
||||
$RUSTC mini_core_hello_world.rs --crate-type bin &&
|
||||
|
||||
$RUSTC ../target/libcore/src/libcore/lib.rs --color=always --crate-type lib 2>&1 | (head -n 20; echo "===="; tail -n 1000)
|
||||
$RUSTC ../target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=../target/libcore/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000)
|
||||
cat ../target/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len"
|
||||
rm *.rlib ../target/log.txt
|
||||
|
25
src/lib.rs
25
src/lib.rs
@ -68,7 +68,7 @@ mod prelude {
|
||||
self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt,
|
||||
TypeAndMut, TypeFoldable, TypeVariants,
|
||||
};
|
||||
pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc};
|
||||
pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc, fx::FxHashMap};
|
||||
pub use rustc_mir::monomorphize::{collector, MonoItem};
|
||||
pub use syntax::ast::{FloatTy, IntTy, UintTy};
|
||||
pub use syntax::codemap::DUMMY_SP;
|
||||
@ -186,6 +186,13 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
providers.target_features_whitelist = |_tcx, _cnum| Lrc::new(Default::default());
|
||||
providers.is_reachable_non_generic = |_tcx, _defid| true;
|
||||
providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new());
|
||||
providers.upstream_monomorphizations = |_tcx, _cnum| Lrc::new(FxHashMap());
|
||||
providers.upstream_monomorphizations_for = |tcx, def_id| {
|
||||
debug_assert!(!def_id.is_local());
|
||||
tcx.upstream_monomorphizations(LOCAL_CRATE)
|
||||
.get(&def_id)
|
||||
.cloned()
|
||||
};
|
||||
}
|
||||
fn provide_extern(&self, providers: &mut Providers) {
|
||||
providers.is_reachable_non_generic = |_tcx, _defid| true;
|
||||
@ -251,9 +258,13 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
let mut log = ::std::fs::File::create("../target/log.txt").unwrap();
|
||||
|
||||
let before = ::std::time::Instant::now();
|
||||
for mono_item in
|
||||
collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0
|
||||
{
|
||||
let mono_items = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0;
|
||||
|
||||
// TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore
|
||||
save_incremental(tcx);
|
||||
tcx.sess.warn("Saved incremental data");
|
||||
|
||||
for mono_item in mono_items {
|
||||
let cx = &mut cx;
|
||||
let context = &mut context;
|
||||
let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(move || {
|
||||
@ -371,6 +382,12 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
}
|
||||
}
|
||||
|
||||
fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
rustc_incremental::assert_dep_graph(tcx);
|
||||
rustc_incremental::save_dep_graph(tcx);
|
||||
rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE));
|
||||
}
|
||||
|
||||
/// This is the entrypoint for a hot plugged rustc_codegen_cranelift
|
||||
#[no_mangle]
|
||||
pub fn __rustc_codegen_backend() -> Box<CodegenBackend> {
|
||||
|
Loading…
Reference in New Issue
Block a user