Skip to content

Use .drectve for MSVC DLL exports#158294

Open
AsakuraMizu wants to merge 2 commits into
rust-lang:mainfrom
AsakuraMizu:windows-drectve-export
Open

Use .drectve for MSVC DLL exports#158294
AsakuraMizu wants to merge 2 commits into
rust-lang:mainfrom
AsakuraMizu:windows-drectve-export

Conversation

@AsakuraMizu

Copy link
Copy Markdown
Contributor

This is a continuation of #142568.

This fixes the i686 MSVC issue mentioned there: .def files accept undecorated names, but .drectve /EXPORT needs decorated symbol names. The public export name is preserved with EXPORTAS.

It's worth noting that EII with defaults now also works on MSVC.

While it would be reasonable to expect the Windows linker to handle
linker args in the .drectve section identical to cli arguments, as it
turns out exporting weak symbols only works when the /EXPORT is in the
.drectve section, not when it is a linker argument or when a .DEF file
is used.
@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 Jun 23, 2026
@rustbot

rustbot commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

r? @oli-obk

rustbot has assigned @oli-obk.
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: codegen, compiler
  • codegen, compiler expanded to 73 candidates
  • Random selection from 21 candidates

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_codegen_ssa/src/back/link.rs Outdated
Comment thread compiler/rustc_codegen_ssa/src/back/linker.rs
@oli-obk oli-obk 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 Jun 23, 2026
@AsakuraMizu AsakuraMizu force-pushed the windows-drectve-export branch from b0075d5 to 4051560 Compare June 24, 2026 05:22
@AsakuraMizu

Copy link
Copy Markdown
Contributor Author

Updated :)

@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 Jun 24, 2026

@oli-obk oli-obk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 4051560 has been approved by oli-obk

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 Jun 24, 2026
@bjorn3

bjorn3 commented Jun 24, 2026

Copy link
Copy Markdown
Member

Maybe rollup=iffy? Linkage related things tend to be tricky.

@oli-obk

oli-obk commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@bors rollup=iffy reason=windows linker shenanigans

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…, r=oli-obk

Use .drectve for MSVC DLL exports

This is a continuation of rust-lang#142568.

This fixes the i686 MSVC issue mentioned there: `.def` files accept undecorated names, but `.drectve` `/EXPORT` needs decorated symbol names. The public export name is preserved with `EXPORTAS`.

It's worth noting that EII with defaults now also works on MSVC.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…, r=oli-obk

Use .drectve for MSVC DLL exports

This is a continuation of rust-lang#142568.

This fixes the i686 MSVC issue mentioned there: `.def` files accept undecorated names, but `.drectve` `/EXPORT` needs decorated symbol names. The public export name is preserved with `EXPORTAS`.

It's worth noting that EII with defaults now also works on MSVC.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…, r=oli-obk

Use .drectve for MSVC DLL exports

This is a continuation of rust-lang#142568.

This fixes the i686 MSVC issue mentioned there: `.def` files accept undecorated names, but `.drectve` `/EXPORT` needs decorated symbol names. The public export name is preserved with `EXPORTAS`.

It's worth noting that EII with defaults now also works on MSVC.
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158294 (Use .drectve for MSVC DLL exports)
 - #158253 (codegen_ssa: multiply scalable vec size by `vscale`)
 - #158308 (Fix bug when rustdoc "go to only result" setting is not working as expected")
 - #158345 (Use `transmute_neo` in `assume_init`)
 - #158369 (std: abort when `resume_unwind` is called inside the panic hook)
 - #158374 (disallow tail calling extern "rust-call" functions)
 - #158380 (Revert "rebuild LLVM when `bootstrap.toml` config changes")
 - #154398 (Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait)
 - #157181 (autodiff: stop always needing an alloca)
 - #158278 (autodiff - typtree cleanups)
 - #158311 (doc(unstable-book): fix typo "earier" -> "earlier" in default-visibility flag)
 - #158318 (Make normalization in a test case resilient to dist compilation)
 - #158338 (Reorganize `tests/ui/issues` [14/N])
 - #158343 (Include `Item::const_stability` info in rustdoc JSON.)
 - #158355 (Fixup the refactoring errors in #156246)
 - #158390 (Fix: auto trait, const trait bound)

Failed merges:

 - #155535 (export symbols: support macos/windows(32/64))
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #158391 (comment)

@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 25, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 25, 2026
@rust-bors

rust-bors Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#158391), which was unapproved.

View changes since this unapproval

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors rollup=iffy reason=windows linker shenanigans

Thanks a lot btw, this helped in finding the pr :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

6 participants