Skip to content

Staticlib rename internal symbols: add COFF support - #160679

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
cezarbbb:staticlib-rename-coff
Sep 21, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
cezarbbb:staticlib-rename-coff

Conversation

@cezarbbb

@cezarbbb cezarbbb commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Follow-up to #156950.

-Zstaticlib-rename-internal-symbols now also works on COFF targets (Windows). Renaming only rewrites symbol names, so unlike hide it needs no visibility concept.

COFF objects keep their string table at the end of the file, so renames append the new names there and patch the 4-byte length prefix plus each symbol's name offset in place. Both regular and bigobj objects are handled; on i686 a leading underscore is stripped when matching against the exported set. The archive format differs (GNU ar on windows-gnu, COFF on windows-msvc) but the members are always COFF objects, so the existing archive code is unchanged.

Supported on ELF, Apple, and COFF targets. -Zstaticlib-hide-internal-symbols remains ELF/Apple-only and still warns on Windows.

A run-make test staticlib-rename-internal-symbols-coff mirrors the existing ELF and Mach-O tests.

r? @bjorn3

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs 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 Aug 7, 2026
@cezarbbb
cezarbbb force-pushed the staticlib-rename-coff branch from 3a890b2 to 3d2cea7 Compare August 7, 2026 09:25
@rustbot

This comment has been minimized.

Comment thread compiler/rustc_codegen_ssa/src/back/symbol_edit.rs Outdated
Comment thread compiler/rustc_codegen_ssa/src/back/symbol_edit.rs Outdated
@bjorn3 bjorn3 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 27, 2026
@cezarbbb
cezarbbb force-pushed the staticlib-rename-coff branch 4 times, most recently from 02dd471 to e03085d Compare August 28, 2026 03:44
@rustbot

This comment has been minimized.

@cezarbbb

Copy link
Copy Markdown
Contributor Author

It has been rebaseed to upstream.

@bjorn3

bjorn3 commented Sep 15, 2026

Copy link
Copy Markdown
Member

@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 Sep 15, 2026
Comment thread tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs Outdated
Comment thread tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs Outdated
Comment thread compiler/rustc_codegen_ssa/src/back/link.rs Outdated
@bjorn3 bjorn3 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 17, 2026
@cezarbbb
cezarbbb force-pushed the staticlib-rename-coff branch from e03085d to e69bf11 Compare September 18, 2026 02:33
@rustbot

rustbot commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@cezarbbb
cezarbbb force-pushed the staticlib-rename-coff branch from e69bf11 to f330047 Compare September 18, 2026 02:52
@cezarbbb

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 Sep 18, 2026
@bjorn3

bjorn3 commented Sep 21, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f330047 has been approved by bjorn3

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 Sep 21, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 21, 2026
…bjorn3

Staticlib rename internal symbols: add COFF support

Follow-up to rust-lang#156950.

`-Zstaticlib-rename-internal-symbols` now also works on COFF targets (Windows). Renaming only rewrites symbol names, so unlike hide it needs no visibility concept.

COFF objects keep their string table at the end of the file, so renames append the new names there and patch the 4-byte length prefix plus each symbol's name offset in place. Both regular and bigobj objects are handled; on i686 a leading underscore is stripped when matching against the exported set. The archive format differs (GNU ar on windows-gnu, COFF on windows-msvc) but the members are always COFF objects, so the existing archive code is unchanged.

Supported on ELF, Apple, and COFF targets. `-Zstaticlib-hide-internal-symbols` remains ELF/Apple-only and still warns on Windows.

A run-make test `staticlib-rename-internal-symbols-coff` mirrors the existing ELF and Mach-O tests.

r? @bjorn3
rust-bors Bot pushed a commit that referenced this pull request Sep 21, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #163083 (Remove `G` generic param from `Diag<'_, G>`)
 - #160679 (Staticlib rename internal symbols: add COFF support)
 - #162007 (Preserve parentheses in raw borrow suggestions)
 - #163057 (Use span context for enclosing item(s) of unmet bound)
 - #163070 (label the path segment that is not an associated item of the trait)
 - #163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
rust-bors Bot pushed a commit that referenced this pull request Sep 21, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #163083 (Remove `G` generic param from `Diag<'_, G>`)
 - #160679 (Staticlib rename internal symbols: add COFF support)
 - #160859 (`core::num::f16b` Rust's 16bit Brain Float)
 - #162007 (Preserve parentheses in raw borrow suggestions)
 - #162821 (Avoid suggesting closures when captures cross associated item boundaries)
 - #163057 (Use span context for enclosing item(s) of unmet bound)
 - #163070 (label the path segment that is not an associated item of the trait)
 - #163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
 - #163107 (Implement Allocator for Pin unstably)
 - #163108 (remove old solver use of `SolverRelating`)
rust-bors Bot pushed a commit that referenced this pull request Sep 21, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #163083 (Remove `G` generic param from `Diag<'_, G>`)
 - #160679 (Staticlib rename internal symbols: add COFF support)
 - #160859 (`core::num::f16b` Rust's 16bit Brain Float)
 - #162007 (Preserve parentheses in raw borrow suggestions)
 - #162821 (Avoid suggesting closures when captures cross associated item boundaries)
 - #163057 (Use span context for enclosing item(s) of unmet bound)
 - #163070 (label the path segment that is not an associated item of the trait)
 - #163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
 - #163107 (Implement Allocator for Pin unstably)
 - #163108 (remove old solver use of `SolverRelating`)
@rust-bors
rust-bors Bot merged commit 2b1343d into rust-lang:main Sep 21, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 21, 2026
Rollup merge of #160679 - cezarbbb:staticlib-rename-coff, r=bjorn3

Staticlib rename internal symbols: add COFF support

Follow-up to #156950.

`-Zstaticlib-rename-internal-symbols` now also works on COFF targets (Windows). Renaming only rewrites symbol names, so unlike hide it needs no visibility concept.

COFF objects keep their string table at the end of the file, so renames append the new names there and patch the 4-byte length prefix plus each symbol's name offset in place. Both regular and bigobj objects are handled; on i686 a leading underscore is stripped when matching against the exported set. The archive format differs (GNU ar on windows-gnu, COFF on windows-msvc) but the members are always COFF objects, so the existing archive code is unchanged.

Supported on ELF, Apple, and COFF targets. `-Zstaticlib-hide-internal-symbols` remains ELF/Apple-only and still warns on Windows.

A run-make test `staticlib-rename-internal-symbols-coff` mirrors the existing ELF and Mach-O tests.

r? @bjorn3
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 21, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#163083 (Remove `G` generic param from `Diag<'_, G>`)
 - rust-lang/rust#160679 (Staticlib rename internal symbols: add COFF support)
 - rust-lang/rust#160859 (`core::num::f16b` Rust's 16bit Brain Float)
 - rust-lang/rust#162007 (Preserve parentheses in raw borrow suggestions)
 - rust-lang/rust#162821 (Avoid suggesting closures when captures cross associated item boundaries)
 - rust-lang/rust#163057 (Use span context for enclosing item(s) of unmet bound)
 - rust-lang/rust#163070 (label the path segment that is not an associated item of the trait)
 - rust-lang/rust#163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
 - rust-lang/rust#163107 (Implement Allocator for Pin unstably)
 - rust-lang/rust#163108 (remove old solver use of `SolverRelating`)
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Sep 22, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#163083 (Remove `G` generic param from `Diag<'_, G>`)
 - rust-lang/rust#160679 (Staticlib rename internal symbols: add COFF support)
 - rust-lang/rust#160859 (`core::num::f16b` Rust's 16bit Brain Float)
 - rust-lang/rust#162007 (Preserve parentheses in raw borrow suggestions)
 - rust-lang/rust#162821 (Avoid suggesting closures when captures cross associated item boundaries)
 - rust-lang/rust#163057 (Use span context for enclosing item(s) of unmet bound)
 - rust-lang/rust#163070 (label the path segment that is not an associated item of the trait)
 - rust-lang/rust#163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
 - rust-lang/rust#163107 (Implement Allocator for Pin unstably)
 - rust-lang/rust#163108 (remove old solver use of `SolverRelating`)
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Sep 22, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#163083 (Remove `G` generic param from `Diag<'_, G>`)
 - rust-lang/rust#160679 (Staticlib rename internal symbols: add COFF support)
 - rust-lang/rust#160859 (`core::num::f16b` Rust's 16bit Brain Float)
 - rust-lang/rust#162007 (Preserve parentheses in raw borrow suggestions)
 - rust-lang/rust#162821 (Avoid suggesting closures when captures cross associated item boundaries)
 - rust-lang/rust#163057 (Use span context for enclosing item(s) of unmet bound)
 - rust-lang/rust#163070 (label the path segment that is not an associated item of the trait)
 - rust-lang/rust#163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
 - rust-lang/rust#163107 (Implement Allocator for Pin unstably)
 - rust-lang/rust#163108 (remove old solver use of `SolverRelating`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 24, 2026
…d,bjorn3

Adjust for Arm64EC name mangling when checking for exported symbols

After rust-lang#160679 the Arm64EC nightly validation run internally by Microsoft started failing with:

```
=== STDOUT ===
main.c
main.obj : error LNK2019: unresolved external symbol my_add referenced in function #my_add$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol my_hash_lookup referenced in function #my_hash_lookup$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol call_internal referenced in function #call_internal$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol my_safe_div referenced in function #my_safe_div$exit_thunk (EC Symbol)
main.exe : fatal error LNK1120: 4 unresolved externals
```

Root cause is that `symbol_edit` wasn't compensating for Arm64EC's name mangling, and so these symbols were missed.
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
Rollup merge of #163188 - dpaoliello:arm64ecsymboledit, r=lqd,bjorn3

Adjust for Arm64EC name mangling when checking for exported symbols

After #160679 the Arm64EC nightly validation run internally by Microsoft started failing with:

```
=== STDOUT ===
main.c
main.obj : error LNK2019: unresolved external symbol my_add referenced in function #my_add$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol my_hash_lookup referenced in function #my_hash_lookup$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol call_internal referenced in function #call_internal$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol my_safe_div referenced in function #my_safe_div$exit_thunk (EC Symbol)
main.exe : fatal error LNK1120: 4 unresolved externals
```

Root cause is that `symbol_edit` wasn't compensating for Arm64EC's name mangling, and so these symbols were missed.
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Sep 25, 2026
Adjust for Arm64EC name mangling when checking for exported symbols

After rust-lang/rust#160679 the Arm64EC nightly validation run internally by Microsoft started failing with:

```
=== STDOUT ===
main.c
main.obj : error LNK2019: unresolved external symbol my_add referenced in function #my_add$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol my_hash_lookup referenced in function #my_hash_lookup$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol call_internal referenced in function #call_internal$exit_thunk (EC Symbol)
main.obj : error LNK2019: unresolved external symbol my_safe_div referenced in function #my_safe_div$exit_thunk (EC Symbol)
main.exe : fatal error LNK1120: 4 unresolved externals
```

Root cause is that `symbol_edit` wasn't compensating for Arm64EC's name mangling, and so these symbols were missed.
makai410 pushed a commit to makai410/rust that referenced this pull request Oct 1, 2026
…nathanBrouwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang#163083 (Remove `G` generic param from `Diag<'_, G>`)
 - rust-lang#160679 (Staticlib rename internal symbols: add COFF support)
 - rust-lang#160859 (`core::num::f16b` Rust's 16bit Brain Float)
 - rust-lang#162007 (Preserve parentheses in raw borrow suggestions)
 - rust-lang#162821 (Avoid suggesting closures when captures cross associated item boundaries)
 - rust-lang#163057 (Use span context for enclosing item(s) of unmet bound)
 - rust-lang#163070 (label the path segment that is not an associated item of the trait)
 - rust-lang#163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
 - rust-lang#163107 (Implement Allocator for Pin unstably)
 - rust-lang#163108 (remove old solver use of `SolverRelating`)
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Oct 1, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#163083 (Remove `G` generic param from `Diag<'_, G>`)
 - rust-lang/rust#160679 (Staticlib rename internal symbols: add COFF support)
 - rust-lang/rust#160859 (`core::num::f16b` Rust's 16bit Brain Float)
 - rust-lang/rust#162007 (Preserve parentheses in raw borrow suggestions)
 - rust-lang/rust#162821 (Avoid suggesting closures when captures cross associated item boundaries)
 - rust-lang/rust#163057 (Use span context for enclosing item(s) of unmet bound)
 - rust-lang/rust#163070 (label the path segment that is not an associated item of the trait)
 - rust-lang/rust#163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
 - rust-lang/rust#163107 (Implement Allocator for Pin unstably)
 - rust-lang/rust#163108 (remove old solver use of `SolverRelating`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

4 participants