Issue |
143575
|
Summary |
MSVC Linker Issue When Targeting ARM64EC
|
Labels |
new issue
|
Assignees |
|
Reporter |
JiachenYuan
|
Hi! A [recent commit](https://github.com/llvm/llvm-project/pull/125320) has caused a linker issue when cross-compiling the LLVM project targeting ARM64EC on a AMD64 host Windows machine. The reduced steps to reproduce the linker error is listed below.
### Prerequisite
MSVC
- Visual Studio Community 2022 17.14.4
Individual MSVC components:
- MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)
- C++ ATL for latest v143 build tools (ARM64/ARM64EC)
- C++ ATL for latest v143 build tools (x86 & x64)
### Build for arm64ec
1. Open a x64 Native Tools Command Prompt for VS 2022
2. The linker error can be reproduced by
```
git clone https://github.com/llvm/llvm-project.git
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A ARM64EC -DLLVM_ENABLE_PROJECTS="llvm" -DLLVM_TARGETS_TO_BUILD="AArch64" -DLLVM_OPTIMIZED_TABLEGEN=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="/wd4146 /wd4244 /wd4267 /wd4996 /wd4800 /D_HAS_EXCEPTIONS=0" -DCMAKE_EXE_LINKER_FLAGS="softintrin.lib arm64rt.lib" -DCMAKE_SHARED_LINKER_FLAGS="softintrin.lib arm64rt.lib" -DCMAKE_MODULE_LINKER_FLAGS="softintrin.lib arm64rt.lib" -DLLVM_DISABLE_ASSEMBLY_FILES=ON ..\llvm-project\llvm
msbuild LLVM.sln /m /p:Platform=ARM64EC /p:Configuration=Release
```
(The `-DLLVM_DISABLE_ASSEMBLY_FILES` flag is suggested in https://github.com/llvm/llvm-project/issues/100335 to ignore problem: `LNK1372: hybrid map entry target function 'llvm_blake3_compress_in_place_sse41' is not 4-byte aligned`)
### Linker Error Message
```
LINK : error LNK2001: unresolved external symbol "??_C@_0L@OHILDFJG@" (??_C@_0L@OHILDFJG@) (EC Symbol)
```
### Triage
Dumping the symbol tables of the generated object files shows that the unresolved symbol is probably related to the `HybridPatchableTargetSuffix` global variable in `AsmPrinter.cpp` introduced by the aforementioned commit. Directly substituting the literal strings to its uses does not solve the problem. A dirty workaround that works for me is to divide up the string at its definition and re-concatenate the parts at the original uses.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs