]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/base.rs
Auto merge of #35162 - canndrew:bang_type_coerced, r=nikomatsakis
[rust.git] / src / librustc_trans / base.rs
index 70c3fdc269d682cc4143907ae0a4fad6e17ecac1..c78cda75e820e548d5a585c1b5e2d1736745f3d0 100644 (file)
@@ -2250,10 +2250,17 @@ fn write_metadata(cx: &SharedCrateContext,
     };
     unsafe {
         llvm::LLVMSetInitializer(llglobal, llconst);
-        let name =
+        let section_name =
             cx.tcx().sess.cstore.metadata_section_name(&cx.sess().target.target);
-        let name = CString::new(name).unwrap();
-        llvm::LLVMSetSection(llglobal, name.as_ptr())
+        let name = CString::new(section_name).unwrap();
+        llvm::LLVMSetSection(llglobal, name.as_ptr());
+
+        // Also generate a .section directive to force no
+        // flags, at least for ELF outputs, so that the
+        // metadata doesn't get loaded into memory.
+        let directive = format!(".section {}", section_name);
+        let directive = CString::new(directive).unwrap();
+        llvm::LLVMSetModuleInlineAsm(cx.metadata_llmod(), directive.as_ptr())
     }
     return metadata;
 }
@@ -2569,7 +2576,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     assert_module_sources::assert_module_sources(tcx, &modules);
 
     // Skip crate items and just output metadata in -Z no-trans mode.
-    if tcx.sess.opts.no_trans {
+    if tcx.sess.opts.debugging_opts.no_trans {
         let linker_info = LinkerInfo::new(&shared_ccx, &[]);
         return CrateTranslation {
             modules: modules,