about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2017-04-05 21:11:22 -0500
committerJorge Aparicio <japaricious@gmail.com>2017-04-05 21:11:22 -0500
commitbbe54115873eca9d9a889be3d9eff0c01d2ba8be (patch)
treea6a42f0e564411ac866da14f3e926d5f6802ad70
parentecddad6920b7640ff0398a52a808703db3d4e62a (diff)
downloadrust-bbe54115873eca9d9a889be3d9eff0c01d2ba8be.tar.gz
rust-bbe54115873eca9d9a889be3d9eff0c01d2ba8be.zip
document the implementation a bit more
-rw-r--r--src/librustc_trans/base.rs3
-rw-r--r--src/librustc_trans/consts.rs1
-rw-r--r--src/librustc_trans/context.rs2
-rw-r--r--src/libsyntax/feature_gate.rs4
4 files changed, 7 insertions, 3 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs
index 378e1d7fc63..d204703b775 100644
--- a/src/librustc_trans/base.rs
+++ b/src/librustc_trans/base.rs
@@ -1187,7 +1187,8 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 }
             }
 
-            // 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();
diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs
index ae8c2433fed..daf1a1ba95f 100644
--- a/src/librustc_trans/consts.rs
+++ b/src/librustc_trans/consts.rs
@@ -277,6 +277,7 @@ pub fn trans_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         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);
         }
diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs
index 2eca0a18e2b..afb94f546ab 100644
--- a/src/librustc_trans/context.rs
+++ b/src/librustc_trans/context.rs
@@ -132,6 +132,8 @@ pub struct LocalCrateContext<'tcx> {
     /// 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>>,
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 66a813025c4..5f719001203 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -344,8 +344,8 @@ declare_features! (
     // 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! (