From 1378f6b5439a1355835b406c6307437cb518e4e7 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 21 Jun 2025 13:35:03 +0300 Subject: [PATCH] [CMAKE] Fix ARM64 build Since VS 17.14.36203.30 / MSVC 19.44.35209.0 the default behavior on ARM64 is to not inline _Interlocked* functions. Until we have those implemented, we disable this feature, going back to the old behavior. For additional details / tracking of the implementation see CORE-20255 --- sdk/cmake/msvc.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/cmake/msvc.cmake b/sdk/cmake/msvc.cmake index c621fce0a77..b1fe4f74dc3 100644 --- a/sdk/cmake/msvc.cmake +++ b/sdk/cmake/msvc.cmake @@ -78,6 +78,14 @@ if(ARCH STREQUAL "amd64" AND MSVC_VERSION GREATER 1922) add_link_options(/d2:-FH4-) endif() +# Workaround: Newer ARM64 builds do not inline interlocked functions by default. +# A better fix would be to implement the interlocked functions in assembly. +# See https://devblogs.microsoft.com/cppblog/introducing-the-forceinterlockedfunctions-switch-for-arm64/ +if(ARCH STREQUAL "arm64" AND MSVC_VERSION GREATER_EQUAL 1944) + message(STATUS "Forcing interlocked functions to be inlined for ARM64 builds") + add_compile_options("/forceInterlockedFunctions-") +endif() + # Generate Warnings Level 3 add_compile_options(/W3)