Force the linker not to drop jemalloc shim on Linux#11114
Merged
Conversation
Force the linker to keep the polkadot_jemalloc_shim crate and its #[global_allocator]. Without it, the linker might drop it since it is seen as a dependency with no referenced symbols. The issue happens only on a subset of combination of rust version and linker (e.g. on CI with Ubunti 24.04, rust 1.88.0 + gcc/ld strips the jemalloc crate from the binary but not rust 1.92.0 and also rust 1.88.0 + clang/mold works fine)
Contributor
Author
|
/cmd prdoc --audience runtime_dev --bump patch |
…time_dev --bump patch'
bkchr
requested changes
Feb 19, 2026
Member
bkchr
left a comment
There was a problem hiding this comment.
Please do this change to every binary using the shim.
Co-authored-by: Bastian Köcher <git@kchr.de>
Contributor
Author
Done it here: d8ecd9e |
ggwpez
approved these changes
Feb 19, 2026
kianenigma
approved these changes
Feb 19, 2026
bkchr
approved these changes
Feb 19, 2026
paritytech-release-backport-bot Bot
pushed a commit
that referenced
this pull request
Feb 19, 2026
Force the linker to keep the `polkadot_jemalloc_shim` crate and its `#[global_allocator]` in all binaries that depend on it. Without it, the linker might drop it since it is seen as a dependency with no referenced symbols. The issue happens only on a subset of combination of rust version and linker (e.g. on CI with Ubunti 24.04, rust 1.88.0 + gcc/ld strips the jemalloc crate from the binary but not rust 1.92.0 and also rust 1.88.0 + clang/mold works fine. One way to reproduce the issue on my local Ubuntu machine using `frame-omni-bencher` as reference (current latest version v0.17.2 has the shim with jemalloc-allocator feature as dependency, as coming from PR #11069 ): 1. building with rust 1.92.0 / gcc +ld => the linker doesn't strip jemalloc allocator from the binary: ```bash nm frame-omni-bencher | grep -i jemalloc 000000000149bf60 t _GLOBAL__sub_I_jemalloc_nodump_allocator.cc 0000000000eacae0 t jemalloc_constructor 0000000000eacd50 t _rjem_je_jemalloc_postfork_child 0000000000eacc70 t _rjem_je_jemalloc_postfork_parent 0000000000eacaf0 t _rjem_je_jemalloc_prefork 000000000262bb08 b _ZN7rocksdbL18jemalloc_type_infoB5cxx11E ``` 2. building with rust 1.88.0 / gcc + ld => the linker strips aways it ```bash 000000000027f8c0 t _GLOBAL__sub_I_jemalloc_nodump_allocator.cc 00000000023a3598 b _ZN7rocksdbL18jemalloc_type_infoB5cxx11E ``` 3. building with rust 1.88.0 / clang + mold => the linker keeps it (same as 1.) Since currently CI relies on Ubuntu 24.04 gcc /ld + rust 1.88.0, we go here for the conservative approach to force the linker not to drop with the `extern crate` change in all impacted binaries. Next step - outside this PR - is to bump rust version. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de> (cherry picked from commit d774715)
|
Successfully created backport PR for |
paritytech-release-backport-bot Bot
pushed a commit
that referenced
this pull request
Feb 19, 2026
Force the linker to keep the `polkadot_jemalloc_shim` crate and its `#[global_allocator]` in all binaries that depend on it. Without it, the linker might drop it since it is seen as a dependency with no referenced symbols. The issue happens only on a subset of combination of rust version and linker (e.g. on CI with Ubunti 24.04, rust 1.88.0 + gcc/ld strips the jemalloc crate from the binary but not rust 1.92.0 and also rust 1.88.0 + clang/mold works fine. One way to reproduce the issue on my local Ubuntu machine using `frame-omni-bencher` as reference (current latest version v0.17.2 has the shim with jemalloc-allocator feature as dependency, as coming from PR #11069 ): 1. building with rust 1.92.0 / gcc +ld => the linker doesn't strip jemalloc allocator from the binary: ```bash nm frame-omni-bencher | grep -i jemalloc 000000000149bf60 t _GLOBAL__sub_I_jemalloc_nodump_allocator.cc 0000000000eacae0 t jemalloc_constructor 0000000000eacd50 t _rjem_je_jemalloc_postfork_child 0000000000eacc70 t _rjem_je_jemalloc_postfork_parent 0000000000eacaf0 t _rjem_je_jemalloc_prefork 000000000262bb08 b _ZN7rocksdbL18jemalloc_type_infoB5cxx11E ``` 2. building with rust 1.88.0 / gcc + ld => the linker strips aways it ```bash 000000000027f8c0 t _GLOBAL__sub_I_jemalloc_nodump_allocator.cc 00000000023a3598 b _ZN7rocksdbL18jemalloc_type_infoB5cxx11E ``` 3. building with rust 1.88.0 / clang + mold => the linker keeps it (same as 1.) Since currently CI relies on Ubuntu 24.04 gcc /ld + rust 1.88.0, we go here for the conservative approach to force the linker not to drop with the `extern crate` change in all impacted binaries. Next step - outside this PR - is to bump rust version. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de> (cherry picked from commit d774715)
|
Successfully created backport PR for |
sigurpol
added a commit
that referenced
this pull request
Feb 19, 2026
Backport #11114 into `stable2603` from sigurpol. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Paolo La Camera <paolo@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
sigurpol
added a commit
that referenced
this pull request
Feb 20, 2026
Backport #11114 into `stable2512` from sigurpol. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Paolo La Camera <paolo@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
arturgontijo
pushed a commit
to moonbeam-foundation/polkadot-sdk
that referenced
this pull request
Apr 1, 2026
Backport paritytech#11114 into `stable2512` from sigurpol. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Paolo La Camera <paolo@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Force the linker to keep the
polkadot_jemalloc_shimcrate and its#[global_allocator]in all binaries that depend on it. Without it, the linker might drop it since it is seen as a dependency with no referenced symbols. The issue happens only on a subset of combination of rust version and linker (e.g. on CI with Ubunti 24.04, rust 1.88.0 + gcc/ld strips the jemalloc crate from the binary but not rust 1.92.0 and also rust 1.88.0 + clang/mold works fine.One way to reproduce the issue on my local Ubuntu machine using
frame-omni-bencheras reference (current latest version v0.17.2 has the shim with jemalloc-allocator feature as dependency, as coming from PR #11069 ):nm frame-omni-bencher | grep -i jemalloc 000000000149bf60 t _GLOBAL__sub_I_jemalloc_nodump_allocator.cc 0000000000eacae0 t jemalloc_constructor 0000000000eacd50 t _rjem_je_jemalloc_postfork_child 0000000000eacc70 t _rjem_je_jemalloc_postfork_parent 0000000000eacaf0 t _rjem_je_jemalloc_prefork 000000000262bb08 b _ZN7rocksdbL18jemalloc_type_infoB5cxx11ESince currently CI relies on Ubuntu 24.04 gcc /ld + rust 1.88.0, we go here for the conservative approach to force the linker not to drop with the
extern cratechange in all impacted binaries.Next step - outside this PR - is to bump rust version.