Skip to content

Use .drectve for MSVC DLL exports#158294

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

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

Conversation

@AsakuraMizu

@AsakuraMizu AsakuraMizu commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

View all comments

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.

@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 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels 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

@rust-bors

This comment has been minimized.

bjorn3 and others added 3 commits June 29, 2026 11:34
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.
@AsakuraMizu AsakuraMizu force-pushed the windows-drectve-export branch from 4051560 to c84bcbe Compare June 29, 2026 06:19
@rustbot

rustbot commented Jun 29, 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.

@AsakuraMizu

Copy link
Copy Markdown
Contributor Author

I've resolved the merge conflict and updated the test file. I did a simple verification on my local Windows machine, but I'm not sure if it will pass the CI completely.

@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 29, 2026
@oli-obk

oli-obk commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@bors try x86_64-msvc-1

@rust-bors

rust-bors Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Unknown argument "x86_64-msvc-1". Did you mean to use @bors jobs=<jobs>|parent=<parent>? Run @bors help or go to https://bors.rust-lang.org/help to see available commands.

@oli-obk

oli-obk commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@bors try jobs=x86_64-msvc-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 29, 2026
Use .drectve for MSVC DLL exports


try-job: x86_64-msvc-1
@rust-bors

rust-bors Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: fbb1950 (fbb195002ee8f5118ac156c1b0e56dd4b38aa343)
Base parent: 63f05e3 (63f05e3635171e7ac3f9ca78bad6c71052cda5a3)

@oli-obk

oli-obk commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c84bcbe 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 29, 2026
@rust-bors

rust-bors Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

⌛ Testing commit c84bcbe with merge 2523831...

Workflow: https://github.com/rust-lang/rust/actions/runs/28381305045

rust-bors Bot pushed a commit that referenced this pull request Jun 29, 2026
Use .drectve for MSVC DLL exports



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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

6 participants