buildRustCrate: remap rustc store path to break rust-src closure leak
When the rust-src component is installed (common with rust-overlay toolchains via rust-toolchain.toml), rustc unvirtualises libstd source paths. Panic locations from monomorphised generic std code (BTreeMap, VecDeque, sync primitives, etc.) then embed the toolchain store path in .rodata, pulling the entire multi-GB toolchain into the runtime closure. This is not an RPATH issue — stdenv's patchelf --shrink-rpath already cleans that. The reference is a core::panic::Location string. Remap the rustc store path to /rustc so panic messages stay readable but no longer create a store-path dependency. This is a no-op for toolchains without rust-src (the prefix simply never matches).
This commit is contained in:
@@ -31,6 +31,12 @@ let
|
||||
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||
"-C codegen-units=${toString codegenUnits}"
|
||||
"--remap-path-prefix=$NIX_BUILD_TOP=/"
|
||||
# When the rust-src component is present (common with rust-overlay
|
||||
# toolchains), rustc unvirtualises libstd source paths. Panic
|
||||
# locations from monomorphised generic std code then embed the
|
||||
# toolchain store path in .rodata, pulling the entire toolchain into
|
||||
# the closure. Remap to a stable placeholder to break the reference.
|
||||
"--remap-path-prefix=${rustc}=/rustc"
|
||||
(mkRustcDepArgs dependencies crateRenames)
|
||||
(mkRustcFeatureArgs crateFeatures)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user