From 7e1b19bad79874d3d93f4389ad64ee908d2642c3 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 6 Oct 2026 18:32:21 -0400 Subject: [PATCH] debugger: stabilize trim-paths unremap file loading ## Stabilization report ### What is stabilized With trim-paths `object` scope and debuginfo on, Cargo writes `.trim-paths.json` beside each final artifact. The "unremap" file maps the remapped paths back to local ones. This stabilizes debugger script changes: `rust-gdb` and `rust-lldb` by default load `{gdb,lldb}_trim_paths.py`, which read the unremap files and apply them through GDB `substitute-path` or LLDB `target.source-map` to set up source file path substitutions. ### What changes * After stabilization, set `RUST_{GDB,LLDB}_TRIM_PATHS=0` to opt out. Before, this needed `RUST_{GDB,LLDB}_TRIM_PATHS=unstable`. * After stabilization, both scripts are shipped on all channels. Before, they were shipped only on nightly. ### Why we don't want to stabilize * This makes debugger scripts relying on Cargo-specific file format, inversing the dependency relation. * There is no integration test for them. (and debugger scripts actually don't have many tests) ### Docs See Cargo's the "Unremap files" section: --- src/bootstrap/src/core/build_steps/dist.rs | 8 ++------ src/etc/rust-gdb | 8 ++++---- src/etc/rust-lldb | 8 ++++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index b3a6817b5d467..be34f1be63fe7 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -776,9 +776,7 @@ impl Step for DebuggerScripts { cp_debugger_script("gdb_load_rust_pretty_printers.py"); cp_debugger_script("gdb_lookup.py"); cp_debugger_script("gdb_providers.py"); - if builder.sess.unstable_features() { - cp_debugger_script("gdb_trim_paths.py"); - } + cp_debugger_script("gdb_trim_paths.py"); // lldb debugger scripts builder.install( @@ -789,9 +787,7 @@ impl Step for DebuggerScripts { cp_debugger_script("lldb_lookup.py"); cp_debugger_script("lldb_providers.py"); - if builder.sess.unstable_features() { - cp_debugger_script("lldb_trim_paths.py"); - } + cp_debugger_script("lldb_trim_paths.py"); } } diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb index 885f69bfbc35a..e75a804271d7f 100755 --- a/src/etc/rust-gdb +++ b/src/etc/rust-gdb @@ -28,11 +28,11 @@ set -- \ -iex "set substitute-path /rustc/$RUSTC_COMMIT_HASH $RUSTC_SYSROOT/lib/rustlib/src/rust" \ "$@" -# Unstable (nightly-only) trim-paths feature, activated only if -# - RUST_GDB_TRIM_PATHS=unstable is set -# - and if the python file is present (only shipped on nightly) +# Load Cargo trim-paths unremap files beside each loaded binary. +# +# Set RUST_GDB_TRIM_PATHS=0 to disable this feature. GDB_TRIM_PATHS="$GDB_PYTHON_MODULE_DIRECTORY/gdb_trim_paths.py" -if [ "${RUST_GDB_TRIM_PATHS:-}" = "unstable" ] && [ -f "$GDB_TRIM_PATHS" ]; then +if [ "${RUST_GDB_TRIM_PATHS:-}" != "0" ] && [ -f "$GDB_TRIM_PATHS" ]; then set -- -x "$GDB_TRIM_PATHS" "$@" fi diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb index c99357f324989..2485b232f269f 100755 --- a/src/etc/rust-lldb +++ b/src/etc/rust-lldb @@ -32,11 +32,11 @@ fi script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_lookup.py\"" -# Unstable (nightly-only) trim-paths feature, activated only if -# - RUST_LLDB_TRIM_PATHS=unstable is set -# - and if the python file is present (only shipped on nightly) +# Load Cargo trim-paths unremap files beside each loaded binary. +# +# Set RUST_LLDB_TRIM_PATHS=0 to disable this feature. LLDB_TRIM_PATHS="$RUSTC_SYSROOT/lib/rustlib/etc/lldb_trim_paths.py" -if [ "${RUST_LLDB_TRIM_PATHS:-}" = "unstable" ] && [ -f "$LLDB_TRIM_PATHS" ]; then +if [ "${RUST_LLDB_TRIM_PATHS:-}" != "0" ] && [ -f "$LLDB_TRIM_PATHS" ]; then set -- --one-line-before-file "command script import \"$LLDB_TRIM_PATHS\"" "$@" fi