Skip to content

Commit 747f0be

Browse files
committed
rustc: Don't use jemalloc when crossing to MSVC
This commit updates the compiler to not attempt to use jemalloc for platforms where jemalloc is never enabled. Currently the compiler attempts to link in jemalloc based on whether `--disable-jemalloc` was specified at build time for the compiler itself, but this is only the right decision for the host target, not for other targets. This still leaves a hole open where a set of target libraries are downloaded which were built with `--disable-jemalloc` and the compiler is unaware of that, but this is a pretty rare case so it can always be fixed later.
1 parent 8fe79bd commit 747f0be

9 files changed

+9
-9
lines changed

src/librustc_back/target/apple_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn opts() -> TargetOptions {
2424
dll_suffix: ".dylib".to_string(),
2525
archive_format: "bsd".to_string(),
2626
pre_link_args: Vec::new(),
27-
exe_allocation_crate: super::best_allocator(),
27+
exe_allocation_crate: super::maybe_jemalloc(),
2828
.. Default::default()
2929
}
3030
}

src/librustc_back/target/bitrig_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
2020
has_rpath: true,
2121
position_independent_executables: true,
2222
archive_format: "gnu".to_string(),
23-
exe_allocation_crate: super::best_allocator(),
23+
exe_allocation_crate: "alloc_system".to_string(),
2424

2525
.. Default::default()
2626
}

src/librustc_back/target/dragonfly_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn opts() -> TargetOptions {
2727
),
2828
position_independent_executables: true,
2929
archive_format: "gnu".to_string(),
30-
exe_allocation_crate: super::best_allocator(),
30+
exe_allocation_crate: super::maybe_jemalloc(),
3131
.. Default::default()
3232
}
3333
}

src/librustc_back/target/freebsd_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn opts() -> TargetOptions {
1818
executables: true,
1919
has_rpath: true,
2020
archive_format: "gnu".to_string(),
21-
exe_allocation_crate: super::best_allocator(),
21+
exe_allocation_crate: super::maybe_jemalloc(),
2222

2323
.. Default::default()
2424
}

src/librustc_back/target/linux_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn opts() -> TargetOptions {
2929
],
3030
position_independent_executables: true,
3131
archive_format: "gnu".to_string(),
32-
exe_allocation_crate: super::best_allocator(),
32+
exe_allocation_crate: super::maybe_jemalloc(),
3333
.. Default::default()
3434
}
3535
}

src/librustc_back/target/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl Target {
449449
}
450450
}
451451

452-
fn best_allocator() -> String {
452+
fn maybe_jemalloc() -> String {
453453
if cfg!(disable_jemalloc) {
454454
"alloc_system".to_string()
455455
} else {

src/librustc_back/target/openbsd_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn opts() -> TargetOptions {
2727
),
2828
position_independent_executables: true,
2929
archive_format: "gnu".to_string(),
30-
exe_allocation_crate: super::best_allocator(),
30+
exe_allocation_crate: "alloc_system".to_string(),
3131
.. Default::default()
3232
}
3333
}

src/librustc_back/target/windows_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn opts() -> TargetOptions {
6464
// Always enable DEP (NX bit) when it is available
6565
"-Wl,--nxcompat".to_string(),
6666
),
67-
exe_allocation_crate: super::best_allocator(),
67+
exe_allocation_crate: super::maybe_jemalloc(),
6868

6969
.. Default::default()
7070
}

src/librustc_back/target/windows_msvc_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn opts() -> TargetOptions {
6060
"/NXCOMPAT".to_string(),
6161
],
6262
archive_format: "gnu".to_string(),
63-
exe_allocation_crate: super::best_allocator(),
63+
exe_allocation_crate: "alloc_system".to_string(),
6464

6565
.. Default::default()
6666
}

0 commit comments

Comments
 (0)