[clang] 28de0fb - [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

Luís Marques via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 24 14:51:04 PST 2020


Author: Luís Marques
Date: 2020-11-24T22:50:28Z
New Revision: 28de0fb4863a3cfef06c26260219089123a80c2f

URL: https://github.com/llvm/llvm-project/commit/28de0fb4863a3cfef06c26260219089123a80c2f
DIFF: https://github.com/llvm/llvm-project/commit/28de0fb4863a3cfef06c26260219089123a80c2f.diff

LOG: [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

The RISCV target did not set the GCC atomic compare and swap defines,
unlike other targets. This broke builds for things like glib on RISCV.

Patch by Kristof Provost (kprovost)

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

Added: 
    

Modified: 
    clang/lib/Basic/Targets/RISCV.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index 5e17b7d51175..37e688d14b4a 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -115,8 +115,14 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
     Builder.defineMacro("__riscv_muldiv");
   }
 
-  if (HasA)
+  if (HasA) {
     Builder.defineMacro("__riscv_atomic");
+    Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+    Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+    Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+    if (Is64Bit)
+      Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+  }
 
   if (HasF || HasD) {
     Builder.defineMacro("__riscv_flen", HasD ? "64" : "32");


        


More information about the cfe-commits mailing list