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

Errors when linking x64 OBJ files into ARM64EC programs #3382

Closed
StephanTLavavej opened this issue Feb 3, 2023 · 2 comments · Fixed by #3732
Closed

Errors when linking x64 OBJ files into ARM64EC programs #3382

StephanTLavavej opened this issue Feb 3, 2023 · 2 comments · Fixed by #3732
Assignees
Labels
ARM64 Related to the ARM64 architecture bug Something isn't working fixed Something works now, yay! high priority Important!

Comments

@StephanTLavavej
Copy link
Member

When linking x64 OBJ files into ARM64EC programs, users are encountering errors like:

error LNK2001: unresolved external symbol __std_reverse_trivially_swappable_8 (EC Symbol)

Related to #2635 and #2740.

It appears that for this scenario, we need to provide separately compiled functions in the import lib (the ARM64 import lib?) that x64 object files could be expecting. These functions can perform plain vanilla swaps/reverses/etc., they don't need to be fancy initially. I am not exactly sure what their mangled names should look like, or what the entire fix will look like as a whole. We should be sure to actually validate the fix end-to-end manually (we now have the ability to create ARM64 VMs for internal testing).

Originally reported as DevCom-10219146 and Microsoft-internal VSO-1707080 / AB#1707080 .

@StephanTLavavej StephanTLavavej added bug Something isn't working high priority Important! ARM64 Related to the ARM64 architecture labels Feb 3, 2023
@CaseyCarter
Copy link
Member

CaseyCarter commented May 20, 2023

We've had yet another customer step on this rake. <mutex>/xonce2.cpp manifest a similar issue:

Rebuild started...
1>------ Rebuild All started: Project: vmwaretestclient, Configuration: Release ARM64EC ------
1>add_person.cc
1>libprotobuf.lib(any.cc.obj) : error LNK2001: unresolved external symbol __imp___std_init_once_begin_initialize (EC Symbol)
1>libprotobuf.lib(map_field.cc.obj) : error LNK2001: unresolved external symbol __imp___std_init_once_begin_initialize (EC Symbol)

the ARM64EC import library needs to provide these symbols.

In the long term, I think we need to do a full audit of the STL to ensure that ARM64EC is everywhere ABI-compatible with the X64 library instead of the ARM64 library.

@CaseyCarter CaseyCarter self-assigned this May 24, 2023
@driver1998
Copy link

driver1998 commented May 25, 2023

I hit something similar when I try to link x64 static boost into an ARM64EC project, see rime/weasel#836. (Or I can somehow build boost as ARM64EC?)

Right now I use an ARM64X redirection DLL and points to separate x64 and ARM64 DLLs.

CaseyCarter added a commit to CaseyCarter/STL that referenced this issue May 25, 2023
* Adds support for building the STL for the ARM64EC platform. (No testing yet, just build.)
* Enable the `__std_init_once_meow` `ALTERNATENAME`s in `src/xonce2.cpp` on ARM64EC. Note that we continue not to use the `<mutex>` `ALTERNATENAME`s when compiling for ARM64EC - the linkage model is complicated - we only include the `ALTERNATENAME`s to support linking with object files built targeting x64. For example, linking x64 static libraries into an ARM64EC binary needs to work.
* Isolate x86/x64-specific code in `src/vector_algorithms.cpp` so we can enable the non-vectorized fallback implementations for ARM64EC. Again, these aren't used when compiling for ARM64EC, but we need the symbols in the import lib to support linking with x64 object files.

Fixes microsoft#3382
@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM64 Related to the ARM64 architecture bug Something isn't working fixed Something works now, yay! high priority Important!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants