document the implementation a bit more
This commit is contained in:
parent
ecddad6920
commit
bbe5411587
4 changed files with 7 additions and 3 deletions
|
|
@ -1187,7 +1187,8 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
// Create llvm.used variable
|
||||
// Create the llvm.used variable
|
||||
// This variable has type [N x i8*] and is stored in the llvm.metadata section
|
||||
if !ccx.used_statics().borrow().is_empty() {
|
||||
let name = CString::new("llvm.used").unwrap();
|
||||
let section = CString::new("llvm.metadata").unwrap();
|
||||
|
|
|
|||
|
|
@ -277,6 +277,7 @@ pub fn trans_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
base::set_link_section(ccx, g, attrs);
|
||||
|
||||
if attr::contains_name(attrs, "used") {
|
||||
// This static will be stored in the llvm.used variable which is an array of i8*
|
||||
let cast = llvm::LLVMConstPointerCast(g, Type::i8p(ccx).to_ref());
|
||||
ccx.used_statics().borrow_mut().push(cast);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ pub struct LocalCrateContext<'tcx> {
|
|||
/// to constants.)
|
||||
statics_to_rauw: RefCell<Vec<(ValueRef, ValueRef)>>,
|
||||
|
||||
/// Statics that will be placed in the llvm.used variable
|
||||
/// See http://llvm.org/docs/LangRef.html#the-llvm-used-global-variable for details
|
||||
used_statics: RefCell<Vec<ValueRef>>,
|
||||
|
||||
lltypes: RefCell<FxHashMap<Ty<'tcx>, Type>>,
|
||||
|
|
|
|||
|
|
@ -344,8 +344,8 @@ declare_features! (
|
|||
// See rust-lang/rfcs#1414. Allows code like `let x: &'static u32 = &42` to work.
|
||||
(active, rvalue_static_promotion, "1.15.1", Some(38865)),
|
||||
|
||||
// Used to preserve symbols
|
||||
(active, used, "1.18.0", None),
|
||||
// Used to preserve symbols (see llvm.used)
|
||||
(active, used, "1.18.0", Some(40289)),
|
||||
);
|
||||
|
||||
declare_features! (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue