Skip to content

Commit 41eac5d

Browse files
committed
Compatibility with macOS
1 parent 69ecba7 commit 41eac5d

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ members = [
8787
"validator_client",
8888
"validator_client/slashing_protection",
8989
]
90+
resolver = "2"
9091

9192
[patch]
9293
[patch.crates-io]

common/malloc_utils/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ lighthouse_metrics = { path = "../lighthouse_metrics" }
99
lazy_static = "1.4.0"
1010
libc = "0.2.79"
1111
parking_lot = "0.12.0"
12-
jemallocator = { version = "0.5.0", optional = true, features = ["background_threads"] }
1312
jemalloc-ctl = { version = "0.5.0", optional = true }
1413

14+
# Jemalloc's background_threads feature requires Linux (pthreads).
15+
[target.'cfg(target_os = "linux")'.dependencies]
16+
jemallocator = { version = "0.5.0", optional = true, features = ["stats", "background_threads"] }
17+
18+
[target.'cfg(not(target_os = "linux"))'.dependencies]
19+
jemallocator = { version = "0.5.0", optional = true, features = ["stats"] }
20+
1521
[features]
1622
mallinfo2 = []
17-
jemalloc = ["jemallocator", "jemallocator/stats", "jemalloc-ctl"]
18-
jemalloc-stats = ["jemallocator/stats"]
23+
jemalloc = ["jemallocator", "jemalloc-ctl"]
1924
jemalloc-profiling = ["jemallocator/profiling"]

common/malloc_utils/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
2727
#[cfg(all(
2828
target_os = "linux",
29-
not(any(target_env = "musl", feature = "jemalloc"))
29+
not(target_env = "musl"),
30+
not(feature = "jemalloc")
3031
))]
3132
mod glibc;
3233

@@ -37,7 +38,8 @@ pub use interface::*;
3738

3839
#[cfg(all(
3940
target_os = "linux",
40-
not(any(target_env = "musl", feature = "jemalloc"))
41+
not(target_env = "musl"),
42+
not(feature = "jemalloc")
4143
))]
4244
mod interface {
4345
pub use crate::glibc::configure_glibc_malloc as configure_memory_allocator;
@@ -54,7 +56,10 @@ mod interface {
5456
pub use crate::jemalloc::scrape_jemalloc_metrics as scrape_allocator_metrics;
5557
}
5658

57-
#[cfg(any(not(target_os = "linux"), target_env = "musl"))]
59+
#[cfg(all(
60+
any(not(target_os = "linux"), target_env = "musl"),
61+
not(feature = "jemalloc")
62+
))]
5863
mod interface {
5964
#[allow(dead_code, clippy::unnecessary_wraps)]
6065
pub fn configure_memory_allocator() -> Result<(), String> {

0 commit comments

Comments
 (0)