From 08526b51ad58d96e0e538729a8515d2b085777aa Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Thu, 19 Feb 2026 13:29:27 +0100 Subject: [PATCH 1/5] frame-omni-bencher: force the linker not to drop jemalloc shim on Linux 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) --- substrate/utils/frame/omni-bencher/src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/substrate/utils/frame/omni-bencher/src/main.rs b/substrate/utils/frame/omni-bencher/src/main.rs index f0f9ab753b074..86e4f9165ba65 100644 --- a/substrate/utils/frame/omni-bencher/src/main.rs +++ b/substrate/utils/frame/omni-bencher/src/main.rs @@ -17,6 +17,15 @@ mod command; +// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). +// Without it, the shim is seen as a dependency that produces no referenced symbols, so the linker +// might drop it. We have seen it happening on CI with rust 1.88.0 and gcc/ld from Ubuntu 24.04 but +// not with rust 1.92.0 and the same linker. It also works without the extern crate declaration on +// both rust 1.88.0 and 1.92.0 when using clang/ld or mold, so it seems to be a combination of rust +// version and linker. +#[cfg(target_os = "linux")] +extern crate polkadot_jemalloc_shim; + use clap::Parser; use sc_cli::Result; use tracing_subscriber::EnvFilter; From 3b19425f095a25869be934272c01968eb982c4d2 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 12:33:35 +0000 Subject: [PATCH 2/5] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump patch' --- prdoc/pr_11114.prdoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 prdoc/pr_11114.prdoc diff --git a/prdoc/pr_11114.prdoc b/prdoc/pr_11114.prdoc new file mode 100644 index 0000000000000..1e3035c5bd3b1 --- /dev/null +++ b/prdoc/pr_11114.prdoc @@ -0,0 +1,12 @@ +title: 'frame-omni-bencher: 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]. 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\r\n" +crates: +- name: frame-omni-bencher + bump: patch From 48f3ef0c56e62765881bc561d76389bf3b7b8574 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Thu, 19 Feb 2026 13:38:11 +0100 Subject: [PATCH 3/5] Review suggestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- substrate/utils/frame/omni-bencher/src/main.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/substrate/utils/frame/omni-bencher/src/main.rs b/substrate/utils/frame/omni-bencher/src/main.rs index 86e4f9165ba65..a62a9145c3146 100644 --- a/substrate/utils/frame/omni-bencher/src/main.rs +++ b/substrate/utils/frame/omni-bencher/src/main.rs @@ -18,11 +18,6 @@ mod command; // Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). -// Without it, the shim is seen as a dependency that produces no referenced symbols, so the linker -// might drop it. We have seen it happening on CI with rust 1.88.0 and gcc/ld from Ubuntu 24.04 but -// not with rust 1.92.0 and the same linker. It also works without the extern crate declaration on -// both rust 1.88.0 and 1.92.0 when using clang/ld or mold, so it seems to be a combination of rust -// version and linker. #[cfg(target_os = "linux")] extern crate polkadot_jemalloc_shim; From d8ecd9ee40849db41056fbb8462b90cf5da9b5f2 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Thu, 19 Feb 2026 14:28:55 +0100 Subject: [PATCH 4/5] Same treatment for more binaries --- cumulus/polkadot-omni-node/src/main.rs | 4 ++++ cumulus/polkadot-parachain/src/main.rs | 4 ++++ polkadot/src/bin/execute-worker.rs | 4 ++++ polkadot/src/bin/prepare-worker.rs | 4 ++++ polkadot/src/main.rs | 4 ++++ prdoc/pr_11114.prdoc | 19 +++++++++++++------ 6 files changed, 33 insertions(+), 6 deletions(-) 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 52eac2ce8b657..52ba1944e3655 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::{ diff --git a/polkadot/src/bin/execute-worker.rs b/polkadot/src/bin/execute-worker.rs index c39a5a3c89de7..0b782a37f4259 100644 --- a/polkadot/src/bin/execute-worker.rs +++ b/polkadot/src/bin/execute-worker.rs @@ -16,6 +16,10 @@ //! Execute worker. +// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). +#[cfg(target_os = "linux")] +extern crate polkadot_jemalloc_shim; + polkadot_node_core_pvf_common::decl_worker_main!( "execute-worker", polkadot_node_core_pvf_execute_worker::worker_entrypoint, diff --git a/polkadot/src/bin/prepare-worker.rs b/polkadot/src/bin/prepare-worker.rs index 3b42991f18baa..99d5173068858 100644 --- a/polkadot/src/bin/prepare-worker.rs +++ b/polkadot/src/bin/prepare-worker.rs @@ -16,6 +16,10 @@ //! Prepare worker. +// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). +#[cfg(target_os = "linux")] +extern crate polkadot_jemalloc_shim; + polkadot_node_core_pvf_common::decl_worker_main!( "prepare-worker", polkadot_node_core_pvf_prepare_worker::worker_entrypoint, 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 index 1e3035c5bd3b1..da4b2770faeeb 100644 --- a/prdoc/pr_11114.prdoc +++ b/prdoc/pr_11114.prdoc @@ -1,12 +1,19 @@ -title: 'frame-omni-bencher: force the linker not to drop jemalloc shim on Linux' +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]. 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\r\n" + \ #[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 From f0260743e3fa70b3916ef2d85ba983b2ce1cd3b0 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Thu, 19 Feb 2026 14:54:10 +0100 Subject: [PATCH 5/5] fix CI --- polkadot/src/bin/execute-worker.rs | 4 ---- polkadot/src/bin/prepare-worker.rs | 4 ---- 2 files changed, 8 deletions(-) diff --git a/polkadot/src/bin/execute-worker.rs b/polkadot/src/bin/execute-worker.rs index 0b782a37f4259..c39a5a3c89de7 100644 --- a/polkadot/src/bin/execute-worker.rs +++ b/polkadot/src/bin/execute-worker.rs @@ -16,10 +16,6 @@ //! Execute worker. -// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). -#[cfg(target_os = "linux")] -extern crate polkadot_jemalloc_shim; - polkadot_node_core_pvf_common::decl_worker_main!( "execute-worker", polkadot_node_core_pvf_execute_worker::worker_entrypoint, diff --git a/polkadot/src/bin/prepare-worker.rs b/polkadot/src/bin/prepare-worker.rs index 99d5173068858..3b42991f18baa 100644 --- a/polkadot/src/bin/prepare-worker.rs +++ b/polkadot/src/bin/prepare-worker.rs @@ -16,10 +16,6 @@ //! Prepare worker. -// Force the linker to keep the polkadot_jemalloc_shim crate (and its #[global_allocator]). -#[cfg(target_os = "linux")] -extern crate polkadot_jemalloc_shim; - polkadot_node_core_pvf_common::decl_worker_main!( "prepare-worker", polkadot_node_core_pvf_prepare_worker::worker_entrypoint,