Skip to content

allow windows-gnu targets to embed gdb visualizer scripts#154840

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Walnut356:windows_gdb_embed
Apr 12, 2026
Merged

allow windows-gnu targets to embed gdb visualizer scripts#154840
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Walnut356:windows_gdb_embed

Conversation

@Walnut356
Copy link
Copy Markdown
Contributor

Pretty straigthforward, works exactly the same as any other *-gnu target so i'm not sure why it wasn't enabled already.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 5, 2026

These commits modify compiler targets.
(See the Target Tier Policy.)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 5, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 11 candidates

@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented Apr 5, 2026

cc *-windows-gnullvm target maintainers in case you know of any issues with embedding gdb visualizer scripts
@mati865 @thomcc

@mati865
Copy link
Copy Markdown
Member

mati865 commented Apr 5, 2026

IIRC this was because it requires GDB with Python support, which was not that common back in the day. Considering that https://github.com/niXman/mingw-builds-binaries now provides Python3 this is probably fine.

I'll test it next week, r? @mati865

@rustbot rustbot assigned mati865 and unassigned chenyukang Apr 5, 2026
@mati865
Copy link
Copy Markdown
Member

mati865 commented Apr 5, 2026

@bors try jobs=dist-x86_64-llvm-mingw,dist-x86_64-mingw

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 5, 2026
allow `windows-gnu` targets to embed gdb visualizer scripts


try-job: dist-x86_64-llvm-mingw
try-job: dist-x86_64-mingw
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 5, 2026

☀️ Try build successful (CI)
Build commit: e1f2d44 (e1f2d44674ff1da2152446756fed287873e13d5b, parent: e73c56abd0baf3dbaafbdc3ce6072a416aade867)

@mati865
Copy link
Copy Markdown
Member

mati865 commented Apr 12, 2026

How did you test that?

LLD discards this section, so building for windows-gnullvm targets or windows-gnu with LLD as the linker results in binaries without this section.

Then testing with windows-gnu and the default ld.bfd linker, and regular GDB binary there is a warning about missing scripts:

❯ gdb --version
GNU gdb (GDB) 17.1
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

❯ gdb -q foo.exe
Reading symbols from foo.exe...
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file G:\msys64\tmp\foo.exe.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) i auto-load
gdb-scripts:  No auto-load scripts.
local-gdbinit:  Local .gdbinit file was not found.
python-scripts:
Loaded  Script
No      gdb_load_rust_pretty_printers.py
...
(gdb) print x
$1 = alloc::vec::Vec<i32, alloc::alloc::Global> {buf: alloc::raw_vec::RawVec<i32, alloc::alloc::Global> {inner: alloc::raw_vec::RawVecInner<alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: core::ptr::non_null::NonNull<u8> {pointer: 0xc7960}, _marker: core::marker::PhantomData<u8>}, cap: core::num::niche_types::UsizeNoHighBit (3), alloc: alloc::alloc::Global}, _marker: core::marker::PhantomData<i32>}, len: 3}

It appears to load fine when using rust-gdb which is non-trivial on this target and requires specifying exact path:

❯ rust-gdb +nightly-x86_64-pc-windows-gnu foo.exe
error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'nightly-x86_64-pc-windows-gnu' toolchain

❯ /c/Users/Mateusz/.rustup/toolchains/nightly-x86_64-pc-windows-gnu/bin/rust-gdb -q foo.exe
Reading symbols from foo.exe...
(gdb) i auto-load
gdb-scripts:  No auto-load scripts.
local-gdbinit:  Local .gdbinit file was not found.
python-scripts:
Loaded  Script
Yes     gdb_load_rust_pretty_printers.py
        full name: C:\Users\Mateusz\.rustup\toolchains\nightly-x86_64-pc-windows-gnu\lib\rustlib\etc\gdb_load_rust_pretty_printers.py
...
(gdb) print x
$1 = Vec(size=3) = {1, 2, 3}

So, there is a benefit from this change, but only when doing additional setup, otherwise this results in a warning each time you start the debugger.
Based on the outcome this doesn't sound to me like embedding the script, more like referencing it in the auto-load. Is it supposed to work this way?

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 12, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 12, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 12, 2026
@Walnut356
Copy link
Copy Markdown
Contributor Author

LLD discards this section

Yeah, that's definitely weird. I dont know enough about linkers to know why it's happening. ld worked fine for me as well.

Based on the outcome this doesn't sound to me like embedding the script, more like referencing it in the auto-load. Is it supposed to work this way?

As I understand it, since these are arbitrary python scripts being run automatically, there's a huge security risk. That means all auto-load scripts are opt-in, even when they're embedded. rust-gdb more or less just automatically opts the user in for that session.

The rust-distributed scripts are embedded via a reference to the script file's location, rather than embedding the full script source code (which is what happens via #![debugger_visualizer]). That's somewhat convenient because:

  1. You can add the rust-distributed script path to your auto-load safe path via .gdbinit and have them loaded for all gdb debugging sessions (even without rust-gdb)
  2. If you do the above, you opt in to rust's visualizers but not any other visualizer embedded in the binary, which is a nice option to have, security-wise.

Without this change, the only way to use the rust visualizers is rust-gdb or manually loading the scripts yourself. Additionally, anything specified by #![debugger_visualizer] is completely discarded at compile time, so if a dependency has a visualizer script, you would need to manually obtain the script and manually load it in at debug-time.

While there is friction even with the change, i dont think it's a huge deal. I havent gotten to look at the debug info survey results, but i'd hazard a guess and say that the population that uses GDB on windows is absolutely minuscule. Anyone that's doing it is jumping through hoops to use gdb anyway, so they'll probably be more tolerant of a few bumps.

@Walnut356
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 12, 2026
@mati865
Copy link
Copy Markdown
Member

mati865 commented Apr 12, 2026

Yeah, that's definitely weird. I dont know enough about linkers to know why it's happening. ld worked fine for me as well.

I guess this section is not marked as excluded from GC in MinGW/COFF backend, but I haven't tested it.


Thanks for the explanation, I have tested it on Linux and it behaves the same way.

Without this change, the only way to use the rust visualizers is rust-gdb or manually loading the scripts yourself.

FWIW, without this change even using rust-gdb doesn't provide visualizers (at least on Linux), I had to manually load the script. To test Linux binary without this section I had used objcopy -R .debug_gdb_scripts foo foo_no_vis.

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 12, 2026

📌 Commit 472b966 has been approved by mati865

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 12, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 12, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 12, 2026

☀️ Test successful - CI
Approved by: mati865
Duration: 3h 41m 15s
Pushing 14196db to main...

@rust-bors rust-bors Bot merged commit 14196db into rust-lang:main Apr 12, 2026
13 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing dab8d9d (parent) -> 14196db (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 14196dbfa3eb7c30195251eac092b1b86c8a2d84 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. aarch64-apple: 2h 48m -> 3h 34m (+27.2%)
  2. dist-aarch64-apple: 2h 22m -> 1h 47m (-24.4%)
  3. dist-x86_64-apple: 1h 56m -> 1h 39m (-14.4%)
  4. dist-aarch64-msvc: 1h 41m -> 1h 49m (+7.9%)
  5. dist-loongarch64-linux: 1h 54m -> 1h 46m (-7.0%)
  6. dist-aarch64-llvm-mingw: 1h 35m -> 1h 42m (+7.0%)
  7. i686-gnu-1: 2h 24m -> 2h 14m (-7.0%)
  8. pr-check-1: 33m 9s -> 30m 58s (-6.6%)
  9. x86_64-mingw-2: 2h 42m -> 2h 32m (-6.5%)
  10. x86_64-mingw-1: 2h 37m -> 2h 47m (+6.4%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (14196db): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.8% [2.8%, 2.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 2.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.4% [3.6%, 7.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.9% [-1.9%, -1.9%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.2%, secondary -20.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.2% [1.5%, 2.6%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-20.5% [-20.5%, -20.5%] 1
All ❌✅ (primary) 2.2% [1.5%, 2.6%] 3

Binary size

Results (secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 489.963s -> 491.114s (0.23%)
Artifact size: 394.27 MiB -> 394.23 MiB (-0.01%)

@folkertdev
Copy link
Copy Markdown
Contributor

Could this be the cause of #155277? It's a PR that vaguely matches the symptoms we see and I think it's part of the right nightly range.

@mati865
Copy link
Copy Markdown
Member

mati865 commented Apr 14, 2026

Yeah, we will have to revert this PR.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 14, 2026
…tdev

Revert "allow `windows-gnu` targets to embed gdb visualizer scripts"

Fixes rust-lang#155277

This reverts commit 472b966.

This was merged as rust-lang#154840, but causes linker errors in the wild.

cc @Walnut356 @mati865
r? @ghost
rust-timer added a commit that referenced this pull request Apr 14, 2026
Rollup merge of #155281 - folkertdev:revert-154840, r=folkertdev

Revert "allow `windows-gnu` targets to embed gdb visualizer scripts"

Fixes #155277

This reverts commit 472b966.

This was merged as #154840, but causes linker errors in the wild.

cc @Walnut356 @mati865
r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants