From 2385c13946ef480d037525d3382b9a5bd3eecad1 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Thu, 19 Feb 2026 15:52:14 +0100 Subject: [PATCH 1/3] Force the linker not to drop jemalloc shim on Linux (#11114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit d7747156e068acdd0bb4ff2d5143a8acde57410f) --- cumulus/polkadot-omni-node/src/main.rs | 4 ++++ cumulus/polkadot-parachain/src/main.rs | 4 ++++ polkadot/src/main.rs | 4 ++++ prdoc/pr_11114.prdoc | 19 +++++++++++++++++++ .../utils/frame/omni-bencher/src/main.rs | 4 ++++ 5 files changed, 35 insertions(+) create mode 100644 prdoc/pr_11114.prdoc diff --git a/cumulus/polkadot-omni-node/src/main.rs b/cumulus/polkadot-omni-node/src/main.rs index 9bc669504d8cc..8dde8f7fd6836 100644 --- a/cumulus/polkadot-omni-node/src/main.rs +++ b/cumulus/polkadot-omni-node/src/main.rs @@ -21,6 +21,10 @@ #![warn(missing_docs)] #![warn(unused_extern_crates)] +// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). +#[cfg(target_os = "linux")] +extern crate polkadot_jemalloc_shim; + use polkadot_omni_node_lib::{ chain_spec::DiskChainSpecLoader, extra_subcommand::NoExtraSubcommand, run_with_custom_cli, runtime::DefaultRuntimeResolver, CliConfig as CliConfigT, RunConfig, NODE_VERSION, diff --git a/cumulus/polkadot-parachain/src/main.rs b/cumulus/polkadot-parachain/src/main.rs index 13fc7224f28bd..ed75fd2d57285 100644 --- a/cumulus/polkadot-parachain/src/main.rs +++ b/cumulus/polkadot-parachain/src/main.rs @@ -19,6 +19,10 @@ #![warn(missing_docs)] #![warn(unused_extern_crates)] +// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). +#[cfg(target_os = "linux")] +extern crate polkadot_jemalloc_shim; + mod chain_spec; use polkadot_omni_node_lib::{run, CliConfig as CliConfigT, RunConfig, NODE_VERSION}; diff --git a/polkadot/src/main.rs b/polkadot/src/main.rs index 4a41e14d15611..252b2b931ca79 100644 --- a/polkadot/src/main.rs +++ b/polkadot/src/main.rs @@ -18,6 +18,10 @@ #![warn(missing_docs)] +// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). +#[cfg(target_os = "linux")] +extern crate polkadot_jemalloc_shim; + use color_eyre::eyre; fn main() -> eyre::Result<()> { diff --git a/prdoc/pr_11114.prdoc b/prdoc/pr_11114.prdoc new file mode 100644 index 0000000000000..da4b2770faeeb --- /dev/null +++ b/prdoc/pr_11114.prdoc @@ -0,0 +1,19 @@ +title: 'Force the linker not to drop jemalloc shim on Linux' +doc: +- audience: Runtime Dev + description: "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 Ubuntu 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).\n" +crates: +- name: frame-omni-bencher + bump: patch +- name: polkadot + bump: patch +- name: polkadot-parachain-bin + bump: patch +- name: polkadot-omni-node + bump: patch diff --git a/substrate/utils/frame/omni-bencher/src/main.rs b/substrate/utils/frame/omni-bencher/src/main.rs index f0f9ab753b074..a62a9145c3146 100644 --- a/substrate/utils/frame/omni-bencher/src/main.rs +++ b/substrate/utils/frame/omni-bencher/src/main.rs @@ -17,6 +17,10 @@ mod command; +// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). +#[cfg(target_os = "linux")] +extern crate polkadot_jemalloc_shim; + use clap::Parser; use sc_cli::Result; use tracing_subscriber::EnvFilter; From 2f7445f9ae67f0e97e333de5980be0aa974642eb Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Thu, 19 Feb 2026 17:08:51 +0100 Subject: [PATCH 2/3] Remove core-pvf-{prepare,execute}-worker from umbrella --- Cargo.lock | 2 -- umbrella/Cargo.toml | 10 ---------- 2 files changed, 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d3a812f9744f..7dce53e96f988 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16763,8 +16763,6 @@ dependencies = [ "polkadot-node-core-pvf", "polkadot-node-core-pvf-checker", "polkadot-node-core-pvf-common", - "polkadot-node-core-pvf-execute-worker", - "polkadot-node-core-pvf-prepare-worker", "polkadot-node-core-runtime-api", "polkadot-node-metrics", "polkadot-node-network-protocol", diff --git a/umbrella/Cargo.toml b/umbrella/Cargo.toml index 5b56ad19cf05e..dd52ba2a101fb 100644 --- a/umbrella/Cargo.toml +++ b/umbrella/Cargo.toml @@ -2478,16 +2478,6 @@ default-features = false optional = true path = "../polkadot/node/core/pvf/common" -[dependencies.polkadot-node-core-pvf-execute-worker] -default-features = false -optional = true -path = "../polkadot/node/core/pvf/execute-worker" - -[dependencies.polkadot-node-core-pvf-prepare-worker] -default-features = false -optional = true -path = "../polkadot/node/core/pvf/prepare-worker" - [dependencies.polkadot-node-core-runtime-api] default-features = false optional = true From 45dab9aeff8f1bfba1ad9d4303f9f4b01a332a56 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Thu, 19 Feb 2026 20:02:50 +0100 Subject: [PATCH 3/3] fix prdoc --- prdoc/pr_11114.prdoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prdoc/pr_11114.prdoc b/prdoc/pr_11114.prdoc index da4b2770faeeb..acf56b23d1fa7 100644 --- a/prdoc/pr_11114.prdoc +++ b/prdoc/pr_11114.prdoc @@ -17,3 +17,5 @@ crates: bump: patch - name: polkadot-omni-node bump: patch +- name: polkadot-sdk + bump: patch