Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use decorated names for linked_symbols on Windows #96444

Merged
merged 1 commit into from
Apr 29, 2022

Conversation

nbdd0121
Copy link
Contributor

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 26, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 26, 2022

let x86 = match &target.arch[..] {
"x86" => true,
"x86_64" => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this case also always results in undecorated names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

x86_64 code can still use "vectorcall" convention

Copy link
Contributor

Choose a reason for hiding this comment

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

The linked MS doc says "Note that in a 64-bit environment, functions are not decorated.", apparently it applies to vectorcall too?
Raw-dylib didn't attempt to support vector call yet, so I don't know what is the correct behavior there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's an inaccurate statement, it should rather say that functions are not decorated by default. Vector call is still a separate calling convention on x64 however, and is still decorated (https://docs.microsoft.com/en-us/cpp/cpp/vectorcall?view=msvc-170, https://godbolt.org/z/asdbdzePz)

Copy link
Contributor

Choose a reason for hiding this comment

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

Vector call is still a separate calling convention on x64

Yeah, I was aware of that, but wasn't sure about the decoration.
Just checked it with Visual Studio's C compiler, and looks like it's indeed the only calling convention that is decorated on x64.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ha, I didn't even know this stuff is in open source now.

.iter()
.map(|abi| abi.layout.size.bytes().next_multiple_of(target.pointer_width as u64 / 8))
.sum();
format!("{prefix}{undecorated}{suffix}{args_in_bytes}")
Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen this logic elsewhere, it's split into fn i686_decorated_name and fn i686_arg_list_size as a part of implementation of the raw-dylib feature.

Could you make sure these two implementations do the same thing?
fn i686_decorated_name, for example, adds or not adds underscore depending on the mingw flag.
(Ideally the code would be shared, but not necessarily in this PR.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just checked that the current behaviour in i686_decorated_name to not add _ in MinGW is due to the fact that it uses dlltool to create a library, and i686 dlltool will automatically add _ to symbols if it does not start with @. For the generated object files we need to add _ ourselves.

There are no other behavioural differences.

@petrochenkov petrochenkov 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 Apr 27, 2022
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 27, 2022

📌 Commit 4f9acb2 has been approved by petrochenkov

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 27, 2022
@bors
Copy link
Contributor

bors commented Apr 29, 2022

⌛ Testing commit 4f9acb2 with merge 5560c51...

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 29, 2022
Add `@feat.00` symbol to symbols.o for COFF

Fix rust-lang#96498

This is based on top of rust-lang#96444.

r? `@petrochenkov`
@bors
Copy link
Contributor

bors commented Apr 29, 2022

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 5560c51 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 29, 2022
@bors bors merged commit 5560c51 into rust-lang:master Apr 29, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 29, 2022
@bors bors mentioned this pull request Apr 29, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 29, 2022
Add `@feat.00` symbol to symbols.o for COFF

Fix rust-lang#96498

This is based on top of rust-lang#96444.

r? ``@petrochenkov``
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5560c51): comparison url.

Summary:

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regression found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 1 0 0 0
mean2 N/A 0.3% N/A N/A N/A
max N/A 0.3% N/A N/A N/A

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

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. 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.

unresolved external symbol _DllMain
6 participants