-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Test mangled named on Windows too #283
Conversation
I have some tests for no_mangle names ( |
I guess it's just |
As far as I understand it, the preceding underscore is C-level name mangling and is used for cdecl symbols. I tried this:
The resulting symbols:
So I think it's correct to strip an underscore (?) |
Oh for completeness:
|
In that case I don't understand what's going on... In |
I found this discussion of the leading underscore: https://stackoverflow.com/questions/27487756/calling-convention-name-mangling-in-c That response says:
However, I repeated the above test with |
Can you check the output on |
Hmm. Maybe some difference between the toolchain I'm using and the one used by your builder? |
From filenames - you are doing some sort of cross compilation from Mac to Windows. Runner is native Windows. |
Yes, this is cross compilation. From the perspective of rustc I imagine it has to be the same codepath to generate windows code regardless of the platform you're starting from, shouldn't it? |
Aha, it's 32-bit vs 64-bit... for reasons I am wholly unclear on.
|
So we want stripping on 64-bit, but not on 32-bit. At least on Windows. 🤔 |
A final doc reference that confirms this:
|
I guess you have the cargo machinery in place to identify the target platform. For Windows aside from CPU arch there is also I think the number of people who are targeting 32-bit Windows is vanishingly small, so I might suggest just picking the behavior that works well for 64-bit Windows (that is, not stripping underscores) and leaving the rest for someone to worry about another time, because it's probably not worth your time! |
So just to double check - is what I have in this branch working for you (possibly with incorrect underscore prefixed)? |
// Search for .globl between sec_start and ix | ||
for line in &lines[sec_start..ix] { | ||
if let Statement::Directive(Directive::Generic(GenericDirective(g))) = line { | ||
if let Some(item) = get_item_in_section("globl\t", ix, label, g, true) { | ||
if let Some(item) = get_item_in_section("globl\t", ix, label, g, is_mac) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment here like "64-bit Windows does not add underscores; TODO: on 32-bit Windows we ought to remove underscores" just so the next person doesn't need to rediscover this
Yes! Current branch behavior: 32-bit:
64-bit:
|
Also just to double check, this branch on the crate I started this all from:
The extra underscores are fine, no worries. |
Okay. I'll try to release today/tomorrow and will make a ticket for 32bit windows for future me when I next time feel bored. And I think I can close #137. |
We need to strip underscore on 32bit Windows and MacOS and leave it as is on Linux and 64bit Windows.
Fixes #137