Skip to content

[lld-link] linker option error: -arm64xsameaddress:__dyn_tls_dtor is not allowed in .drectve (msvcrt.lib(tlsdtor.obj)) #131712

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

Closed
co-neco opened this issue Mar 18, 2025 · 4 comments · Fixed by #139631
Labels

Comments

@co-neco
Copy link

co-neco commented Mar 18, 2025

Environment:

  • VS 2022 with latest MSVC toolset(v14314.43.34808), and Windows SDK version(10.0.22621.0).
  • Arm64 Windows PC.

I want to build ARM64EC version of V8 engine, but failed with following error:

Studio/2022/Professional/VC/Tools/MSVC/14.43.34808/lib/ARM64" "-libpath:../../../../../../../../Program Files (x86)/Windows Kits/10/lib/10.0.22621.0/ucrt/arm64" "-libpath:../../../../../../../../Program Files (x86)/Windows Kits/10/lib/10.0.22621.0/um/arm64" /MACHINE:ARM64EC "/IMPLIB:./third_party_abseil-cpp_absl.dll.lib" /DLL "/PDB:./third_party_abseil-cpp_absl.dll.pdb" "@./third_party_abseil-cpp_absl.dll.rsp"
lld-link: error: ignoring unknown argument: -arm64xsameaddress:__dyn_tls_dtor
lld-link: error: -arm64xsameaddress:__dyn_tls_dtor is not allowed in .drectve (msvcrt.lib(tlsdtor.obj))

In tlsdtor.cpp, there is a linker option:
#ifdef _M_ARM64EC #pragma comment (linker, "-arm64xsameaddress:__dyn_tls_dtor") #endif
It seems that Microsoft VS added arm64xsameaddress option to support some arm64EC compatibility, but lld-link did not notice the fact.

After that, I tested a minimal program hello.cpp with following content:

#include <iostream>

#pragma comment (linker, "-arm64xsameaddress:__dyn_tls_dtor")

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

If I use MSVC cl.exe and link.exe, it was successful:

cl /c /WX- /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MDd /GS /fp:precise /arm64EC hello.cpp
link /MACHINE:ARM64EC hello.obj
Run hello.exe and the output was 'Hello, World!'.

But If I use clang-cl and lld-link, it complained with following error:

clang-cl.exe /c /WX- /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MDd /GS /fp:precise /arm64EC hello.cpp
lld-link /MACHINE:ARM64EC hello.obj
lld-link: warning: ignoring unknown argument: -arm64xsameaddress:__dyn_tls_dtor
lld-link: error: -arm64xsameaddress:__dyn_tls_dtor is not allowed in .drectve (hello.obj).

Another question:
Here, I used clang-cl from LLVM github latest release version:

clang-cl.exe -v
clang version 20.1.0
Target: aarch64-pc-windows-msvc
Thread model: posix

But If I use clang-cl from VS 2022 installed version, compile any .cpp file would complain as follow:

clang-cl -v
clang version 19.1.1
Target: aarch64-pc-windows-msvc
Thread model: posix

clang-cl.exe /c /WX- /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MDd /GS /fp:precise /arm64EC hello.cpp
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

This might be the same problem as the linker option error.

@llvmbot
Copy link
Member

llvmbot commented Mar 18, 2025

@llvm/issue-subscribers-lld-coff

Author: coneco (co-neco)

Environment: - VS 2022 with latest MSVC toolset(v14314.43.34808), and Windows SDK version(10.0.22621.0). - Arm64 Windows PC.

I want to build ARM64EC version of V8 engine, but failed with following error:

> Studio/2022/Professional/VC/Tools/MSVC/14.43.34808/lib/ARM64" "-libpath:../../../../../../../../Program Files (x86)/Windows Kits/10/lib/10.0.22621.0/ucrt/arm64" "-libpath:../../../../../../../../Program Files (x86)/Windows Kits/10/lib/10.0.22621.0/um/arm64" /MACHINE:ARM64EC "/IMPLIB:./third_party_abseil-cpp_absl.dll.lib" /DLL "/PDB:./third_party_abseil-cpp_absl.dll.pdb" "@./third_party_abseil-cpp_absl.dll.rsp"
lld-link: error: ignoring unknown argument: -arm64xsameaddress:__dyn_tls_dtor
lld-link: error: -arm64xsameaddress:__dyn_tls_dtor is not allowed in .drectve (msvcrt.lib(tlsdtor.obj))

In tlsdtor.cpp, there is a linker option:
#ifdef _M_ARM64EC #pragma comment (linker, "-arm64xsameaddress:__dyn_tls_dtor") #endif
It seems that Microsoft VS added arm64xsameaddress option to support some arm64EC compatibility, but lld-link did not notice the fact.

After that, I tested a minimal program hello.cpp with following content:

#include &lt;iostream&gt;

#pragma comment (linker, "-arm64xsameaddress:__dyn_tls_dtor")

int main() {
    std::cout &lt;&lt; "Hello, World!" &lt;&lt; std::endl;
    return 0;
}

If I use MSVC cl.exe and link.exe, it was successful:
> cl /c /WX- /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MDd /GS /fp:precise /arm64EC hello.cpp
link /MACHINE:ARM64EC hello.obj
Run hello.exe and the output was 'Hello, World!'.

But If I use clang-cl and lld-link, it complained with following error:
> clang-cl.exe /c /WX- /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MDd /GS /fp:precise /arm64EC hello.cpp
lld-link /MACHINE:ARM64EC hello.obj
lld-link: warning: ignoring unknown argument: -arm64xsameaddress:__dyn_tls_dtor
lld-link: error: -arm64xsameaddress:__dyn_tls_dtor is not allowed in .drectve (hello.obj).

Another question:
Here, I used clang-cl from LLVM github latest release version:
> clang-cl.exe -v
clang version 20.1.0
Target: aarch64-pc-windows-msvc
Thread model: posix

But If I use clang-cl from VS 2022 installed version, compile any .cpp file would complain as follow:
> clang-cl -v
clang version 19.1.1
Target: aarch64-pc-windows-msvc
Thread model: posix

> clang-cl.exe /c /WX- /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MDd /GS /fp:precise /arm64EC hello.cpp
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
error: no_builtin attribute has no effect on defaulted or deleted functions
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

This might be the same problem as the linker option error.

@mstorsjo
Copy link
Member

Environment:

  • VS 2022 with latest MSVC toolset(v14314.43.34808), and Windows SDK version(10.0.22621.0).
  • Arm64 Windows PC.

I want to build ARM64EC version of V8 engine, but failed with following error:

Studio/2022/Professional/VC/Tools/MSVC/14.43.34808/lib/ARM64" "-libpath:../../../../../../../../Program Files (x86)/Windows Kits/10/lib/10.0.22621.0/ucrt/arm64" "-libpath:../../../../../../../../Program Files (x86)/Windows Kits/10/lib/10.0.22621.0/um/arm64" /MACHINE:ARM64EC "/IMPLIB:./third_party_abseil-cpp_absl.dll.lib" /DLL "/PDB:./third_party_abseil-cpp_absl.dll.pdb" "@./third_party_abseil-cpp_absl.dll.rsp"
lld-link: error: ignoring unknown argument: -arm64xsameaddress:__dyn_tls_dtor
lld-link: error: -arm64xsameaddress:__dyn_tls_dtor is not allowed in .drectve (msvcrt.lib(tlsdtor.obj))

In tlsdtor.cpp, there is a linker option: #ifdef _M_ARM64EC #pragma comment (linker, "-arm64xsameaddress:__dyn_tls_dtor") #endif It seems that Microsoft VS added arm64xsameaddress option to support some arm64EC compatibility, but lld-link did not notice the fact.

After that, I tested a minimal program hello.cpp with following content:

#include <iostream>

#pragma comment (linker, "-arm64xsameaddress:__dyn_tls_dtor")

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

If I use MSVC cl.exe and link.exe, it was successful:

cl /c /WX- /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MDd /GS /fp:precise /arm64EC hello.cpp
link /MACHINE:ARM64EC hello.obj
Run hello.exe and the output was 'Hello, World!'.

But If I use clang-cl and lld-link, it complained with following error:

clang-cl.exe /c /WX- /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MDd /GS /fp:precise /arm64EC hello.cpp
lld-link /MACHINE:ARM64EC hello.obj
lld-link: warning: ignoring unknown argument: -arm64xsameaddress:__dyn_tls_dtor
lld-link: error: -arm64xsameaddress:__dyn_tls_dtor is not allowed in .drectve (hello.obj).

CC @cjacek - we'd need to implement this option.

Another question: Here, I used clang-cl from LLVM github latest release version:

clang-cl.exe -v
clang version 20.1.0
Target: aarch64-pc-windows-msvc
Thread model: posix

But If I use clang-cl from VS 2022 installed version, compile any .cpp file would complain as follow:

clang-cl -v
clang version 19.1.1
Target: aarch64-pc-windows-msvc
Thread model: posix

This might be the same problem as the linker option error.

No, this is simply the fact that LLD 19 didn't support much about arm64ec/arm64x at all. The 20 release is much more complete, but apparently there's still some directives that need to be handled.

@co-neco
Copy link
Author

co-neco commented Mar 18, 2025

Thanks for your reply. Hope the support will come soon.

@co-neco co-neco closed this as completed Mar 18, 2025
@cjacek
Copy link
Contributor

cjacek commented Mar 18, 2025

Here’s an initial implementation: cjacek@6b4298e. It should fix the error and is likely good enough for the most part.

However, it's not yet complete. On pure ARM64EC (not ARM64X), it seems the native symbol should be pulled in too, even though it isn’t used (the EC symbol is used instead). lld-link doesn’t support this yet, so that needs to be addressed first.

@cjacek cjacek reopened this Mar 18, 2025
cjacek added a commit to cjacek/llvm-project that referenced this issue May 12, 2025
Make it a no-op for now, which is sufficient for non-hybrid images.

Fixes llvm#131712.
@cjacek cjacek closed this as completed in d5da557 May 15, 2025
swift-ci pushed a commit to swiftlang/llvm-project that referenced this issue May 16, 2025
Make it a no-op for now, which is sufficient for non-hybrid images.

Fixes llvm#131712.

(cherry picked from commit d5da557)
TIFitis pushed a commit to TIFitis/llvm-project that referenced this issue May 19, 2025
Make it a no-op for now, which is sufficient for non-hybrid images.

Fixes llvm#131712.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants