git: 41ce229505a3 - stable/13 - Apply compiler-rt fix for building with earlier versions of clang

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 04 Jun 2022 12:01:28 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=41ce229505a34e60c869dd540187d31611916df2

commit 41ce229505a34e60c869dd540187d31611916df2
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-06-01 18:29:15 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-06-04 12:00:27 +0000

    Apply compiler-rt fix for building with earlier versions of clang
    
    Merge commit 18efa420da5f from llvm git (by Brooks Davis)
    
      compiler-rt: Allow build without __c11_atomic_fetch_nand
    
      Don't build atomic fetch nand libcall functions when the required
      compiler builtin isn't available. Without this compiler-rt can't be
      built with LLVM 13 or earlier.
    
      Not building the libcall functions isn't optimal, but aligns with the
      usecase in FreeBSD where compiler-rt from LLVM 14 is built with an LLVM
      13 clang and no LLVM 14 clang is built.
    
      Reviewed By:    efriedma
    
      Differential Revision:  https://reviews.llvm.org/D126710
    
    MFC after:      3 days
    
    (cherry picked from commit cfefd16d5721f5bb89506df7d2bb9e18f60b034a)
---
 contrib/llvm-project/compiler-rt/lib/builtins/atomic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c b/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c
index 4c3ebb99a513..8dc2f4fc013a 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c
@@ -363,6 +363,9 @@ OPTIMISED_CASES
 #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW(n, lockfree, type, xor, ^)
 OPTIMISED_CASES
 #undef OPTIMISED_CASE
+// Allow build with clang without __c11_atomic_fetch_nand builtin (pre-14)
+#if __has_builtin(__c11_atomic_fetch_nand)
 #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW_NAND(n, lockfree, type)
 OPTIMISED_CASES
 #undef OPTIMISED_CASE
+#endif