[compiler-rt] [compiler-rt] Avoid defining _KERNEL on FreeBSD (PR #143116)
Jessica Clarke via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 04:43:34 PDT 2025
https://github.com/jrtc27 created https://github.com/llvm/llvm-project/pull/143116
Defining _KERNEL is a hack that can cause all kinds of breakage if
you're not careful, since the actual environment is not a kernel build,
and so should be avoided. Since FreeBSD 12 (MFC'ed for 11.3) you can
define _WANT_SYSVSHM_INTERNALS to expose shminfo (and various other
things) to userspace, so use that instead.
>From bb30a782d6e6f5716b736416a6848be111767c11 Mon Sep 17 00:00:00 2001
From: Jessica Clarke <jrtc27 at jrtc27.com>
Date: Fri, 6 Jun 2025 12:39:14 +0100
Subject: [PATCH] [compiler-rt] Avoid defining _KERNEL on FreeBSD
Defining _KERNEL is a hack that can cause all kinds of breakage if
you're not careful, since the actual environment is not a kernel build,
and so should be avoided. Since FreeBSD 12 (MFC'ed for 11.3) you can
define _WANT_SYSVSHM_INTERNALS to expose shminfo (and various other
things) to userspace, so use that instead.
---
.../lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
index 4940062eeae47..8e83ef9ae61df 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
@@ -87,9 +87,8 @@
#include <wchar.h>
#include <wordexp.h>
-#define _KERNEL // to declare 'shminfo' structure
+#define _WANT_SYSVSHM_INTERNALS // to declare 'shminfo' structure
#include <sys/shm.h>
-#undef _KERNEL
#undef IOC_DIRMASK
More information about the llvm-commits
mailing list