Fix remaining Cross-build Kernel CI failures - #524
Conversation
An external toolchain (upstream clang on Linux/macOS CI) is driven with
-target *-unknown-freebsd13.4 and predefines __FreeBSD__ but not
__MidnightBSD__. The tree keys on __MidnightBSD__ throughout the kernel
(ACPICA's acenv.h, netmap, ipfilter, dtrace, sys/param.h, ...), so the
cross build died in the first ACPICA header:
contrib/dev/acpica/include/platform/acenv.h:365:2: error: Unknown target environment
When bsd.compiler.mk reports the external compiler does not know
__MidnightBSD_cc_version, add -D__MidnightBSD__=<N> to XCFLAGS, using the
same value our own clang derives from the triple's OS major version.
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 GuideUpdates cross-build compiler flags so external clang toolchains targeting FreeBSD-compatible triples define File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
cpufreq_dt.c calls abs64(), which this tree only defined privately in
linuxkpi's <linux/kernel.h> and drm2's drm_os_freebsd.h. Every arm64
GENERIC build therefore fails:
sys/dev/cpufreq/cpufreq_dt.c:116:10: error: call to undeclared function 'abs64'
Provide abs64() in <sys/libkern.h> next to qabs(), as FreeBSD does, and
remove the two duplicate static inlines so headers that include both do
not hit a redefinition error.
Verified: cpufreq_dt.o cross-compiles for aarch64; translation units
including <linux/kernel.h> and <dev/drm2/drmP.h> build with amd64 kernel
flags; sys/modules/linuxkpi linux_compat.o/linux_kmod.o build natively.
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>
|
Claude finished @laffer1's task in 2m 28s —— View job Claude finished the code review
ReviewTwo commits: the
No correctness, malloc/free, bounds-checking, or style(9) issues found. No assembly or |
Follow-up to #523. With the ck header and CFLAGS fixes in, every Cross-build Kernel job got past genassym and died in the first ACPICA header. Three commits, each fixing the next failure CI exposed:
1. Makefile.inc1: define
__MidnightBSD__for external cross compilers. The cross build drives upstream clang-18 with a*-unknown-freebsd13.4triple, which predefines__FreeBSD__but not__MidnightBSD__. The whole kernel tree keys on__MidnightBSD__(ACPICAacenv.hfailed first withUnknown target environment), so patching headers one by one is the wrong fix. When bsd.compiler.mk reports the external compiler has no__MidnightBSD_cc_version, Makefile.inc1 now adds-D__MidnightBSD__=<N>to XCFLAGS next to-target, with N taken from the triple's OS major version exactly as our own clang derives it. Native builds are unaffected. This alone turned both amd64 jobs green.2. libkern: add
abs64(). Both arm64 jobs then failed on a genuine source bug:cpufreq_dt.ccallsabs64(), which this tree only defined privately in linuxkpi and drm2. This breaks native arm64 GENERIC too. Added to<sys/libkern.h>next toqabs()as FreeBSD does; removed the two private copies to avoid redefinition errors.3. arm64: drop the stale
crypto/openssl/aarch64/arm_arch.h. Next arm64 failure, also a native bug: the OpenSSL aarch64.Sfiles#include "arm_arch.h", which resolves to a sibling copy from OpenSSL 1.1 (2018) that lacksAARCH64_VALID_CALL_TARGET, so the macro is assembled literally (unrecognized instruction mnemonic). Removed the stale copy so the maintainedsys/crypto/openssl/arm_arch.his found, added-I$S/crypto/opensslto the aarch64 OpenSSL rules in files.arm64 as FreeBSD does, and repointedossl_aarch64.cat the surviving header. No assembly was modified.Verified locally:
bmake -f Makefile.inc1 -V XCFLAGSfor simulated external and native compilers;cpufreq_dt.oand all OpenSSL/armv8crypto aarch64 objects cross-compile from a GENERIC+ossl config (each fails identically before its fix); translation units including<linux/kernel.h>and<dev/drm2/drmP.h>build with amd64 kernel flags;sys/modules/linuxkpiobjects build natively.AI-Assisted-by: Claude Fable 5.1
🤖 Generated with Claude Code