feat(build): built-in kernel module support#79
Open
yrakcaz wants to merge 1 commit into
Open
Conversation
3c299d2 to
7291944
Compare
Adds support for compiling kernel modules directly into the kernel binary, making them available at boot before the filesystem is mounted. Introduces `xtask/` — a cargo-xtask build orchestrator with a single `build-kernel` subcommand that runs two `cargo build` passes inside `kernel/`: - First pass produces `libkernel.rlib` - Second pass detects the rlib, compiles configured modules against it, and embeds them as aligned byte arrays via `include_bytes!` The double-pass is necessary because `build.rs` runs before `libkernel.rlib` exists on the first build. `cargo:rerun-if-changed=libkernel.rlib` triggers the second pass automatically. When no built-in modules are configured the second pass is a fast no-op. - `build/module.rs`: new build script module that compiles each `.so` listed in `[modules] builtin` and generates `builtin_modules.rs` with `#[repr(align(8))]`-wrapped `include_bytes!` statics - `src/module/mod.rs`: `load_builtin_modules()` iterates `BUILTIN_MODULES` and calls `Module::load()` on each embedded blob - `src/kernel.rs`: calls `load_builtin_modules()` at boot - `default.build-config.toml`: new `[modules]` section with `builtin = []` - `kernel/README.md`: documents the built-in modules workflow New `builtin_module` job (matrix: x86 × x86_64, debug × release): - configures `build-config.toml` with `builtin = ["ps2", "e1000"]` - builds with `cargo xtask build-kernel` - verifies `builtin_modules.rs` references `libps2.so` and `libe1000.so`
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.
Adds support for compiling kernel modules directly into the kernel binary, making them available at boot before the filesystem is mounted.
Introduces
xtask/, a cargo-xtask build orchestrator with a singlebuild-kernelsubcommand that runs twocargo buildpasses insidekernel/:libkernel.rlibinclude_bytes!The double-pass is necessary because
build.rsruns beforelibkernel.rlibexists on the first build.cargo:rerun-if-changed=libkernel.rlibtriggers the second pass automatically. When no built-in modules are configured the second pass is a fast no-op.build/module.rs: new build script module that compiles each.solisted in[modules] builtinand generatesbuiltin_modules.rswith#[repr(align(8))]-wrappedinclude_bytes!staticssrc/module/mod.rs:load_builtin_modules()iteratesBUILTIN_MODULESand callsModule::load()on each embedded blobsrc/kernel.rs: callsload_builtin_modules()at bootdefault.build-config.toml: new[modules]section withbuiltin = []kernel/README.md: documents the built-in modules workflowNew
builtin_modulejob (matrix: x86 × x86_64, debug × release):build-config.tomlwithbuiltin = ["ps2", "e1000"]cargo xtask build-kernelbuiltin_modules.rsreferenceslibps2.soandlibe1000.so