]> git.lizzy.rs Git - rust.git/commitdiff
Fix cross-crate global allocators on windows
authorAidan Hobson Sayers <aidanhs@cantab.net>
Thu, 10 Aug 2017 13:40:42 +0000 (14:40 +0100)
committerAidan Hobson Sayers <aidanhs@cantab.net>
Thu, 10 Aug 2017 15:22:09 +0000 (16:22 +0100)
src/librustc_trans/back/symbol_export.rs
src/libstd/lib.rs
src/tools/tidy/src/pal.rs

index 72071f8cec99006793a4a5df09d9c7f246fa95d7..971483e91b6f341d13743ffd901e87385775d549 100644 (file)
@@ -13,6 +13,7 @@
 use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE, INVALID_CRATE, CRATE_DEF_INDEX};
 use rustc::session::config;
 use rustc::ty::TyCtxt;
+use rustc_allocator::ALLOCATOR_METHODS;
 use syntax::attr;
 
 /// The SymbolExportLevel of a symbols specifies from which kinds of crates
@@ -83,6 +84,14 @@ pub fn compute<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                               SymbolExportLevel::C));
         }
 
+        if tcx.sess.allocator_kind.get().is_some() {
+            for method in ALLOCATOR_METHODS {
+                local_crate.push((format!("__rust_{}", method.name),
+                                  INVALID_DEF_ID,
+                                  SymbolExportLevel::Rust));
+            }
+        }
+
         if let Some(id) = tcx.sess.derive_registrar_fn.get() {
             let def_id = tcx.hir.local_def_id(id);
             let idx = def_id.index;
index 8850a8a5582dee77511a2279660c3a8aeef3ad77..f7748aa3f041f43a51a0f20002e331b00626b71e 100644 (file)
 #![default_lib_allocator]
 
 // Always use alloc_system during stage0 since we don't know if the alloc_*
-// crate the stage0 compiler will pick by default is available (most
-// obviously, if the user has disabled jemalloc in `./configure`).
+// crate the stage0 compiler will pick by default is enabled (e.g.
+// if the user has disabled jemalloc in `./configure`).
 // `force_alloc_system` is *only* intended as a workaround for local rebuilds
 // with a rustc without jemalloc.
-#![cfg_attr(any(stage0, feature = "force_alloc_system"), feature(global_allocator))]
-#[cfg(any(stage0, feature = "force_alloc_system"))]
+// The not(stage0+msvc) gates will only last until the next stage0 bump
+#![cfg_attr(all(
+        not(all(stage0, target_env = "msvc")),
+        any(stage0, feature = "force_alloc_system")),
+    feature(global_allocator))]
+#[cfg(all(
+    not(all(stage0, target_env = "msvc")),
+    any(stage0, feature = "force_alloc_system")))]
 #[global_allocator]
 static ALLOC: alloc_system::System = alloc_system::System;
 
index 1065749a6961ce5c19fcfcde01fbabccfc5517b7..10c99713820460eb869c88688b6ee7196849e3e4 100644 (file)
@@ -69,6 +69,7 @@
     "src/libstd/path.rs",
     "src/libstd/f32.rs",
     "src/libstd/f64.rs",
+    "src/libstd/lib.rs", // Until next stage0 snapshot bump
     "src/libstd/sys_common/mod.rs",
     "src/libstd/sys_common/net.rs",
     "src/libterm", // Not sure how to make this crate portable, but test needs it