Skip to content

fix(build): bootstrap libraries before compiling emu#163

Open
Ticed wants to merge 1 commit intoNERVsystems:masterfrom
Ticed:fix/macos-build-bootstrap
Open

fix(build): bootstrap libraries before compiling emu#163
Ticed wants to merge 1 commit intoNERVsystems:masterfrom
Ticed:fix/macos-build-bootstrap

Conversation

@Ticed
Copy link
Copy Markdown

@Ticed Ticed commented Apr 4, 2026

Summary

On a fresh clone, the macOS build scripts fail because the required libraries
are not built before the emulator is compiled. The linker then cannot find the
.a files, and the build exits with no such file or directory errors.

Changes

  • Added a library build loop, creation of the missing target lib directory, and
    mk/Limbo pre-checks to build-macos-headless.sh,
    build-macos-sdl3.sh, and tests/host/build_test.sh.
  • Exported SYSTARG=MacOSX in the macOS build scripts and
    tests/host/build_test.sh, and SYSTARG=Linux in
    build-linux-arm64.sh.
  • Added the devprof.$O: $RUNT dependency in emu/port/portmkfile so it is
    recompiled when runt.h changes.
  • Fixed a path typo (MacOSX/arm64/bin instead of X/arm64/bin) in
    QUICKSTART.md.

Why

The macOS build scripts skip the library build and directory creation steps, so
they fail on a clean checkout where the .a files have not yet been generated.
This creates inconsistent behavior across platforms, since the self-contained
Linux build scripts already handle this correctly.

Verification

export ROOT=$PWD
export PATH=$PWD/MacOSX/arm64/bin:$PATH

# Simulate a fresh clone: remove libraries, .o files, and generated headers
mv MacOSX/arm64/lib MacOSX/arm64/lib.bak
for d in lib9 libbio libmp libsec libmath libmemdraw libmemlayer libdraw libinterp libkeyring; do
    [ -d "$d" ] && (cd "$d" && mk nuke 2>/dev/null || true)
done
rm -f libinterp/runt.h
(cd emu/MacOSX && mk clean 2>/dev/null || true)

./build-macos-headless.sh
./emu/MacOSX/o.emu -r. /tests/hello_test.dis

touch libinterp/runt.h
(cd emu/MacOSX && mk GUIBACK=headless 2>&1 | grep devprof)

On a fresh clone, macOS build scripts fail because the emulator is compiled without first building the required libraries. The linker cannot find the .a files and the build exits with "no such file or directory" errors.

Add the library build loop and mk/limbo pre-checks to build-macos-headless.sh, build-macos-sdl3.sh, and
build_test.sh. Export SYSTARG in the macOS and Linux ARM64 build scripts.

Add the devprof.$O on $RUNT dependency in portmkfile. Without it ,mk does not generate runt.h before compiling devprof.c, causing a missing-header failure on build.

Fix path typo in QUICKSTART.md.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 4, 2026

Copy link
Copy Markdown

@pdfinn pdfinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Ticed, thanks for this — really appreciate you taking the time to dig into the build system and put together a fix. This is a real problem: the macOS build scripts aren't self-contained like the Linux one, and a fresh clone + ./build-macos-headless.sh shouldn't leave someone staring at linker errors.

Two of these fixes are clean and I'd like to get them merged right away:

  • QUICKSTART.md typo — good catch, X/arm64/binMacOSX/arm64/bin
  • devprof.$O: $RUNT in portmkfiledevprof.c includes runt.h but was missing the dependency. Correct fix.

For the library bootstrap, I have a few suggestions before we merge that part:

  1. libfreetype doesn't need to be built. If you look at the emu/MacOSX/emu config, freetype is commented out in the lib section — it's not linked into either headless or SDL3 builds. Building it is harmless but unnecessary.

  2. The SYSTARG export is redundant. mkconfig already sets SYSTARG=$SYSHOST, so the build system picks it up automatically. No harm done, but it's not needed.

  3. The library loop is duplicated across three files. Identical 23-line blocks in build-macos-headless.sh, build-macos-sdl3.sh, and build_test.sh will be a maintenance headache. Would you be open to extracting that into a shared script (something like scripts/bootstrap-libs.sh) that all three source? Our CI already handles this as discrete steps — take a look at the macos-arm64 job in .github/workflows/ci.yml for how we structure the build order.

Suggestion: Would you be up for splitting this into two PRs? I can merge the QUICKSTART + portmkfile fixes right now, and we can iterate on the bootstrap work separately. That way the good stuff lands immediately. Happy to help with the shared-script approach if you want to pair on it.

One more thing — the QUICKSTART and portmkfile fixes are really upstream improvements that would benefit all InferNode users. Would you consider submitting those to infernode-os/infernode as well? That's the canonical repo; our fork here carries product-specific changes. Totally fine to keep the bootstrap PR here since it's about our macOS build scripts specifically.

Thanks again for contributing — finding the devprof dependency and the QUICKSTART typo shows you were reading carefully.

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.

2 participants