[llvm] [Support] Add missing LLVM_ABI annotations in Atomic.h (PR #152768)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 10:30:05 PDT 2025


https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/152768

This fixes building LLD for mingw targets with
LLVM_BUILD_LLVM_DYLIB_VIS=ON. This has been missed for other platforms, as those platforms have LLVM_THREADING_USE_STD_CALL_ONCE=1 in llvm/Support/Threading.h, while it ends up set to 0, using CompareAndSwap() and MemoryFence() instead, for mingw targets.

>From 58a6949774b6ecbc3d7a698e82e9f708d1e1e972 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Fri, 8 Aug 2025 20:25:56 +0300
Subject: [PATCH] [Support] Add missing LLVM_ABI annotations in Atomic.h

This fixes building LLD for mingw targets, with
LLVM_BUILD_LLVM_DYLIB_VIS=ON. This has been missed for other
platforms, as those platforms have LLVM_THREADING_USE_STD_CALL_ONCE=1
in llvm/Support/Threading.h, while it ends up set to 0, using
CompareAndSwap() and MemoryFence() instead, for mingw targets.
---
 llvm/include/llvm/Support/Atomic.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/llvm/include/llvm/Support/Atomic.h b/llvm/include/llvm/Support/Atomic.h
index a8445fddc1a85..4dcef19359ce5 100644
--- a/llvm/include/llvm/Support/Atomic.h
+++ b/llvm/include/llvm/Support/Atomic.h
@@ -17,6 +17,7 @@
 #ifndef LLVM_SUPPORT_ATOMIC_H
 #define LLVM_SUPPORT_ATOMIC_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/DataTypes.h"
 
 // Windows will at times define MemoryFence.
@@ -26,16 +27,16 @@
 
 namespace llvm {
   namespace sys {
-    void MemoryFence();
+    LLVM_ABI void MemoryFence();
 
 #ifdef _MSC_VER
     typedef long cas_flag;
 #else
     typedef uint32_t cas_flag;
 #endif
-    cas_flag CompareAndSwap(volatile cas_flag* ptr,
-                            cas_flag new_value,
-                            cas_flag old_value);
+    LLVM_ABI cas_flag CompareAndSwap(volatile cas_flag* ptr,
+                                     cas_flag new_value,
+                                     cas_flag old_value);
   }
 }
 



More information about the llvm-commits mailing list