]> git.lizzy.rs Git - rust.git/blobdiff - src/liballoc_jemalloc/build.rs
std: Stop prefixing jemalloc symbols
[rust.git] / src / liballoc_jemalloc / build.rs
index 4bc752af48eee5fdfb58a41b5fbb5b37ea987bc5..c9508322a31a7d7292d14b25426b562b31d08519 100644 (file)
@@ -50,7 +50,7 @@ fn main() {
        .env("AR", &ar)
        .env("RANLIB", format!("{} s", ar.display()));
 
-    if target.contains("windows-gnu") {
+    if target.contains("windows") {
         // A bit of history here, this used to be --enable-lazy-lock added in
         // #14006 which was filed with jemalloc in jemalloc/jemalloc#83 which
         // was also reported to MinGW:
@@ -72,7 +72,19 @@ fn main() {
         //        locking, but requires passing an option due to a historical
         //        default with jemalloc.
         cmd.arg("--disable-lazy-lock");
-    } else if target.contains("ios") || target.contains("android") {
+    } else if target.contains("ios") {
+        cmd.arg("--disable-tls");
+    } else if target.contains("android") {
+        // We force android to have prefixed symbols because apparently
+        // replacement of the libc allocator doesn't quite work. When this was
+        // tested (unprefixed symbols), it was found that the `realpath`
+        // function in libc would allocate with libc malloc (not jemalloc
+        // malloc), and then the standard library would free with jemalloc free,
+        // causing a segfault.
+        //
+        // If the test suite passes, however, without symbol prefixes then we
+        // should be good to go!
+        cmd.arg("--with-jemalloc-prefix=je_");
         cmd.arg("--disable-tls");
     }
 
@@ -82,7 +94,6 @@ fn main() {
 
     // Turn off broken quarantine (see jemalloc/jemalloc#161)
     cmd.arg("--disable-fill");
-    cmd.arg("--with-jemalloc-prefix=je_");
     cmd.arg(format!("--host={}", build_helper::gnu_target(&target)));
     cmd.arg(format!("--build={}", build_helper::gnu_target(&host)));