Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upUnable to export unmangled dll entry points for stdcall #17806
Comments
kmcallister
added
O-windows
A-linkage
C-enhancement
labels
Oct 6, 2014
This comment has been minimized.
This comment has been minimized.
|
All dllexport'ed functions are usually "mangled" in that way. It's not rust-specific; gcc does same and I think msvc link.exe does too. |
This comment has been minimized.
This comment has been minimized.
|
This is a LLVM issue - it mangles stdcall symbols so that the
|
This comment has been minimized.
This comment has been minimized.
|
An updated command line,
I am not an expert on stdcall, but it would seem that the EDIT: Also, I did do this on Linux, as I assumed that the ABI is the important part here, not Windows specifically. That could be a wrong assumption, I am terrible at Windows stuff :( |
This comment has been minimized.
This comment has been minimized.
bbigras
commented
Mar 18, 2016
The |
This comment has been minimized.
This comment has been minimized.
|
What would be cool is if, for the |
This comment has been minimized.
This comment has been minimized.
bozaro
commented
Sep 22, 2016
•
|
I have inverse problem: I try to set exported name with "@" symbol. So, with gnu toolchain I create fork like:
And it works correctly. This code also works with msvc amd64 toolchain. But on msvc x86 toolchain I can't find way to get exported name like "_AbortCompilerPass@4". I try to use:
But MS linker ignored all @4 in all variants :( |
This comment has been minimized.
This comment has been minimized.
bozaro
commented
Sep 22, 2016
|
I created simple example with my issue: https://github.com/bozaro/rust-msvcdll
For toolchains:
I try to implement wrapper for Visual Studio compiler plugin: Also looks like removing
|
This comment has been minimized.
This comment has been minimized.
bozaro
commented
Sep 22, 2016
•
|
Also in ideal world I want one of two options:
At this moment:
|
This comment has been minimized.
This comment has been minimized.
|
@bozaro I think the #[export_name = "\x01AbortCompilerPass"]The leading "1 byte" tells LLVM to disable all name mangling. |
This comment has been minimized.
This comment has been minimized.
slonopotamus
commented
Sep 26, 2016
•
|
@alexcrichton: @bozaro problem is the opposite. Currently (rust 1.11) |
This comment has been minimized.
This comment has been minimized.
|
Here's an update on what the current situation is for the example in the original post using
This is what is exported from the DLL itself: Now in @bozaro 's case, |
This comment has been minimized.
This comment has been minimized.
|
Oh! Sorry I misinterpreted this issue totally. This is probably because we don't use |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton If we want to do this properly, we'll need to distinguish between the name exported from the import library and the name exported from the DLL itself, and unfortunately |
This comment has been minimized.
This comment has been minimized.
|
Triage: no changes I'm aware of |
This comment has been minimized.
This comment has been minimized.
devsnek
commented
Jun 19, 2018
|
was this ever fixed? |
This comment has been minimized.
This comment has been minimized.
RosieCode95
commented
Jun 19, 2018
|
^ having this issue and cant find a working workaround, tried everything from renaming to using \x01 |
This comment has been minimized.
This comment has been minimized.
norru
commented
Oct 2, 2018
|
Just got bitten by this. |

darklajid commentedOct 5, 2014
Hi.
After some questions on IRC I think this might be a bug or at least a missing feature:
I'd like to export functions with a name of my choosing. I knew about #[no_mangle] and learned about #[export_name] on IRC, but both fail to work in my case.
Code/test.rs:
Build with
rustc --cratetype dylib test.rsResult:

So, every single stdcall entry point follows the name@sizeofarguments convention. I have a number of DLLs right in front of me (not based on rust) that export stdcall entries and DON'T use that convention. In fact, I'm reasonably sure that most of the windows API is both using stdcall and exporting 'unmangled' names.
Can I create something similar with rust? Am I missing another attribute? Should no_mangle work in these cases? Should export_name?