}
}
- // 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();
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);
}
/// 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>>,
// 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! (