Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Dec 2021 11:56:34 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ed0550041614 - stable/12 - Add kludges for old gcc builds of compiler-rt builtins
Message-ID:  <202112251156.1BPBuYGq007690@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by dim:

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

commit ed0550041614dbb5c2d1d231c7550e1af69f459e
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-12-25 11:48:53 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-25 11:51:45 +0000

    Add kludges for old gcc builds of compiler-rt builtins
    
    Only use the __libgcc_cmp_return__ mode attribute for gcc > 4.2, as it
    was only introduced in gcc 4.3.0.
    
    Don't use __has_include() for old gcc (actually cpp), as this results in
    'missing binary operator before token "("' errors. Also add a forced
    <stdbool.h> include, since old gcc refuses to recognize the 'bool' type
    in freestanding mode.
    
    Use the inline __builtin_sadd_overflow() implementation (originally
    provided for MSVC) for gcc < 5.0, as it was only introduced in gcc 5.0.
    
    NOTE: since the llvm project requires at least gcc >= 5.1, these kludges
    should not be upstreamed.
---
 .../llvm-project/compiler-rt/lib/builtins/fp_compare_impl.inc    | 2 +-
 contrib/llvm-project/compiler-rt/lib/builtins/int_lib.h          | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/fp_compare_impl.inc b/contrib/llvm-project/compiler-rt/lib/builtins/fp_compare_impl.inc
index 40fc7df4c679..eba3ca73725f 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/fp_compare_impl.inc
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/fp_compare_impl.inc
@@ -23,7 +23,7 @@ typedef long long CMP_RESULT;
 typedef long CMP_RESULT;
 #endif
 
-#if !defined(__clang__) && defined(__GNUC__)
+#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
 // GCC uses a special __libgcc_cmp_return__ mode to define the return type, so
 // check that we are ABI-compatible when compiling the builtins with GCC.
 typedef int GCC_CMP_RESULT __attribute__((__mode__(__libgcc_cmp_return__)));
diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/int_lib.h b/contrib/llvm-project/compiler-rt/lib/builtins/int_lib.h
index f10e643363ad..a7051c3ff5a6 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/int_lib.h
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/int_lib.h
@@ -82,13 +82,14 @@
 // back on the latter if not available since NetBSD only has
 // the latter.
 //
-#if defined(__has_include) && __has_include(<sys/limits.h>)
+#if defined(__FreeBSD__) // defined(__has_include) && __has_include(<sys/limits.h>)
 #include <sys/limits.h>
 #else
 #include <machine/limits.h>
 #endif
 #include <sys/stdint.h>
 #include <sys/types.h>
+#include <stdbool.h>
 #else
 // Include the standard compiler builtin headers we use functionality from.
 #include <float.h>
@@ -156,6 +157,10 @@ int __inline __builtin_clzll(uint64_t value) {
 
 #define __builtin_clzl __builtin_clzll
 
+#endif // defined(_MSC_VER) && !defined(__clang__)
+
+#if !defined(__clang__) && (defined(_MSC_VER) || defined(__GNUC__) && __GNUC__ < 5)
+
 bool __inline __builtin_sadd_overflow(int x, int y, int *result) {
   if ((x < 0) != (y < 0)) {
     *result = x + y;
@@ -168,6 +173,6 @@ bool __inline __builtin_sadd_overflow(int x, int y, int *result) {
   return false;
 }
 
-#endif // defined(_MSC_VER) && !defined(__clang__)
+#endif // !defined(__clang__) && (defined(_MSC_VER) || defined(__GNUC__) && __GNUC__ < 5)
 
 #endif // INT_LIB_H



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112251156.1BPBuYGq007690>