Skip to content

Commit d36dfe5

Browse files
ryancinsightmjp41
authored andcommitted
docs: update README and Cargo.toml for build alignment and new features
1 parent c59be91 commit d36dfe5

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

snmalloc-rs/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ notls = ["snmalloc-sys/notls"]
3434
stats = ["snmalloc-sys/stats"]
3535
usewait-on-address = ["snmalloc-sys/usewait-on-address"]
3636
libc-api = ["snmalloc-sys/libc-api"]
37+
tracing = ["snmalloc-sys/tracing"]
38+
fuzzing = ["snmalloc-sys/fuzzing"]
39+
vendored-stl = ["snmalloc-sys/vendored-stl"]
40+
check-loads = ["snmalloc-sys/check-loads"]
41+
pageid = ["snmalloc-sys/pageid"]
42+
gwp-asan = ["snmalloc-sys/gwp-asan"]

snmalloc-rs/README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,14 @@ a global allocator for rust. snmalloc is a research allocator. Its key design fe
1818
Some old benchmark results are available in
1919
the [`snmalloc` paper](https://github.com/microsoft/snmalloc/blob/master/snmalloc.pdf). Some recent benchmark results
2020
are listed at
21-
[bench_suite](https://github.com/SchrodingerZhu/bench_suite). There are three features defined in this crate:
21+
[bench_suite](https://github.com/SchrodingerZhu/bench_suite). There are following features defined in this crate:
2222

23-
- `debug`: Enable the `Debug` mode in `snmalloc`.
24-
- ~~`1mib`: Use the `1mib` chunk configuration. From `0.2.17`, this is set as a default feature~~ (removed since 0.3.0)
25-
- ~~`16mib`: Use the `16mib` chunk configuration.~~ (removed since 0.3.0)
26-
- ~~`cache-friendly`: Make the allocator more cache friendly (setting `CACHE_FRIENDLY_OFFSET` to `64` in building the
27-
library).~~ (removed since 0.3.0)
23+
- `debug`: Enable the `Debug` mode in `snmalloc`. This is also automatically enabled if Cargo's `DEBUG` environment variable is set to `true`.
2824
- `native-cpu`: Optimize `snmalloc` for the native CPU of the host machine. (this is not a default behavior
2925
since `0.2.14`)
3026
- `qemu`: Workaround `madvise` problem of QEMU environment
31-
- ~~`stats`: Enable statistics~~ (removed since 0.3.0)
3227
- `local_dynamic_tls`: Workaround cannot allocate memory in static tls block
3328
- `build_cc`: Use of cc crate instead of cmake (cmake still default) as builder (more platform agnostic)
34-
- ~~`usecxx20`: Enable C++20 standard if available~~ (removed since 0.3.0)
3529
- `usecxx17`: Use C++17 standard
3630
- `check`: Enable extra checks to improve security, see upstream [security docs](https://github.com/microsoft/snmalloc/tree/main/docs/security).
3731
Note that the `memcpy` protection is not enabled in Rust.
@@ -40,6 +34,25 @@ are listed at
4034
- `notls`: Enables to be loaded dynamically, thus disable tls.
4135
- `stats`: Enables allocation statistics.
4236
- `libc-api`: Enables libc API backed by snmalloc.
37+
- `usewait-on-address`: Enable `WaitOnAddress` support on Windows (enabled by default).
38+
- `tracing`: Enable structured tracing/logging.
39+
- `fuzzing`: Enable fuzzing support.
40+
- `vendored-stl`: Use self-vendored STL.
41+
- `check-loads`: Enable check loads feature.
42+
- `pageid`: Enable page ID feature.
43+
- `gwp-asan`: Enable GWP-ASan integration. Requires `SNMALLOC_GWP_ASAN_INCLUDE_PATH` and `SNMALLOC_GWP_ASAN_LIBRARY_PATH`.
44+
45+
## Build Configuration
46+
47+
The build script ensures architectural alignment between the Rust profile and the underlying `snmalloc` allocator:
48+
49+
### Environment Variables
50+
The following environment variables are automatically detected and propagated:
51+
- `DEBUG`: Synchronizes the `snmalloc` build type with the Cargo profile. If `true`, `snmalloc` is built in `Debug` mode.
52+
- `OPT_LEVEL`: Propagated to the C++ compiler to ensure optimization parity between Rust and C++ components.
53+
54+
### Windows CRT Consistency
55+
On Windows, the build script enforces static CRT linking (`/MT` or `/MTd`) across both `cc` and `cmake` builders. This prevents linker errors and ensures consistency when `snmalloc` is used as a global allocator.
4356

4457
**To get the crates compiled, you need to choose either `1mib` or `16mib` to determine the chunk configuration**
4558

0 commit comments

Comments
 (0)