Skip to content

feat(build): built-in kernel module support#79

Open
yrakcaz wants to merge 1 commit into
maestro-os:masterfrom
yrakcaz:builtin-modules
Open

feat(build): built-in kernel module support#79
yrakcaz wants to merge 1 commit into
maestro-os:masterfrom
yrakcaz:builtin-modules

Conversation

@yrakcaz

@yrakcaz yrakcaz commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

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

@yrakcaz yrakcaz force-pushed the builtin-modules branch 2 times, most recently from 3c299d2 to 7291944 Compare April 4, 2026 20:06
@yrakcaz yrakcaz force-pushed the builtin-modules branch from 7291944 to 47fcb38 Compare May 29, 2026 17:14
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`
@yrakcaz yrakcaz force-pushed the builtin-modules branch from 47fcb38 to d59a3df Compare June 6, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant