From f500c931377ea755fbafbceb0fe101c4c64efe8c Mon Sep 17 00:00:00 2001 From: Lucas Holt Date: Fri, 25 Sep 2026 14:15:56 -0400 Subject: [PATCH 1/2] ck: select kernel headers for any _KERNEL build, not just __MidnightBSD__ The Linux/macOS cross-build CI compiles the kernel with an upstream clang targeting *-unknown-freebsd13.4, which predefines __FreeBSD__ but not __MidnightBSD__. ck_stdint.h, ck_stddef.h, ck_stdbool.h, ck_stdlib.h and ck_string.h still gated their kernel branch on __MidnightBSD__, so they fell through to the hosted //... includes, which do not exist under -nostdinc: contrib/ck/include/ck_stdint.h:33:10: fatal error: 'stdint.h' file not found contrib/ck/include/ck_stdbool.h:30:10: fatal error: 'stdbool.h' file not found Key the BSD branch on _KERNEL alone, matching the fix already applied to ck_limits.h in 8b8a33bb4e. Verified by building genassym.o, every ck_*.o and subr_epoch.o/subr_pctrie.o with both the native compiler and CC='clang -U__MidnightBSD__'. AI-Assisted-by: Claude Fable 5.1 Co-Authored-By: Claude Fable 5.1 Signed-off-by: Lucas Holt --- sys/contrib/ck/include/ck_stdbool.h | 2 +- sys/contrib/ck/include/ck_stddef.h | 2 +- sys/contrib/ck/include/ck_stdint.h | 2 +- sys/contrib/ck/include/ck_stdlib.h | 2 +- sys/contrib/ck/include/ck_string.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/contrib/ck/include/ck_stdbool.h b/sys/contrib/ck/include/ck_stdbool.h index 6af26ab4fad..d00f367669c 100644 --- a/sys/contrib/ck/include/ck_stdbool.h +++ b/sys/contrib/ck/include/ck_stdbool.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#if defined(__MidnightBSD__) && defined(_KERNEL) +#if defined(_KERNEL) /* any BSD kernel build; compiler may not predefine __MidnightBSD__/__FreeBSD__ */ #include #else #include diff --git a/sys/contrib/ck/include/ck_stddef.h b/sys/contrib/ck/include/ck_stddef.h index ab5868001b2..a7e487b5385 100644 --- a/sys/contrib/ck/include/ck_stddef.h +++ b/sys/contrib/ck/include/ck_stddef.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#if defined(__MidnightBSD__) && defined(_KERNEL) +#if defined(_KERNEL) /* any BSD kernel build; compiler may not predefine __MidnightBSD__/__FreeBSD__ */ #include #else #include diff --git a/sys/contrib/ck/include/ck_stdint.h b/sys/contrib/ck/include/ck_stdint.h index 7398d8cfaf9..f88426b13fa 100644 --- a/sys/contrib/ck/include/ck_stdint.h +++ b/sys/contrib/ck/include/ck_stdint.h @@ -27,7 +27,7 @@ #if defined(__linux__) && (defined(__KERNEL__) || defined(_KERNEL)) #include #include -#elif defined(__MidnightBSD__) && defined(_KERNEL) +#elif defined(_KERNEL) /* any BSD kernel build; compiler may not predefine __MidnightBSD__/__FreeBSD__ */ #include #else #include diff --git a/sys/contrib/ck/include/ck_stdlib.h b/sys/contrib/ck/include/ck_stdlib.h index a8555104ad3..aede9ec1ae7 100644 --- a/sys/contrib/ck/include/ck_stdlib.h +++ b/sys/contrib/ck/include/ck_stdlib.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#if defined(__MidnightBSD__) && defined(_KERNEL) +#if defined(_KERNEL) /* any BSD kernel build; compiler may not predefine __MidnightBSD__/__FreeBSD__ */ #include #else #include diff --git a/sys/contrib/ck/include/ck_string.h b/sys/contrib/ck/include/ck_string.h index 6b0978103a4..238953ef378 100644 --- a/sys/contrib/ck/include/ck_string.h +++ b/sys/contrib/ck/include/ck_string.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -#if defined(__MidnightBSD__) && defined(_KERNEL) +#if defined(_KERNEL) /* any BSD kernel build; compiler may not predefine __MidnightBSD__/__FreeBSD__ */ #include #else #include From 099d3d99e30a42a6dc99a0d68c9dadd0e23d1ef1 Mon Sep 17 00:00:00 2001 From: Lucas Holt Date: Fri, 25 Sep 2026 14:15:56 -0400 Subject: [PATCH 2/2] ci: stop overriding kernel CFLAGS on the Linux arm64 buildkernel KERNEL_FLAGS is expanded raw onto the bmake command line, and a command-line CFLAGS+= assignment makes CFLAGS command-line-owned, so every CFLAGS=/CFLAGS+= line in sys/conf/kern.pre.mk is ignored. The arm64 Ubuntu job therefore lost -nostdinc and all -I paths and failed immediately: sys/kern/genoffset.c:31:10: fatal error: 'sys/cdefs.h' file not found The -idirafter paths added in f3f40cdac7 and 4f31c80e0f were workarounds for the ck header problem fixed in the previous commit, so drop them. AI-Assisted-by: Claude Fable 5.1 Co-Authored-By: Claude Fable 5.1 Signed-off-by: Lucas Holt --- .github/workflows/cross-bootstrap-tools.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/cross-bootstrap-tools.yml b/.github/workflows/cross-bootstrap-tools.yml index 9aa2b7cb6ca..69e05e00350 100644 --- a/.github/workflows/cross-bootstrap-tools.yml +++ b/.github/workflows/cross-bootstrap-tools.yml @@ -67,8 +67,4 @@ jobs: args+=($EXTRA_BUILD_ARGS) fi args+=(TARGET=${{ matrix.target }} TARGET_ARCH=${{ matrix.target_arch }} KERNCONF=GENERIC NO_MODULES=yes buildkernel -s -j"$NPROC") - if [ "${{ runner.os }}" = "Linux" ] && [ "${{ matrix.target_arch }}" = "aarch64" ]; then - resource_dir=$(/usr/lib/llvm-18/bin/clang -print-resource-dir) - args+=("KERNEL_FLAGS=CFLAGS+=-idirafter ${PWD}/tools/build/cross-build/include/common CFLAGS+=-idirafter ${resource_dir}/include") - fi "${args[@]}"