Skip to content

Commit 9f3de64

Browse files
committed
Prefix jemalloc on DragonFly to prevent segfaults.
Similar to commits ed01545 (iOS) and e3b414d (Android)
1 parent 235d774 commit 9f3de64

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

mk/rt.mk

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ else ifeq ($(findstring android, $(OSTYPE_$(1))), android)
157157
# If the test suite passes, however, without symbol prefixes then we should be
158158
# good to go!
159159
JEMALLOC_ARGS_$(1) := --disable-tls --with-jemalloc-prefix=je_
160+
else ifeq ($(findstring dragonfly, $(OSTYPE_$(1))), dragonfly)
161+
JEMALLOC_ARGS_$(1) := --with-jemalloc-prefix=je_
160162
endif
161163

162164
ifdef CFG_ENABLE_DEBUG_JEMALLOC

src/liballoc_jemalloc/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ fn main() {
8686
// should be good to go!
8787
cmd.arg("--with-jemalloc-prefix=je_");
8888
cmd.arg("--disable-tls");
89+
} else if target.contains("dragonfly") {
90+
cmd.arg("--with-jemalloc-prefix=je_");
8991
}
9092

9193
if cfg!(feature = "debug-jemalloc") {

src/liballoc_jemalloc/lib.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,27 @@ use libc::{c_int, c_void, size_t};
4242
extern {}
4343

4444
// Note that the symbols here are prefixed by default on OSX (we don't
45-
// explicitly request it), and on Android we explicitly request it as
46-
// unprefixing cause segfaults (mismatches in allocators).
45+
// explicitly request it), and on Android and DragonFly we explicitly request
46+
// it as unprefixing cause segfaults (mismatches in allocators).
4747
extern {
48-
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios"),
48+
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
49+
target_os = "dragonfly"),
4950
link_name = "je_mallocx")]
5051
fn mallocx(size: size_t, flags: c_int) -> *mut c_void;
51-
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios"),
52+
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
53+
target_os = "dragonfly"),
5254
link_name = "je_rallocx")]
5355
fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
54-
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios"),
56+
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
57+
target_os = "dragonfly"),
5558
link_name = "je_xallocx")]
5659
fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
57-
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios"),
60+
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
61+
target_os = "dragonfly"),
5862
link_name = "je_sdallocx")]
5963
fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
60-
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios"),
64+
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
65+
target_os = "dragonfly"),
6166
link_name = "je_nallocx")]
6267
fn nallocx(size: size_t, flags: c_int) -> size_t;
6368
}

0 commit comments

Comments
 (0)