cast the #[used] static to *i8

to match the type signature of the llvm.used variable
This commit is contained in:
Jorge Aparicio 2017-04-05 21:02:52 -05:00
parent c759eea7a6
commit c1635d7e61
2 changed files with 2 additions and 3 deletions

View File

@ -1189,8 +1189,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Create llvm.used variable
if !ccx.used_statics().borrow().is_empty() {
debug!("llvm.used");
let name = CString::new("llvm.used").unwrap();
let section = CString::new("llvm.metadata").unwrap();
let array = C_array(Type::i8(&ccx).ptr_to(), &*ccx.used_statics().borrow());

View File

@ -277,7 +277,8 @@ pub fn trans_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
base::set_link_section(ccx, g, attrs);
if attr::contains_name(attrs, "used") {
ccx.used_statics().borrow_mut().push(g);
let cast = llvm::LLVMConstPointerCast(g, Type::i8p(ccx).to_ref());
ccx.used_statics().borrow_mut().push(cast);
}
Ok(g)