Skip to content

Commit e157459

Browse files
authored
Merge pull request #52 from linxGnu/adapt_mimalloc_2
Update extended options, fix build
2 parents 3461455 + 6e47c9b commit e157459

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

libmimalloc-sys/build.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ fn main() {
9595
Ok(CMakeBuildType::MinSizeRel) => (false, "MinSizeRel"),
9696
Err(e) => panic!("Cannot determine CMake build type: {}", e),
9797
};
98+
99+
// Turning off shared lib, tests, PADDING.
100+
// See also: https://github.com/microsoft/mimalloc/blob/master/CMakeLists.txt
101+
cfg = cfg.define("MI_PADDING", "OFF");
102+
cfg = cfg.define("MI_BUILD_TESTS", "OFF");
103+
cfg = cfg.define("MI_BUILD_SHARED", "OFF");
104+
cfg = cfg.define("MI_BUILD_OBJECT", "OFF");
105+
98106
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
99107
if target_env == "msvc" {
100108
cfg = cfg.define("CMAKE_SH", "CMAKE_SH-NOTFOUND");
@@ -114,10 +122,10 @@ fn main() {
114122
// Those flags prevents mimalloc from building on windows
115123
if is_debug {
116124
// CMAKE_C_FLAGS + CMAKE_C_FLAGS_DEBUG
117-
cfg = cfg.cflag("-static -ffunction-sections -fdata-sections -m64 -O2 -fpic");
125+
cfg = cfg.cflag("-ffunction-sections -fdata-sections -m64 -O2 -fpic");
118126
} else {
119127
// CMAKE_C_FLAGS + CMAKE_C_FLAGS_RELEASE
120-
cfg = cfg.cflag("-static -ffunction-sections -fdata-sections -m64 -O3 -fpic");
128+
cfg = cfg.cflag("-ffunction-sections -fdata-sections -m64 -O3 -fpic");
121129
}
122130
};
123131

libmimalloc-sys/src/extended.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,11 @@ pub const mi_option_large_os_pages: mi_option_t = 6;
371371
/// allocate just a little to take up space in the huge OS page area (which cannot be reset).
372372
pub const mi_option_reserve_huge_os_pages: mi_option_t = 7;
373373

374+
/// TODO: update later
375+
pub const mi_option_reserve_os_memory: mi_option_t = 8;
376+
374377
/// Option (experimental) specifying number of segments per thread to keep cached.
375-
pub const mi_option_segment_cache: mi_option_t = 8;
378+
pub const mi_option_segment_cache: mi_option_t = 9;
376379

377380
/// Option (experimental) to reset page memory after mi_option_reset_delay milliseconds when it becomes free.
378381
///
@@ -384,19 +387,19 @@ pub const mi_option_segment_cache: mi_option_t = 8;
384387
/// off completely.
385388
///
386389
/// Default: 1 (true)
387-
pub const mi_option_page_reset: mi_option_t = 9;
390+
pub const mi_option_page_reset: mi_option_t = 10;
388391

389392
/// Experimental
390-
pub const mi_option_abandoned_page_reset: mi_option_t = 10;
393+
pub const mi_option_abandoned_page_reset: mi_option_t = 11;
391394

392395
/// Experimental
393-
pub const mi_option_segment_reset: mi_option_t = 11;
396+
pub const mi_option_segment_reset: mi_option_t = 12;
394397

395398
/// Experimental
396-
pub const mi_option_eager_commit_delay: mi_option_t = 12;
399+
pub const mi_option_eager_commit_delay: mi_option_t = 13;
397400

398401
/// Option (experimental) specifying delay in milli-seconds before resetting a page (100ms by default).
399-
pub const mi_option_reset_delay: mi_option_t = 13;
402+
pub const mi_option_reset_delay: mi_option_t = 14;
400403

401404
/// Option (experimental) to pretend there are at most N NUMA nodes.
402405
///
@@ -405,13 +408,16 @@ pub const mi_option_reset_delay: mi_option_t = 13;
405408
/// actual NUMA nodes is fine and will only cause threads to potentially allocate more
406409
/// memory across actual NUMA nodes (but this can happen in any case as NUMA local
407410
/// allocation is always a best effort but not guaranteed).
408-
pub const mi_option_use_numa_nodes: mi_option_t = 14;
411+
pub const mi_option_use_numa_nodes: mi_option_t = 15;
412+
413+
/// TODO: update later
414+
pub const mi_option_limit_os_alloc: mi_option_t = 16;
409415

410416
/// Option (experimental) specifying OS tag to assign to mimalloc'd memory.
411-
pub const mi_option_os_tag: mi_option_t = 15;
417+
pub const mi_option_os_tag: mi_option_t = 17;
412418

413419
/// Experimental
414-
pub const mi_option_max_errors: mi_option_t = 16;
420+
pub const mi_option_max_errors: mi_option_t = 18;
415421

416422
extern "C" {
417423
// Note: mi_option_{enable,disable} aren't exposed because they're redundant

0 commit comments

Comments
 (0)