[libc-commits] [libc] e381586 - [libc] Work around lack of '__has_builtin' for GPU server (#87417)

via libc-commits libc-commits at lists.llvm.org
Tue Apr 2 15:06:08 PDT 2024


Author: Joseph Huber
Date: 2024-04-02T17:06:03-05:00
New Revision: e381586f259568bf244fcd857ce91fc5cb38b959

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

LOG: [libc] Work around lack of '__has_builtin' for GPU server (#87417)

Summary:
The RPC server build for the GPU support needs to be build from the
"projects" phase of the LLVM build. That means it is built with the same
compile that LLVM supports, which currently is GCC 7.4 in most cases.
A previous patch removed the `LIBC_HAS_BUILTIN` indirection we used,
which regressed the case where we used the `libc` source externally. The
files that we need to use here are `converter.cpp` and `writer.cpp`
which currently are compatible with C++17, so there aren't issues with
the code itself. However, older GCC does not have this builtin which
makes the checks fail.

This patch just adds in a simple wrapper that allows it to correctly
ignore everything if using a compiler that doesn't support it.

Added: 
    

Modified: 
    libc/src/__support/macros/config.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/macros/config.h b/libc/src/__support/macros/config.h
index 3f200f0d62ba26..6390c7992325d4 100644
--- a/libc/src/__support/macros/config.h
+++ b/libc/src/__support/macros/config.h
@@ -13,6 +13,12 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H
 #define LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H
 
+// Workaround for compilers that do not support builtin detection.
+// FIXME: This is only required for the GPU portion which should be moved.
+#ifndef __has_builtin
+#define __has_builtin(b) 0
+#endif
+
 // Compiler feature-detection.
 // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
 #ifdef __has_feature


        


More information about the libc-commits mailing list