[compiler-rt] [compiler-rt] FreeBSD kernel headers in baremetal libprofile (PR #211278)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 22 13:50:03 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: Justin Cady (justincady)
<details>
<summary>Changes</summary>
Add conditional FreeBSD kernel headers when building baremetal profile
library. This is unconnected to a CMake target; it requires building
libprofile out of band with `-DCOMPILER_RT_PROFILE_BAREMETAL=1`.
The headers replaced in this diff are not available when building for
FreeBSD kernel space. This is the first issue I hit when experimenting
with using the baremetal libprofile like this, so there may be other
changes required as I make progress.
---
Full diff: https://github.com/llvm/llvm-project/pull/211278.diff
5 Files Affected:
- (modified) compiler-rt/lib/profile/InstrProfiling.c (+5)
- (modified) compiler-rt/lib/profile/InstrProfiling.h (+5)
- (modified) compiler-rt/lib/profile/InstrProfilingInternal.h (+5)
- (modified) compiler-rt/lib/profile/InstrProfilingPort.h (+4)
- (modified) compiler-rt/lib/profile/InstrProfilingWriter.c (+4)
``````````diff
diff --git a/compiler-rt/lib/profile/InstrProfiling.c b/compiler-rt/lib/profile/InstrProfiling.c
index d59ec78ad3296..a0adb43d7957f 100644
--- a/compiler-rt/lib/profile/InstrProfiling.c
+++ b/compiler-rt/lib/profile/InstrProfiling.c
@@ -9,8 +9,13 @@
// Note: This is linked into the Darwin kernel, and must remain compatible
// with freestanding compilation. See `darwin_add_builtin_libraries`.
+#if defined(__FreeBSD__) && defined(_KERNEL)
+#include <sys/limits.h>
+#include <sys/systm.h>
+#else
#include <limits.h>
#include <string.h>
+#endif
#include "InstrProfiling.h"
#include "InstrProfilingInternal.h"
diff --git a/compiler-rt/lib/profile/InstrProfiling.h b/compiler-rt/lib/profile/InstrProfiling.h
index f4b4a5f622894..369f26b33ba1d 100644
--- a/compiler-rt/lib/profile/InstrProfiling.h
+++ b/compiler-rt/lib/profile/InstrProfiling.h
@@ -10,7 +10,12 @@
#define PROFILE_INSTRPROFILING_H_
#include "InstrProfilingPort.h"
+#if defined(__FreeBSD__) && defined(_KERNEL)
+#include <sys/stddef.h>
+#include <sys/types.h>
+#else
#include <stddef.h>
+#endif
#ifndef COMPILER_RT_PROFILE_BAREMETAL
#include <stdio.h>
#endif
diff --git a/compiler-rt/lib/profile/InstrProfilingInternal.h b/compiler-rt/lib/profile/InstrProfilingInternal.h
index 61485915bddad..e53c0e28edb13 100644
--- a/compiler-rt/lib/profile/InstrProfilingInternal.h
+++ b/compiler-rt/lib/profile/InstrProfilingInternal.h
@@ -9,7 +9,12 @@
#ifndef PROFILE_INSTRPROFILING_INTERNALH_
#define PROFILE_INSTRPROFILING_INTERNALH_
+#if defined(__FreeBSD__) && defined(_KERNEL)
+#include <sys/stddef.h>
+#include <sys/types.h>
+#else
#include <stddef.h>
+#endif
#include "InstrProfiling.h"
diff --git a/compiler-rt/lib/profile/InstrProfilingPort.h b/compiler-rt/lib/profile/InstrProfilingPort.h
index 0149c7aacb2da..0f397046d2eae 100644
--- a/compiler-rt/lib/profile/InstrProfilingPort.h
+++ b/compiler-rt/lib/profile/InstrProfilingPort.h
@@ -146,6 +146,10 @@ static inline size_t getpagesize(void) {
#define O_BINARY 0
#endif
+#if defined(__FreeBSD__) && defined(_KERNEL)
+#include <sys/stdint.h>
+#else
#include <stdint.h>
+#endif
#endif /* PROFILE_INSTRPROFILING_PORT_H_ */
diff --git a/compiler-rt/lib/profile/InstrProfilingWriter.c b/compiler-rt/lib/profile/InstrProfilingWriter.c
index 3021e3b3cfc31..59fa2af316544 100644
--- a/compiler-rt/lib/profile/InstrProfilingWriter.c
+++ b/compiler-rt/lib/profile/InstrProfilingWriter.c
@@ -13,7 +13,11 @@
/* For _alloca */
#include <malloc.h>
#endif
+#if defined(__FreeBSD__) && defined(_KERNEL)
+#include <sys/systm.h>
+#else
#include <string.h>
+#endif
#include "InstrProfiling.h"
#include "InstrProfilingInternal.h"
``````````
</details>
https://github.com/llvm/llvm-project/pull/211278
More information about the llvm-commits
mailing list