]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Don't create empty codegen units
authorAlex Crichton <alex@alexcrichton.com>
Wed, 4 Oct 2017 23:21:38 +0000 (16:21 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 4 Oct 2017 23:21:38 +0000 (16:21 -0700)
This'll end up just creating a bunch of object files that otherwise wouldn't
exist, so skip that extra work if possible.

src/librustc_trans/base.rs
src/librustc_trans/partitioning.rs

index 0568bd2f3cabd5803ec389a9a15a5e593b26b2d5..94e1d238c64ed84387f3f8369403b5b5565d7bb4 100644 (file)
@@ -1178,9 +1178,6 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
             .collect::<Vec<_>>()
     });
 
-    assert!(tcx.sess.opts.codegen_units == codegen_units.len() ||
-            tcx.sess.opts.debugging_opts.incremental.is_some());
-
     let translation_items: DefIdSet = items.iter().filter_map(|trans_item| {
         match *trans_item {
             TransItem::Fn(ref instance) => Some(instance.def_id()),
index 7c29186f4657f721a5424d5c1c9c736569dc76bf..a84bfd15402f91a5d9539f5cbdb3d54ebd90c490 100644 (file)
@@ -407,15 +407,6 @@ fn merge_codegen_units<'tcx>(initial_partitioning: &mut PreInliningPartitioning<
     for (index, cgu) in codegen_units.iter_mut().enumerate() {
         cgu.set_name(numbered_codegen_unit_name(crate_name, index));
     }
-
-    // If the initial partitioning contained less than target_cgu_count to begin
-    // with, we won't have enough codegen units here, so add a empty units until
-    // we reach the target count
-    while codegen_units.len() < target_cgu_count {
-        let index = codegen_units.len();
-        let name = numbered_codegen_unit_name(crate_name, index);
-        codegen_units.push(CodegenUnit::new(name));
-    }
 }
 
 fn place_inlined_translation_items<'tcx>(initial_partitioning: PreInliningPartitioning<'tcx>,