Skip to content

Commit c1635d7

Browse files
author
Jorge Aparicio
committed
cast the #[used] static to *i8
to match the type signature of the llvm.used variable
1 parent c759eea commit c1635d7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/librustc_trans/base.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,8 +1189,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11891189

11901190
// Create llvm.used variable
11911191
if !ccx.used_statics().borrow().is_empty() {
1192-
debug!("llvm.used");
1193-
11941192
let name = CString::new("llvm.used").unwrap();
11951193
let section = CString::new("llvm.metadata").unwrap();
11961194
let array = C_array(Type::i8(&ccx).ptr_to(), &*ccx.used_statics().borrow());

src/librustc_trans/consts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ pub fn trans_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
277277
base::set_link_section(ccx, g, attrs);
278278

279279
if attr::contains_name(attrs, "used") {
280-
ccx.used_statics().borrow_mut().push(g);
280+
let cast = llvm::LLVMConstPointerCast(g, Type::i8p(ccx).to_ref());
281+
ccx.used_statics().borrow_mut().push(cast);
281282
}
282283

283284
Ok(g)

0 commit comments

Comments
 (0)