Skip to content

Commit

Permalink
Unix arm64 atomics (#71512)
Browse files Browse the repository at this point in the history
* Define_InterlockMethod macro

* compiler failure

* fix build errors

* Set g_arm64_atomics_present at common place

* Fix the missing declaration

* Change TARGET_ARM64 => HOST_ARM64

* Use LSE for InterlockedCompareExchange

* Attempt to fix osx-arm64 build issue

* Introduce LSE_INSTRUCTIONS_ENABLED_BY_DEFAULT

* Make sure that compiler knows that M1 has lse
  • Loading branch information
kunalspathak authored Jul 7, 2022
1 parent e633272 commit 10286e9
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 195 deletions.
5 changes: 5 additions & 0 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ if (CLR_CMAKE_HOST_UNIX)
if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST)
# We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)
add_compile_options(-fstack-protector)
if(CLR_CMAKE_HOST_UNIX_ARM64)
# For OSX-Arm64, LSE instructions are enabled by default
add_definitions(-DLSE_INSTRUCTIONS_ENABLED_BY_DEFAULT)
add_compile_options(-mcpu=apple-m1)
endif(CLR_CMAKE_HOST_UNIX_ARM64)
elseif(NOT CLR_CMAKE_HOST_BROWSER)
check_c_compiler_flag(-fstack-protector-strong COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG)
if (COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG)
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/debug/createdump/datatarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

#include "createdump.h"

#if defined(HOST_ARM64)
// Flag to check if atomics feature is available on
// the machine
bool g_arm64_atomics_present = false;
#endif

DumpDataTarget::DumpDataTarget(CrashInfo& crashInfo) :
m_ref(1),
m_crashInfo(crashInfo)
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/dlls/mscordbi/mscordbi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ extern BOOL WINAPI DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
//*****************************************************************************
extern "C"
#ifdef TARGET_UNIX

#if defined(HOST_ARM64)
// Flag to check if atomics feature is available on
// the machine
bool g_arm64_atomics_present = false;
#endif

DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Expand Down
Loading

0 comments on commit 10286e9

Please sign in to comment.