Discard .pdr in the PSP linker script - #161484
Merged
Merged
Conversation
Collaborator
|
These commits modify compiler targets. |
Collaborator
|
Thanks for the pull request, and welcome! The Rust Project has assigned @nnethercote (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
This was referenced Aug 21, 2026
Contributor
Author
|
@nnethercote This is LLM assisted, not able to edit the label. Considering the blast radius is small and the logic is solid I thought I'd go for it. |
`.pdr` holds MIPS procedure-descriptor debug data. It is not allocated, so `--gc-sections` does not collect it, but the relocations kept for it by the target's `--emit-relocs` still refer to the functions that were collected. rust-lld reports each of those as "relocation refers to a discarded section"; a hello-world picks up 70 such warnings, now that cargo no longer suppresses linker output. Nothing on the PSP reads `.pdr`, so discard it alongside the other non-loadable sections already listed. This also drops ~9% off the resulting EBOOT. Fixes overdrivenpotato/rust-psp#203 (in part)
ItsNoHax
force-pushed
the
psp-discard-pdr
branch
from
August 21, 2026 21:44
81e0aaf to
8639b1f
Compare
Contributor
Contributor
Author
|
It was used for analysis @nnethercote. |
nnethercote
approved these changes
Aug 25, 2026
Contributor
|
@bors r+ rollup |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Aug 25, 2026
…rcote Discard `.pdr` in the PSP linker script The `mipsel-sony-psp` target passes `--emit-relocs` and relies on `--gc-sections`. `.pdr` (MIPS procedure-descriptor debug data) is not allocated, so it survives collection, but the relocations kept for it still point at the functions that *were* collected. rust-lld reports every one of those: ``` rust-lld: relocation refers to a discarded section: .text._RNvNtNtCs1mwba6qCgei_4libm4math3log3log >>> referenced by libm-...-cgu.3.rcgu.o:(.rel.pdr+0xbfa0) in archive .../liblibm-....rlib ``` A hello-world picks up **70** of these. They were always emitted; they only became visible when cargo stopped suppressing linker output, and are now reported by the `linker_messages` lint. Reported downstream as overdrivenpotato/rust-psp#203. Nothing on the PSP reads `.pdr`, so this discards it alongside the non-loadable sections the script already drops (`.MIPS.abiflags`, `.reginfo`). Discarding `.pdr` also removes `.rel.pdr`, since `--emit-relocs` only emits relocations for sections that survive. ### Verification Building `rust-psp`'s `ci/tests` suite and running it on PPSSPP: | | before | after | | ---------------------- | ----------- | ----------- | | discarded-section warnings | 70 | **0** | | `EBOOT.PBP` size | 1,395,948 B | 1,264,396 B (−9.4%) | | test suite | 47 pass / 0 fail | 47 pass / 0 fail (`FINAL_SUCCESS`) | Since the linker script lives in the target spec, I validated the exact change by building against a patched `--print target-spec-json` copy of the target, and cross-checked it by passing an equivalent `/DISCARD/` fragment as an extra `--script` to a normal `cargo psp` build. Both give the same result. This is the target's own linker script and affects no other target. The remaining warnings in that issue have a separate cause (`EF_MIPS_CPIC`) and are handled in a follow-up PR.
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 25, 2026
Rollup of 5 pull requests Successful merges: - #156749 (remove `box_patterns`) - #161411 (avoid overlapping const suggestions) - #161484 (Discard `.pdr` in the PSP linker script) - #161663 (Reduce dependency on implicit paths in bootstrap) - #161720 (rename rust_target_features query to make it clear that these are *all* target features)
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 25, 2026
Rollup merge of #161484 - ItsNoHax:psp-discard-pdr, r=nnethercote Discard `.pdr` in the PSP linker script The `mipsel-sony-psp` target passes `--emit-relocs` and relies on `--gc-sections`. `.pdr` (MIPS procedure-descriptor debug data) is not allocated, so it survives collection, but the relocations kept for it still point at the functions that *were* collected. rust-lld reports every one of those: ``` rust-lld: relocation refers to a discarded section: .text._RNvNtNtCs1mwba6qCgei_4libm4math3log3log >>> referenced by libm-...-cgu.3.rcgu.o:(.rel.pdr+0xbfa0) in archive .../liblibm-....rlib ``` A hello-world picks up **70** of these. They were always emitted; they only became visible when cargo stopped suppressing linker output, and are now reported by the `linker_messages` lint. Reported downstream as overdrivenpotato/rust-psp#203. Nothing on the PSP reads `.pdr`, so this discards it alongside the non-loadable sections the script already drops (`.MIPS.abiflags`, `.reginfo`). Discarding `.pdr` also removes `.rel.pdr`, since `--emit-relocs` only emits relocations for sections that survive. ### Verification Building `rust-psp`'s `ci/tests` suite and running it on PPSSPP: | | before | after | | ---------------------- | ----------- | ----------- | | discarded-section warnings | 70 | **0** | | `EBOOT.PBP` size | 1,395,948 B | 1,264,396 B (−9.4%) | | test suite | 47 pass / 0 fail | 47 pass / 0 fail (`FINAL_SUCCESS`) | Since the linker script lives in the target spec, I validated the exact change by building against a patched `--print target-spec-json` copy of the target, and cross-checked it by passing an equivalent `/DISCARD/` fragment as an extra `--script` to a normal `cargo psp` build. Both give the same result. This is the target's own linker script and affects no other target. The remaining warnings in that issue have a separate cause (`EF_MIPS_CPIC`) and are handled in a follow-up PR.
pull Bot
pushed a commit
to LeeeeeeM/miri
that referenced
this pull request
Aug 26, 2026
Rollup of 5 pull requests Successful merges: - rust-lang/rust#156749 (remove `box_patterns`) - rust-lang/rust#161411 (avoid overlapping const suggestions) - rust-lang/rust#161484 (Discard `.pdr` in the PSP linker script) - rust-lang/rust#161663 (Reduce dependency on implicit paths in bootstrap) - rust-lang/rust#161720 (rename rust_target_features query to make it clear that these are *all* target features)
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this pull request
Aug 28, 2026
Rollup of 5 pull requests Successful merges: - rust-lang/rust#156749 (remove `box_patterns`) - rust-lang/rust#161411 (avoid overlapping const suggestions) - rust-lang/rust#161484 (Discard `.pdr` in the PSP linker script) - rust-lang/rust#161663 (Reduce dependency on implicit paths in bootstrap) - rust-lang/rust#161720 (rename rust_target_features query to make it clear that these are *all* target features)
vetleras
pushed a commit
to vetleras/rustfmt
that referenced
this pull request
Aug 28, 2026
Rollup of 5 pull requests Successful merges: - rust-lang/rust#156749 (remove `box_patterns`) - rust-lang/rust#161411 (avoid overlapping const suggestions) - rust-lang/rust#161484 (Discard `.pdr` in the PSP linker script) - rust-lang/rust#161663 (Reduce dependency on implicit paths in bootstrap) - rust-lang/rust#161720 (rename rust_target_features query to make it clear that these are *all* target features)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
mipsel-sony-psptarget passes--emit-relocsand relies on--gc-sections..pdr(MIPS procedure-descriptor debug data) is not allocated, so it survives collection, but the relocations kept for it still point at the functions that were collected. rust-lld reports every one of those:A hello-world picks up 70 of these. They were always emitted; they only became visible when cargo stopped suppressing linker output, and are now reported by the
linker_messageslint. Reported downstream as overdrivenpotato/rust-psp#203.Nothing on the PSP reads
.pdr, so this discards it alongside the non-loadable sections the script already drops (.MIPS.abiflags,.reginfo). Discarding.pdralso removes.rel.pdr, since--emit-relocsonly emits relocations for sections that survive.Verification
Building
rust-psp'sci/testssuite and running it on PPSSPP:EBOOT.PBPsizeFINAL_SUCCESS)Since the linker script lives in the target spec, I validated the exact change by building against a patched
--print target-spec-jsoncopy of the target, and cross-checked it by passing an equivalent/DISCARD/fragment as an extra--scriptto a normalcargo pspbuild. Both give the same result.This is the target's own linker script and affects no other target. The remaining warnings in that issue have a separate cause (
EF_MIPS_CPIC) and are handled in a follow-up PR.