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

clang i686-w64-windows-gnu weak reference mangling #237

Closed
jeremyd2019 opened this issue Aug 26, 2021 · 1 comment · Fixed by #238 or #242
Closed

clang i686-w64-windows-gnu weak reference mangling #237

jeremyd2019 opened this issue Aug 26, 2021 · 1 comment · Fixed by #238 or #242

Comments

@jeremyd2019
Copy link
Contributor

Sorry, this is probably pretty esoteric...

I am attempting to build for i686-w64-windows-gnu, and it is failing to link. After some investigation I found the cause. Clang is hitting this case:

#elif defined(__clang__) /* CLANG */
#ifdef __STDC__
#define openlibm_weak_reference(sym,alias) \
__asm__(".weak_reference " #alias); \
__asm__(".set " #alias ", " #sym)
#else

But, on x86 32-bit Windows, symbols for C functions are prefixed by _. Changing that so that sym and alias are prefixed by _ solves the linking there. That doesn't seems like it would work everywhere though.

In contrast, I think GCC would hit the case:

#define openlibm_weak_reference(sym,alias) \
__asm__(".stabs \"_" #alias "\",11,0,0,0"); \
__asm__(".stabs \"_" #sym "\",1,0,0,0")

Which always includes _ prefixes,,,

See also https://github.com/mingw-w64/mingw-w64/blob/6b62cf66832bd158c67662cd5566413baf35f20e/mingw-w64-headers/crt/_mingw_mac.h#L130 and the lines immediately before that figure out whether the _ is required or not

@ViralBShah
Copy link
Member

Could you provide a PR here?

ViralBShah pushed a commit that referenced this issue Sep 9, 2021
In a case that I believe can only be hit for Clang i686-*-windows-gnu (AKA MinGW), symbols in asm need to be prefixed with `_`.  Fixes #237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants