[OpenMP][mingw] Fix build for aarch64 target
authorAlvin Wong <alvin@alvinhc.com>
Fri, 4 Nov 2022 22:22:50 +0000 (00:22 +0200)
committerMartin Storsjö <martin@martin.st>
Tue, 8 Nov 2022 13:27:03 +0000 (15:27 +0200)
This patch changes AArch64 + `__GNUC__` to use `__sync` builtins to
implement internal atomic macros just like for Unix, because mingw-w64
is missing some of the intrinsics which the MSVC codepath is using.

Then some remaining intel-only functions are removed from dllexport to
fix linking.

This should fix https://github.com/llvm/llvm-project/issues/56349.

Reviewed By: natgla

Differential Revision: https://reviews.llvm.org/D137168

openmp/runtime/src/dllexports
openmp/runtime/src/kmp_os.h
openmp/runtime/src/kmp_utility.cpp

index 2fd1d90..a541f58 100644 (file)
@@ -1243,7 +1243,6 @@ kmp_set_disp_num_buffers                    890
     %ifdef IS_IA_ARCH
     __kmpc_atomic_float10_max              2139
     __kmpc_atomic_float10_min              2140
-    %endif
     __kmpc_atomic_float10_max_cpt          2141
     __kmpc_atomic_float10_min_cpt          2142
 
@@ -1263,6 +1262,7 @@ kmp_set_disp_num_buffers                    890
     __kmpc_atomic_val_2_cas_cpt            2156
     __kmpc_atomic_val_4_cas_cpt            2157
     __kmpc_atomic_val_8_cas_cpt            2158
+    %endif
 
 %endif
 
index 458609c..1a802ce 100644 (file)
@@ -456,7 +456,7 @@ enum kmp_mem_fence_type {
 
 // Synchronization primitives
 
-#if KMP_ASM_INTRINS && KMP_OS_WINDOWS
+#if KMP_ASM_INTRINS && KMP_OS_WINDOWS && !(KMP_ARCH_AARCH64 && defined(__GNUC__))
 
 #if KMP_MSVC_COMPAT && !KMP_COMPILER_CLANG
 #pragma intrinsic(InterlockedExchangeAdd)
index 48d31e5..53ff178 100644 (file)
@@ -370,7 +370,7 @@ void __kmp_expand_file_name(char *result, size_t rlen, char *pattern) {
         case 'I':
         case 'i': {
           pid_t id = getpid();
-#if KMP_ARCH_X86_64 && defined(__MINGW32__)
+#if (KMP_ARCH_X86_64 || KMP_ARCH_AARCH64) && defined(__MINGW32__)
           snp_result = KMP_SNPRINTF(pos, end - pos + 1, "%0*lld", width, id);
 #else
           snp_result = KMP_SNPRINTF(pos, end - pos + 1, "%0*d", width, id);