Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: rewrite x86_64 build system #334

Merged
merged 9 commits into from
Sep 29, 2024
Merged

Conversation

hawkw
Copy link
Contributor

@hawkw hawkw commented Sep 29, 2024

So I rewrote the x86_64 kernel's build system again.

This commit rewrites the builder for the x86_64 kernel to be a cargo
custom runner, rather than a build script in a normal crate. This way,
we can use

$ cargo run --package mnemos-x86_64 --target-arch x86_64-unknown-none

to build the x86 kernel normally using cargo, outputting a path that's
then passed into the custom runner binary by Cargo. This way, we don't
build the whole kernel inside a build script, so we get normal cargo
output from the kernel build, and we don't need to deal with the fact
that we have to rerun the build script whenever the kernel or any of its
dependencies changes. Instead, the kernel is built by a normal cargo
invocation, which is like infinitely better in literally every possible
way. The custom runner can also launch QEMU, so you can now cargo run
the x86 kernel and IT JUST WORKS, RIGHT OUT OF THE BOX.1

The one weird thing about this approach is that now, you build the
kernel by running cargo run with a build subcommand that tells it to
not actually build the kernel, instead of cargo build like a normal
person. This is, admittedly, weird; but it's so much less bad than the
previous thing where you had to run cargo clean every time you changed
the kernel if you didn't want to get a stale build artifact (see #332),
which was incredibly life-ruining and made developing the x86 kernel a
horrific nightmare of infinite pain. And, most of the time you'll build
it using the Justfile just run-x86 and just build-x86 recipes so you
don't have to face the horrible truth that you're using cargo run to
build something without running it. So, whatever.

Closes #332

Footnotes

  1. Provided that, like, you have qemu-system-x86_64 on your
    computer, and stuff.

@hawkw hawkw requested a review from spookyvision September 29, 2024 19:49
@hawkw hawkw added this pull request to the merge queue Sep 29, 2024
Merged via the queue into main with commit 7392db2 Sep 29, 2024
12 checks passed
@hawkw hawkw deleted the eliza/rewrite-the-build-system-again branch September 29, 2024 20:18
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.

x86 bootimage runner is bad and we should feel bad too
2 participants