Skip to content

<atomic>: atomic waits do not link in ARM64 #1504

Description

Describe the bug
When building a program using atomic waits (directly or indirectly through std::counting_semaphore) for ARM64, linking will fail.

Command-line test case

C:\Temp>vsdevcmd -arch=arm64 -host_arch=amd64

C:\Temp>type repro.cpp
#include <atomic>

int main()
{
	std::atomic<int> test(1);
	test.wait(1);
	test.notify_all();
	test.notify_one();
	return test.load();
}

C:\Temp>cl /MDd /std:c++latest repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29515.1 for ARM64
Copyright (C) Microsoft Corporation.  All rights reserved.

/std:c++latest is provided as a preview of language features from the latest C++
working draft, and we're eager to hear about bugs and suggestions for improvements.
However, note that these features are provided as-is without support, and subject
to changes or removal as the working draft evolves. See
https://go.microsoft.com/fwlink/?linkid=2045807 for details.

repro.cpp
Microsoft (R) Incremental Linker Version 14.28.29515.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:repro.exe
repro.obj
repro.obj : error LNK2019: unresolved external symbol __std_atomic_wait_direct referenced in function "void __cdecl std::_Atomic_wait_direct<int,long>(struct std::_Atomic_storage<int,4> const * const,long,enum std::memory_order)" (??$_Atomic_wait_direct@HJ@std@@YAXQEBU?$_Atomic_storage@H$03@0@JW4memory_order@0@@Z)
repro.obj : error LNK2019: unresolved external symbol __std_atomic_notify_one_direct referenced in function "public: void __cdecl std::_Atomic_storage<int,4>::notify_one(void)" (?notify_one@?$_Atomic_storage@H$03@std@@QEAAXXZ)
repro.obj : error LNK2019: unresolved external symbol __std_atomic_notify_all_direct referenced in function "public: void __cdecl std::_Atomic_storage<int,4>::notify_all(void)" (?notify_all@?$_Atomic_storage@H$03@std@@QEAAXXZ)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29515\lib\ARM64\msvcprtd.lib : warning LNK4272: library machine type 'ARM64EC' conflicts with target machine type 'ARM64'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29515\lib\ARM64\OLDNAMES.lib : warning LNK4272: library machine type 'ARM64EC' conflicts with target machine type 'ARM64'
repro.exe : fatal error LNK1120: 3 unresolved externals

C:\Temp>cl /std:c++latest repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29515.1 for ARM64
Copyright (C) Microsoft Corporation.  All rights reserved.

/std:c++latest is provided as a preview of language features from the latest C++
working draft, and we're eager to hear about bugs and suggestions for improvements.
However, note that these features are provided as-is without support, and subject
to changes or removal as the working draft evolves. See
https://go.microsoft.com/fwlink/?linkid=2045807 for details.

repro.cpp
Microsoft (R) Incremental Linker Version 14.28.29515.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:repro.exe
repro.obj
libcpmt.lib(atomic_wait.obj) : error LNK2019: unresolved external symbol WaitOnAddress referenced in function __std_atomic_wait_direct
libcpmt.lib(atomic_wait.obj) : error LNK2019: unresolved external symbol WakeByAddressSingle referenced in function __std_atomic_notify_one_direct
libcpmt.lib(atomic_wait.obj) : error LNK2019: unresolved external symbol WakeByAddressAll referenced in function __std_atomic_notify_all_direct
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29515\lib\ARM64\OLDNAMES.lib : warning LNK4272: library machine type 'ARM64EC' conflicts with target machine type 'ARM64'
repro.exe : fatal error LNK1120: 3 unresolved externals

Expected behavior
I expected this program to build in both command line cases in the repro.

STL version

Microsoft Visual Studio Community 2019 Preview
Version 16.9.0 Preview 1.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ARM64Related to the ARM64 architecturebugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions