]> git.lizzy.rs Git - rust.git/commitdiff
cast the #[used] static to *i8
authorJorge Aparicio <japaricious@gmail.com>
Thu, 6 Apr 2017 02:02:52 +0000 (21:02 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Thu, 6 Apr 2017 02:02:52 +0000 (21:02 -0500)
to match the type signature of the llvm.used variable

src/librustc_trans/base.rs
src/librustc_trans/consts.rs

index 63258b74533179cb0cf63ec9e200ed38df183070..378e1d7fc63f05b829b7a85181e77cfe859532ce 100644 (file)
@@ -1189,8 +1189,6 @@ fn trans_def_task<'a, 'tcx>(ccx: CrateContext<'a, '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());
index 9974155f7c07d4d4eb8880303f1562f5a53481af..ae8c2433fed7560394bfecd99f95481934ac1d67 100644 (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)