Skip to content

Commit cedab8e

Browse files
committed
switch to cc_static_library
1 parent 0b757ff commit cedab8e

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ build --incompatible_disallow_empty_glob
2323
# for details.
2424
common --incompatible_config_setting_private_default_visibility
2525

26+
# cc static lib for rust
27+
build --experimental_cc_static_library
28+
2629
# Link Google Test against Abseil and RE2.
2730
build --define='absl=1'
2831

docs/quickstart.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,6 @@ Congratulations! You've created your first binary using TCMalloc.
256256

257257
## TCMalloc-rs
258258
This is the rust wrapper for using `TCMalloc` as a global allocator.
259-
### Building
260-
To build the `tcmalloc` rust bindings, you need to turn off the `alwayslink` flag on `cc_library` targets.
261-
This is done with the `--//tcmalloc:alwayslink=false` flag.
262-
263-
`//tcmalloc:tcmalloc` with `alwayslink=1` will produce `libtcmalloc.lo` which rustc does not recognize as a valid static library ([related](https://github.com/bazelbuild/rules_rust/issues/325#issuecomment-706548453)).
264-
Optionally turning off `alwayslink` for `tcmalloc_sys` will allow `bindgen` to successfully build.
265259

266260
#### Pagesize
267261
By default, `tcmalloc` build with support for `8k` pagesize.
@@ -270,7 +264,7 @@ To build `tcmalloc` with `32k` pagesizes, build `tcmalloc_rs` with `--//tcmalloc
270264

271265
To build `tcmalloc` with `512k` pagesizes, build `tcmalloc_rs` with `--//tcmalloc_rs:pagesize=512k`
272266
### Running Tests
273-
`bazel run //tcmalloc_rs:test --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux --//tcmalloc:alwayslink=false`
267+
`bazel run //tcmalloc_rs:test --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux`
274268

275269
### Usage
276270
Add the bazel dependency:
@@ -288,7 +282,7 @@ static GLOBAL: tcmalloc_rs::TCMalloc = tcmalloc_rs::TCMalloc;
288282

289283
#### Running the example
290284
Take a look at the code in `tcmalloc_rs/main.rs` and run
291-
`bazel run //tcmalloc_rs:main --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux --//tcmalloc:alwayslink=false`.
285+
`bazel run //tcmalloc_rs:main --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux`.
292286

293287
## What's Next
294288

0 commit comments

Comments
 (0)