Skip to content

build: auto-build QEMU on a virt BSP build when its binary is missing#298

Merged
daniel-rossier merged 2 commits into
mainfrom
feat/bsp-auto-build-qemu
Jul 16, 2026
Merged

build: auto-build QEMU on a virt BSP build when its binary is missing#298
daniel-rossier merged 2 commits into
mainfrom
feat/bsp-auto-build-qemu

Conversation

@daniel-rossier

Copy link
Copy Markdown
Contributor

Summary

On the QEMU-emulated platforms (virt32/virt64), a full BSP build now builds the emulator automatically when it is missing, so a fresh tree is runnable with st.sh without a separate build.sh qemu step.

Before this, a fresh checkout hit a bare "qemu-system- not found"* at st.sh unless you remembered to build.sh qemu first (the two-step build.sh -x qemu && build.sh bsp-so3 seen in the lvperf Dockerfiles / docs).

Behaviour

build.sh, before building bsp-so3/bsp-linux on virt32/virt64, checks for qemu/build/qemu-system-<arch> and runs bitbake qemu first when it is absent.

  • Bootstrap only — an already-built emulator is left untouched, so the inner build loop pays nothing and the qemu-hacking loop stays the explicit build.sh -x qemu.
  • Hardware platforms (verdin, rpi4) never run under QEMU → skipped.
  • Opt out with IB_BUILD_QEMU="0" in build/conf/local.conf.

Why a build.sh check and not a bitbake dependency

Two dead ends ruled out the recipe-level approach:

  • A parse-time os.path.exists() in a .bbclass is not part of bitbake's parse-cache key, so the decision goes stale (moving the binary doesn't re-trigger the check — verified).
  • QEMU's do_build/do_configure are nostamp (for the in-tree updiff hacking workflow), so a hard qemu:do_build dependency would reconfigure + rebuild QEMU on every BSP build.

A wrapper check reads the real filesystem state on each invocation — deterministic, and free once QEMU is built.

Other changes

  • CI (.github/workflows/build.yml) sets IB_BUILD_QEMU="0" in the build+deploy step (it never runs the emulator, so it skips the multi-minute QEMU compile).
  • lvperf Dockerfiles drop the now-redundant build.sh -x qemu step.
  • local.conf, build.sh -h, docker/README.md and user_guide.rst document the knob.

Test

  • sh -n scripts/build.sh passes; build.sh -h renders.
  • Three real build.sh bsp-so3 runs (with bitbake stubbed) confirm: binary absent → bitbake qemu then bitbake bsp-so3; binary present → bitbake bsp-so3 only; IB_BUILD_QEMU=0bitbake bsp-so3 only.
  • bitbake -g bsp-so3 parses cleanly.

A fresh tree needed a separate `build.sh qemu` before `st.sh` would run;
forgetting it produced a bare "qemu-system-* not found". Make a BSP build
bootstrap the emulator instead.

build.sh now, before building bsp-so3/bsp-linux on virt32/virt64, checks for
qemu/build/qemu-system-<arch> and runs `bitbake qemu` first when it is absent.
It is a bootstrap only: an already-built emulator is left untouched, so the
inner build loop pays nothing and the qemu-hacking loop stays the explicit
`build.sh -x qemu`. Hardware platforms (verdin, rpi4) never run under QEMU and
are skipped. Opt out with IB_BUILD_QEMU="0".

The check lives in build.sh, not a bitbake dependency: a parse-time
os.path.exists() is not part of bitbake's parse-cache key (so it goes stale),
and qemu's do_build is nostamp (so a hard dependency would reconfigure+rebuild
qemu on every BSP build). A wrapper check reads the real FS state each run.

CI sets IB_BUILD_QEMU="0" (it only builds+deploys, never runs the emulator);
the lvperf Dockerfiles drop the now-redundant `build.sh -x qemu` step. Docs and
local.conf document the knob.
The attach guard's "local modifications not captured" branch called bbwarn
and bbfatal, which are not defined as shell functions in the task
environment, so the branch exited 127 (command not found) — turning the
intended diagnostic into a hard task failure with no message printed. Use
echo to stderr for the warning and echo + exit 1 for the abort, matching the
codebase convention (bb* shell logging helpers are unavailable here).
@daniel-rossier
daniel-rossier merged commit c20f642 into main Jul 16, 2026
6 checks passed
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