🆕 Carry the reims-graphics option ROM prebuilt, with its record
QEMU's reims-graphics-pci has no default option ROM, and reims-ctl is to name one for every x86-64 VM on reims-vgpu's own device, on hosts that build no firmware. firmware/prebuilt/ReimsGraphics.rom is the ROM `make -C firmware prebuilt` builds on a Mac (Apple clang 21.0.0, Homebrew lld 23.1.4; the bytes are the compiler's), and ReimsGraphics.toml records its sha256 and that of every file it was built from, the wire header among them. `make -C firmware prebuilt-check` (firmware/prebuilt.sh --check) hashes the ROM and those files against the record on any host, with no compiler, and `cargo xtask check` runs it: the wire header is the library's, whose checks would otherwise never see the ROM go stale.
This commit is contained in:
1 parent
d47ccde75b
commit
bf69e0fee1
5 files changed
+139
-4
No files matched your search
+15
-3
@@ -4,8 +4,14 @@
|
||||
# the reims-graphics device's (docs/graphics-kext/design.md), built on the
|
||||
# host's wire protocol header in ../crates/reims-graphics/include.
|
||||
#
|
||||
# make build/ReimsVgpu.{efi,rom} and build/ReimsGraphics.{efi,rom}
|
||||
# make clean remove build/
|
||||
# make build/ReimsVgpu.{efi,rom} and build/ReimsGraphics.{efi,rom}
|
||||
# make prebuilt on a Mac, also prebuilt/ReimsGraphics.rom, which reims-ctl carries, and
|
||||
# prebuilt/ReimsGraphics.toml, the sha256 of the files it was built from
|
||||
# (prebuilt.sh): commit both with a change to what the ROM is built from
|
||||
# make prebuilt-check
|
||||
# fail where the committed ROM is stale: a file its record names changed
|
||||
# (cargo xtask check runs it)
|
||||
# make clean remove build/
|
||||
#
|
||||
# BUILD moves the output: cargo xtask dist runs `make rom` with BUILD set to
|
||||
# <target>/firmware. Needs clang and lld (on macOS, Homebrew's: brew install
|
||||
@@ -92,9 +98,15 @@ $(BUILD)/obj/%.obj: src/%.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
||||
|
||||
prebuilt: $(BUILD)/$(GNAME).rom
|
||||
sh prebuilt.sh $(BUILD)
|
||||
|
||||
prebuilt-check:
|
||||
@sh prebuilt.sh --check
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD)
|
||||
|
||||
.PHONY: all efi rom clean
|
||||
.PHONY: all efi rom prebuilt prebuilt-check clean
|
||||
|
||||
-include $(OBJECTS:.obj=.d) $(GOBJECTS:.obj=.d)
|
||||
@@ -0,0 +1,90 @@
|
||||
#!/bin/sh
|
||||
# The option ROM reims-ctl carries for reims-vgpu's own device, and the record of what it was
|
||||
# built from:
|
||||
#
|
||||
# sh prebuilt.sh BUILD make prebuilt, after the ROM's build into BUILD, on a Mac
|
||||
# sh prebuilt.sh --check make prebuilt-check, anywhere
|
||||
#
|
||||
# The first copies BUILD/ReimsGraphics.rom to prebuilt/ReimsGraphics.rom and writes
|
||||
# prebuilt/ReimsGraphics.toml: the ROM's sha256, and that of each file it was built from, by its
|
||||
# path in the repository (the Makefile, the ROM's assembler, and every file the compiler's
|
||||
# dependency lists name). It runs on a Mac alone: the ROM's bytes are the compiler's, and the
|
||||
# committed one's are Xcode's clang's and Homebrew's lld's. reims-ctl embeds the ROM
|
||||
# (crates/reims-ctl/src/prebuilt.rs).
|
||||
#
|
||||
# The second fails where the committed ROM or a file the record names is not the record's: a
|
||||
# change to what the ROM is built from, without the ROM built again. cargo xtask check and
|
||||
# reims-ctl's tests run it.
|
||||
set -eu
|
||||
cd "$(dirname "$0")"
|
||||
root=$(cd .. && pwd)
|
||||
record=prebuilt/ReimsGraphics.toml
|
||||
sha() {
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum "$1" | cut -d' ' -f1
|
||||
else
|
||||
shasum -a 256 "$1" | cut -d' ' -f1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${1:-}" = --check ]; then
|
||||
[ -f "$record" ] || {
|
||||
echo "prebuilt: firmware/$record is missing" >&2
|
||||
exit 1
|
||||
}
|
||||
stale=0
|
||||
want=$(sed -n 's/^rom = "\(.*\)"$/\1/p' "$record")
|
||||
if [ ! -f prebuilt/ReimsGraphics.rom ] || [ "$(sha prebuilt/ReimsGraphics.rom)" != "$want" ]; then
|
||||
echo "prebuilt: firmware/prebuilt/ReimsGraphics.rom is not the one its record names" >&2
|
||||
stale=1
|
||||
fi
|
||||
sed -n 's/^"\(.*\)" = "\(.*\)"$/\1 \2/p' "$record" | {
|
||||
changed=0
|
||||
while read -r f want; do
|
||||
if [ ! -f "$root/$f" ] || [ "$(sha "$root/$f")" != "$want" ]; then
|
||||
echo "prebuilt: $f changed since firmware/prebuilt/ReimsGraphics.rom was built" >&2
|
||||
changed=1
|
||||
fi
|
||||
done
|
||||
exit $changed
|
||||
} || stale=1
|
||||
if [ $stale = 1 ]; then
|
||||
echo "prebuilt: run make -C firmware prebuilt on a Mac, and commit the ROM and its record" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "prebuilt: firmware/prebuilt/ReimsGraphics.rom is built from the tree's sources"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
[ "$(uname)" = Darwin ] || {
|
||||
echo "prebuilt: build the committed ROM on a Mac: its bytes are the compiler's" >&2
|
||||
exit 1
|
||||
}
|
||||
build=$1
|
||||
sources=$(
|
||||
{
|
||||
echo Makefile src/ReimsGraphicsRom.S src/OptionRom.S
|
||||
cat "$build"/obj/ReimsGraphics.d "$build"/obj/ReimsGraphicsOutput.d "$build"/obj/ReimsGraphicsName.d
|
||||
} | tr -d '\\' | tr ' \t' '\n\n' | grep -v -e ':$' -e '^$' -e '\.obj$' |
|
||||
while read -r f; do
|
||||
d=$(cd "$(dirname "$f")" && pwd)
|
||||
echo "${d#"$root"/}/$(basename "$f")"
|
||||
done | LC_ALL=C sort -u
|
||||
)
|
||||
mkdir -p prebuilt
|
||||
cp "$build/ReimsGraphics.rom" prebuilt/ReimsGraphics.rom
|
||||
chmod 644 prebuilt/ReimsGraphics.rom
|
||||
{
|
||||
echo "# prebuilt/ReimsGraphics.rom, the option ROM reims-ctl carries for reims-vgpu's own device,"
|
||||
echo "# and the sha256 of each file it was built from: make -C firmware prebuilt writes both on a"
|
||||
echo "# Mac, and make -C firmware prebuilt-check checks them against the tree. Built with:"
|
||||
echo "# $(clang --version | head -1)"
|
||||
echo "# $(ld.lld --version | head -1)"
|
||||
echo "rom = \"$(sha prebuilt/ReimsGraphics.rom)\""
|
||||
echo
|
||||
echo "[sources]"
|
||||
for f in $sources; do
|
||||
echo "\"$f\" = \"$(sha "$root/$f")\""
|
||||
done
|
||||
} >"$record"
|
||||
echo "prebuilt: firmware/prebuilt/ReimsGraphics.rom and firmware/$record"
|
||||
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
# prebuilt/ReimsGraphics.rom, the option ROM reims-ctl carries for reims-vgpu's own device,
|
||||
# and the sha256 of each file it was built from: make -C firmware prebuilt writes both on a
|
||||
# Mac, and make -C firmware prebuilt-check checks them against the tree. Built with:
|
||||
# Apple clang version 21.0.0 (clang-2100.4.1.1)
|
||||
# Homebrew LLD 23.1.4 (compatible with GNU linkers)
|
||||
rom = "749434f87f562895548f60681cd4cd8bf6cc0d0e967ac2fea297674426709161"
|
||||
|
||||
[sources]
|
||||
"crates/reims-graphics/include/reims_graphics_wire.h" = "48eb0e5bffaf6a1d2adee16ee9df6c2a88e7352d7fe867bd39509ca85868e5d7"
|
||||
"firmware/Makefile" = "dfdc68504271e09cec05f2408c7a73c7fa2487f20ffef0944fe20b078ae3b322"
|
||||
"firmware/src/OptionRom.S" = "54cb57ea2e5b4ac67e1627f5251314d56c4792a376a9c535deb661f0e29714a4"
|
||||
"firmware/src/ReimsGraphics.c" = "554751ff15edbdf69a038d5b2aefd8315b9c54610c090c0890d9c72b13dacdef"
|
||||
"firmware/src/ReimsGraphics.h" = "83e3439b9baf9c06ee75c57537792770efa7a5cb07e22bf1fb47f6ffef7af169"
|
||||
"firmware/src/ReimsGraphicsName.c" = "107e7e34240a3942dcd410b701768ab81013f42932783b7fa90fcefc3f815f19"
|
||||
"firmware/src/ReimsGraphicsOutput.c" = "c35ed747684d90c2b195d95613d79111a9f7c0777654f5f027ed9951bdd7a112"
|
||||
"firmware/src/ReimsGraphicsRom.S" = "db1211cc9d4b40628d101a7377eeeebfefc57820ec5fd1a72fffefb90c2ed2bb"
|
||||
"firmware/src/Uefi.h" = "d9b349424b645428c114d141b0ca7c4b92ccef573803e16eea501258eb5572ee"
|
||||
+17
-1
@@ -52,7 +52,7 @@ const COMMANDS: &[Command] = &[
|
||||
},
|
||||
Command {
|
||||
name: "check",
|
||||
about: "testkit, header --check, rustfmt, clippy, cargo nextest and the doc-tests; on a Mac, also clippy for x86-64 Linux and, where Rosetta runs x86-64 code, core's tests as x86-64",
|
||||
about: "testkit, header --check, the prebuilt option ROM's record (make -C firmware prebuilt-check), rustfmt, clippy, cargo nextest and the doc-tests; on a Mac, also clippy for x86-64 Linux and, where Rosetta runs x86-64 code, core's tests as x86-64",
|
||||
run: cmd_check,
|
||||
},
|
||||
];
|
||||
@@ -139,6 +139,18 @@ fn cargo_with(args: &[&str], env: &[(&str, &std::path::Path)]) -> Res<bool> {
|
||||
Ok(status.success())
|
||||
}
|
||||
|
||||
/// Runs `make` with `args` from the repository's root: one of the check's steps that are not
|
||||
/// cargo's.
|
||||
fn make(args: &[&str]) -> Res<bool> {
|
||||
println!("$ make {}", args.join(" "));
|
||||
let status = std::process::Command::new("make")
|
||||
.args(args)
|
||||
.current_dir(repo_root())
|
||||
.status()
|
||||
.map_err(|e| format!("make: {e}"))?;
|
||||
Ok(status.success())
|
||||
}
|
||||
|
||||
/// The features `check` tests with: every feature of the workspace's crates but the C API's
|
||||
/// `vulkan`, which makes every handle of the C API the Vulkan platform's, so that the pins and
|
||||
/// the C harness, which drive the product's C API, would run on that platform instead
|
||||
@@ -191,6 +203,10 @@ fn cmd_check(args: &[String]) -> Res<bool> {
|
||||
let mut ok = true;
|
||||
ok &= cmd_testkit(&[])?;
|
||||
ok &= header::cmd_header(&["--check".to_owned()])?;
|
||||
// The option ROM reims-ctl carries is built from the tree's sources: a change to what it is
|
||||
// built from (the wire header among them) without it built again fails here, though the
|
||||
// library's checks reach neither (firmware/prebuilt.sh).
|
||||
ok &= make(&["-C", "firmware", "prebuilt-check"])?;
|
||||
if !flag(args, "--no-cargo") {
|
||||
let features = if cfg!(target_os = "linux") {
|
||||
LINUX_FEATURES
|
||||
|
||||
Reference in new issue
Block a user