diff options
| author | bors <bors@rust-lang.org> | 2018-04-07 17:14:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-04-07 17:14:46 +0000 |
| commit | 780707490f2b6c3e71a1418e08ef80a6730bce13 (patch) | |
| tree | 8f481766d61262dc3835796d1d510810211f7a39 /src/librustc/middle | |
| parent | 8228d8e17649bab2881ac77c31e32ba6e341fa64 (diff) | |
| parent | 48ede3f031ee81be017923708e5a6e77160e09c3 (diff) | |
| download | rust-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/middle')
| -rw-r--r-- | src/librustc/middle/weak_lang_items.rs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 95e75b4f064..e19f4483f65 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -64,6 +64,24 @@ pub fn link_name(attrs: &[ast::Attribute]) -> Option<Symbol> { }) } +/// Returns whether the specified `lang_item` doesn't actually need to be +/// present for this compilation. +/// +/// Not all lang items are always required for each compilation, particularly in +/// the case of panic=abort. In these situations some lang items are injected by +/// crates and don't actually need to be defined in libstd. +pub fn whitelisted(tcx: TyCtxt, lang_item: lang_items::LangItem) -> bool { + // If we're not compiling with unwinding, we won't actually need these + // symbols. Other panic runtimes ensure that the relevant symbols are + // available to link things together, but they're never exercised. + if tcx.sess.panic_strategy() != PanicStrategy::Unwind { + return lang_item == lang_items::EhPersonalityLangItem || + lang_item == lang_items::EhUnwindResumeLangItem + } + + false +} + fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, items: &lang_items::LanguageItems) { // We only need to check for the presence of weak lang items if we're @@ -89,18 +107,9 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } - // If we're not compiling with unwinding, we won't actually need these - // symbols. Other panic runtimes ensure that the relevant symbols are - // available to link things together, but they're never exercised. - let mut whitelisted = HashSet::new(); - if tcx.sess.panic_strategy() != PanicStrategy::Unwind { - whitelisted.insert(lang_items::EhPersonalityLangItem); - whitelisted.insert(lang_items::EhUnwindResumeLangItem); - } - $( if missing.contains(&lang_items::$item) && - !whitelisted.contains(&lang_items::$item) && + !whitelisted(tcx, lang_items::$item) && items.$name().is_none() { tcx.sess.err(&format!("language item required, but not found: `{}`", stringify!($name))); |
