From 6813f2420b236f852d18f1a582c77d17ed15d45f Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 9 Dec 2020 18:37:43 +0000 Subject: [PATCH] =?UTF-8?q?Merge=20commit=2028de0fb48=20from=20llvm=20git?= =?UTF-8?q?=20(by=20Lu=C3=ADs=20Marques):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [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 This should fix building glib20 on RISC-V and unblock a number of dependent ports. Requested by: kp MFC after: 3 days --- contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp index 4ba703c8dd1a..6154c0f99002 100644 --- a/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp +++ b/contrib/llvm-project/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");