Fix the Cross-build Kernel CI workflow - #523
Merged
Merged
Conversation
…SD__
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 <stdint.h>/<stdbool.h>/... 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 8b8a33b. 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 <noreply@anthropic.com>
Signed-off-by: Lucas Holt <luke@foolishgames.com>
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 f3f40cd and 4f31c80 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 <noreply@anthropic.com>
Signed-off-by: Lucas Holt <luke@foolishgames.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes cross-build kernel CI by making CK headers recognize any _KERNEL build regardless of predefined OS macros, preventing hosted-header failures with upstream clang triples, and removing the arm64 Ubuntu CFLAGS+= workaround that caused bmake to discard the kernel’s normal include flags. Flow diagram for cross-build kernel header selectionflowchart TD
A["Cross-build kernel compilation"] --> B{_KERNEL defined?}
B -->|Yes| C["CK headers include sys kernel headers"]
B -->|No| D["CK headers include hosted standard headers"]
C --> E["Works with upstream clang FreeBSD triple"]
D --> F["Uses stdbool.h stddef.h stdint.h stdlib.h or string.h"]
Flow diagram for corrected arm64 kernel build flagsflowchart TD
A["Cross-build workflow"] --> B["Build kernel with normal bmake flags"]
B --> C["kern.pre.mk supplies -nostdinc and -I paths"]
C --> D["Kernel and CK headers resolve sys includes"]
D --> E["genassym.o and kernel objects compile"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This was referenced Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Cross-build Kernel workflow has failed on every master run for months. Three independent causes, one commit each:
1. ck compat headers gate on
__MidnightBSD__. Fivesys/contrib/ck/include/ck_*.hheaders fell through to hosted<stdint.h>/<stdbool.h>under-nostdincwhen the macro was missing. Keyed the branch on_KERNELlike the earlier ck_limits.h fix (8b8a33b).2. arm64 Ubuntu passes
KERNEL_FLAGS=CFLAGS+=.... A command-lineCFLAGS+=makes CFLAGS command-line-owned in bmake, so every CFLAGS line in kern.pre.mk is dropped and the kernel loses-nostdincand all-Ipaths (sys/cdefs.h file not foundin genoffset.c). The two-idirafterhacks were workarounds for cause 1, so they are removed.3. External compilers never define
__MidnightBSD__. The cross build drives upstream clang-18 with a*-unknown-freebsd13.4triple, which predefines__FreeBSD__only. The whole kernel tree keys on__MidnightBSD__(ACPICAacenv.hwas the first to fail withUnknown target environment, followed by netmap, ipfilter, dtrace, ...). When bsd.compiler.mk reports the external compiler has no__MidnightBSD_cc_version, Makefile.inc1 now adds-D__MidnightBSD__=<N>to XCFLAGS, with N taken from the triple's OS major version exactly as our own clang does. Native builds are unaffected.Causes 1 and 2 were verified locally (all
ck_*.o,genassym.o,subr_epoch.o,subr_pctrie.owithCC='clang -U__MidnightBSD__'). Cause 3 was verified viabmake -f Makefile.inc1 -V XCFLAGSfor simulated external and native compilers; the PR's CI run is the end-to-end test.AI-Assisted-by: Claude Fable 5.1
Fixes: f3f40cd ci: add clang resource headers for arm64 kernel build
Fixes: 4f31c80 ci: add cross-build headers for Linux arm64 kernel builds
🤖 Generated with Claude Code