Repository navigation
Plan Import machinery
Roadmap milestone F1 (Phase 0). Large upstream projects (LLVM, GCC, Mesa, Linux DRM, linux-firmware) are imported the same way: pristine upstream source, build lists generated from upstream's own build system, and a component model that decides what gets built. T1 (LLVM 23), T2 (GCC 16) and G1 (Mesa 26) are its first users; DRM, which already works this way, is moved onto it first, so the machinery is proved on an import whose output is known.
-
Pristine source.
dist/is byte-identical to an upstream tag. Imports are commits on avendor/<project>branch, tagged<project>-<tag>, merged into trunk;git diffbetween two tags is exactly upstream's change. A paths file maps upstream paths todist/and keeps the import to what the build uses. Local changes never go intodist/: they go into compatibility code, or into a replacement file outsidedist/that the build lists instead, with a comment saying why (the DRM rules, made general). - License classification. Every built file is classified by its SPDX tag (or its header when it has none). Files outside the project's expected license need an entry in an allowlist and, for GPL-only files in a permissive project, a build switch.
- Build description, generated. A reader runs upstream's build system and extracts, per target: its kind (library, program, kernel module, host tool, header set), its sources, per-file flags, include paths and defines, its dependencies, and the files generated at build time with the commands that make them (TableGen, mkregtable, Python code generators). All readers write the same intermediate description, so the emitters do not care which build system it came from.
-
Configuration results, kept.
config.hand similar files come from running upstream's configure step against the target's sysroot, per architecture, and are committed, together with the command line that made them. They are checked on the target when libc changes (as in C2a, where 353 kept results were updated). -
Emitted BSD make files. From the description:
Makefiles for libraries and programs usingbsd.lib.mk/bsd.prog.mk,files.*lists andsrcs.mkfor kernel code, set list entries, and mtree entries. Generated files carry a header naming the generator and the upstream tag; they are never edited by hand. -
A regeneration check.
verifyre-imports and regenerates and fails on any difference: pristinedist/, committed generated files equal to what the generators produce now. It is a maintainer and CI step;build.shnever runs a generator.
A project declares its components in components (one file per
project): name, one-line description, the targets it owns, the
components it needs (in this project or another), the set its files go
to, and whether it is on by default. Components are coarse: for LLVM,
roughly clang, lld, the LLVM binary tools, lldb, compiler-rt builtins,
sanitizers, libunwind, libc++/libc++abi, OpenMP, clang-tools-extra,
libclc; not one per library.
- Each component is an
MKvariable (MKLLVM_LLD,MKMESA_VULKAN), so it is also a set-list keyword with no further work: the set tools already treat everyMKvariable as a selector. - Everything is on by default: full strength. Lighter systems come
from presets: named, additive sets of components (
PRESET=minimal,PRESET=server,PRESET=desktop), set withbuild.sh -V. An explicitMKsetting overrides the preset. - The dependency closure is computed when
bsd.own.mkis read, from a generatedbsd.components.mk: turning a component on turns on what it needs; turning off something an enabled component needs is an error that names both, not a silent change. -
make -f mkvars.mklists components, their state and why (default, preset, explicit, needed by X).
| build system | used by | how |
|---|---|---|
| Kbuild | DRM | GNU make evaluates each directory's Kbuild with the Kconfig options set (today's kbuild2netbsd) |
| CMake | LLVM, compiler-rt, libc++ | the CMake file API (codemodel and toolchains replies) for targets, sources and flags; ninja -t commands/-t graph for custom commands such as TableGen |
| meson | Mesa, libdrm |
meson introspect (targets, sources, per-target arguments, custom targets) |
| autoconf + make | GCC, binutils | configure for the config headers; the source and flag lists from upstream's makefiles evaluated with make -n and the object lists (the mechanism decided with T2) |
-
external/import/: the shared Python 3 package (paths, import, verify, license classification, the intermediate description, the emitters, the component closure) and one reader per build system. Python is needed only by the maintainer at import time; the build never runs it. - Per project, next to its
dist/:import.conf(upstream repository, tag, paths),components, the license allowlist, and any per-project hooks (the DRM wrapper renaming, LLVM's TableGen rules). - Today's per-project tools (
tools/import,verify-dist,license-check,kbuild2netbsdunder DRM;firmware.sh) become thin calls into the package and are then removed.
Each step has its proof: the same output before and after, or a build that matches upstream's.
-
Vendor tools.
import,verifyand license classification in the package, driven byimport.conf. Proof: DRM'sdist/re-imported from v7.3.7 is byte-identical, and the license report equals today's. -
Description and make emitter; Kbuild reader.
kbuild2netbsdported onto the intermediate description. Proof: every generated DRM list (files.*,srcs.mk, the renamed wrappers) is unchanged, for x86_64 and aarch64. -
CMake reader. Proved on LLVM 23's runtimes (libunwind,
libc++abi, libc++, compiler-rt builtins) and on
llvm-tblgen: built through the generated makefiles, each library has the same object list and exported symbols as the CMake build of the same tag. This is the base T1 starts from. - meson reader. Proved on libdrm from xsrc against its meson build, the same way: same objects, same symbols. This is the base G1 starts from.
-
Components and presets.
bsd.components.mkgeneration, the closure inbsd.own.mk, the listing inmkvars.mk; DRM's existing switches (MKDRM_GPL, the drivers) as the first components. Proof: the default build's set lists are unchanged; a preset that drops a component removes exactly its files; turning off a needed component fails with both names. - Book chapter: how an import works, for maintainers.
autoconf comes with T2, where it is needed; LLVM's full component list comes with T1.
aiBSD system development guide
Tutorial
II — Building
III — The kernel
- Kernel basics
- Booting and kernel modules
- The boot loader
- System calls and other numbered ABIs
- The auxiliary vector and CPU features
- Locales in libc
- Threads, processes, tasks
- Devices and drivers
- Files, descriptors, device nodes
- PCI
- Virtual memory
- Memory and DMA
- Page tables, TLBs, memory types
- Firmware
- State and events
- The console
- Power management
IV — Linux compat layer
V — DRM
VI — Testing
VII — Upstreams
Appendices