Skip to content

Commit

Permalink
cast the #[used] static to *i8
Browse files Browse the repository at this point in the history
to match the type signature of the llvm.used variable
  • Loading branch information
Jorge Aparicio committed Apr 6, 2017
1 parent c759eea commit c1635d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/librustc_trans/base.rs
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_trans/consts.rs
Expand Up @@ -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)
Expand Down

0 comments on commit c1635d7

Please sign in to comment.