📘 Khy-OS 文档站 🧭 新手先读:核心概念

Vendored MoonBit prebuilt artifacts

Vendored MoonBit prebuilt artifacts#

These files let the kernel build without the MoonBit (moon) toolchain when
make MOONBIT_PREBUILT=1 is used (the native Windows build path; see
services/backend/src/cli/handlers/khyos.js). In the default build they are NOT used —
make regenerates build/moonbit_gen.c via moon build as before.

Contents#

FileSourcePurpose
moonbit_gen.cgenerated by moon build --target native then main()moonbit_entry() sed (see kernel/Makefile moonbit-build)the MoonBit module compiled to C
runtime.c~/.moon/lib/runtime.cMoonBit C runtime
include/moonbit.h~/.moon/include/moonbit.hruntime header
include/moonbit-fundamental.h~/.moon/include/moonbit-fundamental.hthe only header moonbit.h pulls in under -DMOONBIT_NATIVE_NO_SYS_HEADER

-DMOONBIT_NATIVE_NO_SYS_HEADER (already in MOONBIT_CFLAGS) gates off every system
include in runtime.c (stdio.h, windows.h, backtrace.h, …), so this 3-file set is
fully self-contained for a freestanding build. backtrace.h is NOT required
(gated behind MOONBIT_ALLOW_STACKTRACE, which is not defined).

Version pin (ABI invariant)#

moonbit_gen.c and runtime.c/headers MUST come from the same MoonBit release —
a mismatch can break the ABI between the generated C and the runtime.

Generated with:

moon 0.1.20260427 (48d7def 2026-04-27)

Regenerating (maintainers)#

After changing kernel/moonbit/**, regenerate and refresh these files:

cd kernel && make moonbit-build           # writes build/moonbit_gen.c
cp build/moonbit_gen.c        vendor/moonbit/moonbit_gen.c
cp ~/.moon/lib/runtime.c      vendor/moonbit/runtime.c
cp ~/.moon/include/moonbit.h              vendor/moonbit/include/moonbit.h
cp ~/.moon/include/moonbit-fundamental.h vendor/moonbit/include/moonbit-fundamental.h

Update the version pin above to the moon version that produced them.