[llvm] [Bazel] Configure macOS Support capabilities (PR #218186)
Corentin Kerisit via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 22 20:08:45 PDT 2026
https://github.com/cerisier created https://github.com/llvm/llvm-project/pull/218186
The Bazel overlay uses target-platform defines instead of running CMake feature probes, so stable platform capabilities must be selected explicitly. These are properties of supported macOS SDKs and the Darwin ABI: arc4random is declared, the __crashreporter_info__ annotation is supported, and struct stat exposes st_mtimespec.tv_nsec. LLVM GN already hardcodes the same three values for macOS, and native macOS compile probes confirmed the exact interfaces used by LLVM. Gate them on macOS only, retain the arc4random fallback elsewhere, and leave the other macros undefined elsewhere so FreeBSD and other targets inherit no Darwin assumptions.
>From 2e47752537c9cf5e640dd3a1cc3ec858dbf1b477 Mon Sep 17 00:00:00 2001
From: Corentin Kerisit <corentin.kerisit at gmail.com>
Date: Sun, 23 Aug 2026 01:38:38 +0900
Subject: [PATCH] [Bazel] Configure macOS capability macros
---
utils/bazel/llvm-project-overlay/llvm/config.bzl | 11 ++++++++++-
.../llvm/include/llvm/Config/config.h | 4 ++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl
index 49f70f95d2c79..5a81f7f9d92c9 100644
--- a/utils/bazel/llvm-project-overlay/llvm/config.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl
@@ -96,6 +96,15 @@ macos_defines = posix_defines + fenv_defines + [
"HAVE_UNW_ADD_DYNAMIC_FDE=1",
]
+macos_capability_defines = select({
+ "@platforms//os:macos": [
+ "HAVE_CRASHREPORTER_INFO=1",
+ "HAVE_DECL_ARC4RANDOM=1",
+ "HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC=1",
+ ],
+ "//conditions:default": ["HAVE_DECL_ARC4RANDOM=0"],
+})
+
win32_defines = [
# Windows system library specific defines.
"_CRT_SECURE_NO_DEPRECATE",
@@ -120,7 +129,7 @@ os_defines = select({
"@platforms//os:macos": macos_defines,
"@platforms//os:windows": win32_defines,
"//conditions:default": linux_defines,
-}) + backtrace_defines + mallinfo_defines
+}) + macos_capability_defines + backtrace_defines + mallinfo_defines
# HAVE_BUILTIN_THREAD_POINTER is true for on Linux (outside of ppc64) for
# all recent toolchains. Add it here by default on Linux as we can't perform a
diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
index bb69f3c472998..fb86e44d61319 100644
--- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
+++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
@@ -52,7 +52,7 @@
/* Define to 1 if you have the declaration of `arc4random', and to 0 if you
don't. */
-#define HAVE_DECL_ARC4RANDOM 0
+/* HAVE_DECL_ARC4RANDOM defined in Bazel */
/* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you
don't. */
@@ -175,7 +175,7 @@
/* HAVE_SYS_IOCTL_H defined in Bazel */
/* Define to 1 if stat struct has st_mtimespec member .*/
-/* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */
+/* HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC defined in Bazel */
/* Define to 1 if stat struct has st_mtim member. */
/* HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC defined in Bazel */
More information about the llvm-commits
mailing list