Skip to content

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

Open
@co-neco

Description

@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 <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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions