From e6f0f7d52d69d0c4f290ac32c6eebf92bbf6dd81 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Sat, 7 Nov 2015 12:22:04 -0500 Subject: Only retain external static symbols across LTO --- src/libsyntax/attr.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index cc5f30e2184..e2654375736 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -316,6 +316,13 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option bool { + contains_name(attrs, "no_mangle") || + contains_name(attrs, "link_section") || + contains_name(attrs, "linkage") || + contains_name(attrs, "export_name") +} + #[derive(Copy, Clone, PartialEq)] pub enum InlineAttr { None, -- cgit 1.4.1-3-g733a5 From 32328ac6ff13cf55b61dbfcf0c79aba1b7a8f429 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Tue, 12 Jan 2016 13:07:04 -0500 Subject: Remove link_section and linkage as extern indicators --- src/libsyntax/attr.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index e2654375736..c3e3042eff0 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -318,8 +318,6 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option bool { contains_name(attrs, "no_mangle") || - contains_name(attrs, "link_section") || - contains_name(attrs, "linkage") || contains_name(attrs, "export_name") } -- cgit 1.4.1-3-g733a5 From a141c52816b606f01a3eb432ea1c5e1131513d1c Mon Sep 17 00:00:00 2001 From: arcnmx Date: Tue, 12 Jan 2016 15:55:59 -0500 Subject: Use find_export_name_attr instead of string literal --- src/librustc_trans/trans/base.rs | 2 +- src/libsyntax/attr.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 4748c62921d..5a3c5ced804 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -2727,7 +2727,7 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, None => {} } - match attr::find_export_name_attr(ccx.sess().diagnostic(), attrs) { + match attr::find_export_name_attr(Some(ccx.sess().diagnostic()), attrs) { // Use provided name Some(name) => name.to_string(), _ => { diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index c3e3042eff0..fca659e63b5 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -298,16 +298,16 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option { } /// Find the value of #[export_name=*] attribute and check its validity. -pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option { +pub fn find_export_name_attr(diag: Option<&Handler>, attrs: &[Attribute]) -> Option { attrs.iter().fold(None, |ia,attr| { if attr.check_name("export_name") { if let s@Some(_) = attr.value_str() { s } else { - diag.struct_span_err(attr.span, + diag.map(|d| d.struct_span_err(attr.span, "export_name attribute has invalid format") .help("use #[export_name=\"*\"]") - .emit(); + .emit()); None } } else { @@ -318,7 +318,7 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option bool { contains_name(attrs, "no_mangle") || - contains_name(attrs, "export_name") + find_export_name_attr(None, attrs).is_some() } #[derive(Copy, Clone, PartialEq)] -- cgit 1.4.1-3-g733a5 From 0ff055ad6640e26a4ddf783682545320de0d1c03 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Fri, 15 Jan 2016 14:43:14 -0500 Subject: Pass through diagnostic handler instead --- src/librustc/middle/reachable.rs | 4 +++- src/librustc_metadata/decoder.rs | 3 ++- src/librustc_trans/trans/base.rs | 2 +- src/libsyntax/attr.rs | 10 +++++----- 4 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 5486172b830..d2e1b3edc3a 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -237,7 +237,9 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } else { false }; - if reachable || attr::contains_extern_indicator(&item.attrs) { + let is_extern = attr::contains_extern_indicator(&self.tcx.sess.diagnostic(), + &item.attrs); + if reachable || is_extern { self.reachable_symbols.insert(search_item); } } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 3ec32635a4b..8409a0c74b8 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1586,7 +1586,8 @@ pub fn is_extern_item(cdata: Cmd, id: DefIndex, tcx: &ty::ctxt) -> bool { }; if applicable { - attr::contains_extern_indicator(&get_attributes(item_doc)) + attr::contains_extern_indicator(tcx.sess.diagnostic(), + &get_attributes(item_doc)) } else { false } diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 5a3c5ced804..4748c62921d 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -2727,7 +2727,7 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, None => {} } - match attr::find_export_name_attr(Some(ccx.sess().diagnostic()), attrs) { + match attr::find_export_name_attr(ccx.sess().diagnostic(), attrs) { // Use provided name Some(name) => name.to_string(), _ => { diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index fca659e63b5..9953947eb52 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -298,16 +298,16 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option { } /// Find the value of #[export_name=*] attribute and check its validity. -pub fn find_export_name_attr(diag: Option<&Handler>, attrs: &[Attribute]) -> Option { +pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option { attrs.iter().fold(None, |ia,attr| { if attr.check_name("export_name") { if let s@Some(_) = attr.value_str() { s } else { - diag.map(|d| d.struct_span_err(attr.span, + diag.struct_span_err(attr.span, "export_name attribute has invalid format") .help("use #[export_name=\"*\"]") - .emit()); + .emit(); None } } else { @@ -316,9 +316,9 @@ pub fn find_export_name_attr(diag: Option<&Handler>, attrs: &[Attribute]) -> Opt }) } -pub fn contains_extern_indicator(attrs: &[Attribute]) -> bool { +pub fn contains_extern_indicator(diag: &Handler, attrs: &[Attribute]) -> bool { contains_name(attrs, "no_mangle") || - find_export_name_attr(None, attrs).is_some() + find_export_name_attr(diag, attrs).is_some() } #[derive(Copy, Clone, PartialEq)] -- cgit 1.4.1-3-g733a5