Skip to content

Commit

Permalink
Add flag for rustc_std_internal_symbol attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Mar 7, 2018
1 parent 6bc7f41 commit 39f9d23
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@ bitflags! {
const RUSTC_ALLOCATOR_NOUNWIND = 0b0000_1000;
const NAKED = 0b0001_0000;
const NO_MANGLE = 0b0010_0000;
const RUSTC_STD_INTERNAL_SYMBOL = 0b0100_0000;
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
//! this is not implemented however: a mono item will be produced
//! regardless of whether it is actually needed or not.
use rustc::hir;
use rustc::hir::{self, TransFnAttrFlags};
use rustc::hir::itemlikevisit::ItemLikeVisitor;

use rustc::hir::map as hir_map;
Expand All @@ -211,8 +211,6 @@ use monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode};

use rustc_data_structures::bitvec::BitVector;

use syntax::attr;

use std::iter;

#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
Expand Down Expand Up @@ -985,8 +983,8 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
MonoItemCollectionMode::Lazy => {
self.entry_fn == Some(def_id) ||
self.tcx.is_reachable_non_generic(def_id) ||
attr::contains_name(&self.tcx.get_attrs(def_id),
"rustc_std_internal_symbol")
self.tcx.trans_fn_attrs(def_id).flags.contains(
TransFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::sync::Arc;

use monomorphize::Instance;
use rustc::hir;
use rustc::hir::TransFnAttrFlags;
use rustc::hir::def_id::CrateNum;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol, metadata_symbol_name};
Expand All @@ -21,7 +22,6 @@ use rustc::ty::{TyCtxt, SymbolName};
use rustc::ty::maps::Providers;
use rustc::util::nodemap::{FxHashMap, DefIdSet};
use rustc_allocator::ALLOCATOR_METHODS;
use syntax::attr;

pub type ExportedSymbols = FxHashMap<
CrateNum,
Expand Down Expand Up @@ -258,8 +258,8 @@ fn symbol_export_level_provider(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportL
// are not considered for export
let trans_fn_attrs = tcx.trans_fn_attrs(sym_def_id);
let is_extern = trans_fn_attrs.contains_extern_indicator();
let std_internal = attr::contains_name(&tcx.get_attrs(sym_def_id),
"rustc_std_internal_symbol");
let std_internal = trans_fn_attrs.flags.contains(TransFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);

if is_extern && !std_internal {
SymbolExportLevel::C
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,8 @@ fn trans_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> TransFnAt
trans_fn_attrs.flags |= TransFnAttrFlags::NAKED;
} else if attr.check_name("no_mangle") {
trans_fn_attrs.flags |= TransFnAttrFlags::NO_MANGLE;
} else if attr.check_name("rustc_std_internal_symbol") {
trans_fn_attrs.flags |= TransFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
} else if attr.check_name("inline") {
trans_fn_attrs.inline = attrs.iter().fold(InlineAttr::None, |ia, attr| {
if attr.path != "inline" {
Expand Down

0 comments on commit 39f9d23

Please sign in to comment.