[PATCH] D91784: [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

Kristof Provost via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 19 04:37:48 PST 2020


kprovost created this revision.
kprovost added reviewers: kito-cheng, khchen, s.egerton, emaste.
Herald added subscribers: cfe-commits, frasercrmck, NickHung, evandro, luismarques, apazos, sameer.abuasal, pzheng, lenary, Jim, benna, psnobl, jocewei, PkmX, jfb, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: clang.
kprovost requested review of this revision.
Herald added a subscriber: MaskRay.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91784

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


Index: clang/lib/Basic/Targets/RISCV.cpp
===================================================================
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -115,8 +115,14 @@
     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");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91784.306371.patch
Type: text/x-patch
Size: 697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201119/1e0e1a57/attachment.bin>


More information about the cfe-commits mailing list