about summary refs log tree commit diff
path: root/src/librustc_trans
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-04-07 17:14:46 +0000
committerbors <bors@rust-lang.org>2018-04-07 17:14:46 +0000
commit780707490f2b6c3e71a1418e08ef80a6730bce13 (patch)
tree8f481766d61262dc3835796d1d510810211f7a39 /src/librustc_trans
parent8228d8e17649bab2881ac77c31e32ba6e341fa64 (diff)
parent48ede3f031ee81be017923708e5a6e77160e09c3 (diff)
downloadrust-780707490f2b6c3e71a1418e08ef80a6730bce13.tar.gz
rust-780707490f2b6c3e71a1418e08ef80a6730bce13.zip
Auto merge of #49672 - alexcrichton:fix-another-std-core-cycle, r=michaelwoerister
Fix another circular deps link args issue

It turns out that the support in #49316 wasn't enough to handle all cases
notably the example in #48661. The underlying bug was connected to panic=abort
where lang items were listed in the `missing_lang_items` sets but didn't
actually exist anywhere.

This caused the linker backend to deduce that start-group/end-group wasn't
needed because not all items were defined. Instead the missing lang items that
don't actually need to have a definition are filtered out and not considered for
the start-group/end-group arguments

Closes #48661
Diffstat (limited to 'src/librustc_trans')
-rw-r--r--src/librustc_trans/base.rs8
-rw-r--r--src/librustc_trans/lib.rs2
2 files changed, 9 insertions, 1 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs
index a513ebbf6c7..0329264a312 100644
--- a/src/librustc_trans/base.rs
+++ b/src/librustc_trans/base.rs
@@ -36,6 +36,7 @@ use llvm;
 use metadata;
 use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
 use rustc::middle::lang_items::StartFnLangItem;
+use rustc::middle::weak_lang_items;
 use rustc::mir::mono::{Linkage, Visibility, Stats};
 use rustc::middle::cstore::{EncodedMetadata};
 use rustc::ty::{self, Ty, TyCtxt};
@@ -1141,6 +1142,13 @@ impl CrateInfo {
                     info.lang_item_to_crate.insert(item, id.krate);
                 }
             }
+
+            // No need to look for lang items that are whitelisted and don't
+            // actually need to exist.
+            let missing = missing.iter()
+                .cloned()
+                .filter(|&l| !weak_lang_items::whitelisted(tcx, l))
+                .collect();
             info.missing_lang_items.insert(cnum, missing);
         }
 
diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs
index 738b72dbcbb..344f959c141 100644
--- a/src/librustc_trans/lib.rs
+++ b/src/librustc_trans/lib.rs
@@ -404,7 +404,7 @@ struct CrateInfo {
     wasm_custom_sections: BTreeMap<String, Vec<u8>>,
     wasm_imports: FxHashMap<String, String>,
     lang_item_to_crate: FxHashMap<LangItem, CrateNum>,
-    missing_lang_items: FxHashMap<CrateNum, Lrc<Vec<LangItem>>>,
+    missing_lang_items: FxHashMap<CrateNum, Vec<LangItem>>,
 }
 
 __build_diagnostic_array! { librustc_trans, DIAGNOSTICS }