Skip to content

Commit b87e39f

Browse files
committed
Disable background_threads support on windows
Background Threads are unsupported on windows in jemalloc, due to requiring pthreads (which aren't available on windows, at least on the msvc target). Trying to enable it will cause a runtime error causing the program to immediately abort. As such, to avoid problems, we set windows as a target that does not support background_threads. Signed-off-by: roblabla <[email protected]>
1 parent 3f2e4a1 commit b87e39f

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
include:
1919
- name: x86_64-pc-windows-msvc
2020
target: x86_64-pc-windows-msvc
21-
nobgt: 0
21+
nobgt: 1
2222
no_tests: 1
2323
tag: windows-latest
2424
- name: x86_64-apple-darwin

jemalloc-ctl/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ option! {
141141
/// # static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
142142
/// #
143143
/// # fn main() {
144-
/// # #[cfg(not(target_os = "macos"))] {
144+
/// # #[cfg(not(any(target_os = "macos", windows)))] {
145145
/// #
146146
/// use tikv_jemalloc_ctl::background_thread;
147147
/// let bg = background_thread::mib().unwrap();
@@ -171,7 +171,7 @@ option! {
171171
/// # static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
172172
/// #
173173
/// # fn main() {
174-
/// # #[cfg(not(target_os = "macos"))] {
174+
/// # #[cfg(not(any(target_os = "macos", windows)))] {
175175
/// #
176176
/// use tikv_jemalloc_ctl::max_background_threads;
177177
/// let m = max_background_threads::mib().unwrap();

jemalloc-ctl/src/macros.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ macro_rules! r {
6969
match stringify!($id) {
7070
"background_thread" |
7171
"max_background_threads"
72-
if cfg!(target_os = "macos") => return,
72+
if cfg!(any(target_os = "macos", windows)) => return,
7373
_ => (),
7474
}
7575

@@ -117,7 +117,7 @@ macro_rules! w {
117117
match stringify!($id) {
118118
"background_thread" |
119119
"max_background_threads"
120-
if cfg!(target_os = "macos") => return,
120+
if cfg!(any(target_os = "macos", windows)) => return,
121121
_ => (),
122122
}
123123

@@ -167,7 +167,7 @@ macro_rules! u {
167167
match stringify!($id) {
168168
"background_thread" |
169169
"max_background_threads"
170-
if cfg!(target_os = "macos") => return,
170+
if cfg!(any(target_os = "macos", windows)) => return,
171171
_ => (),
172172
}
173173

jemalloc-sys/src/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub static UNSUPPORTED_TARGETS: &[&str] = &[
1212
pub static UNTESTED_TARGETS: &[&str] = &["openbsd", "msvc"];
1313

1414
/// `jemalloc`'s background_thread support is known not to work on these targets:
15-
pub static NO_BG_THREAD_TARGETS: &[&str] = &["musl"];
15+
pub static NO_BG_THREAD_TARGETS: &[&str] = &["musl", "windows"];
1616

1717
/// targets that don't support unprefixed `malloc`
1818
// “it was found that the `realpath` function in libc would allocate with libc malloc

jemallocator/tests/background_thread_enabled.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! library was compiled with background thread run-time support.
33
#![cfg(feature = "background_threads_runtime_support")]
44
#![cfg(not(feature = "unprefixed_malloc_on_supported_platforms"))]
5-
#![cfg(not(target_env = "musl"))]
5+
#![cfg(not(any(windows, target_env = "musl")))]
66

77
use tikv_jemallocator::Jemalloc;
88

0 commit comments

Comments
 (0)