Skip to content

fix(cores): build mGBA with cmake, and unpin fceumm onto the fixed patch - #28

Merged
lepht merged 1 commit into
mainfrom
claude/adopt-upstream-799-core-builds
Aug 12, 2026
Merged

fix(cores): build mGBA with cmake, and unpin fceumm onto the fixed patch#28
lepht merged 1 commit into
mainfrom
claude/adopt-upstream-799-core-builds

Conversation

@lepht

@lepht lepht commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Clears the last two unchecked boxes in #16. Adopted from upstream LoveRetro/NextUI#799 by @pvaibhav.

The point

Both cores were pinned backwards to dodge upstream drift. That was a holding action, and #16 said so at the time. This is the actual fix, so the pins move forwards instead.

⚠️ The patches and the pins have to move together. Adopting the new patch files while keeping the old pins produces a guaranteed break, because each rewritten patch targets exactly the upstream change its pin was chosen to avoid.

mgba — cmake

libretro/mgba deleted Makefile.libretro in 8940477 when its CI moved to cmake, and patches/mgba.patch existed only to add a platform block to that file. So the patch is deleted outright and the same compiler flags now go to cmake directly via mgba_MAKE, with mgba_CORE pointing into the build dir.

Pinned to e31759b (2026-08-05), verified: cmake-only, exposes BUILD_LIBRETRO / LIBMGBA_ONLY / LIBRETRO_STATIC, and builds target mgba_libretro with PREFIX "" and no LIBRARY_OUTPUT_DIRECTORY — so the .so lands where mgba_CORE expects it.

This adds cmake as a build dependency for one core. I checked rather than assumed: cmake is installed in the tg5040-toolchain Dockerfile, which also ships an aarch64 cross-compile toolchain file. Core builds run inside that container, not on the runner.

fceumm — forwards past the drift

The rewritten patch targets the post-8ed0cb2 Makefile.libretro (the commit that replaced bundled zlib), so it cannot apply to the commit we pinned to avoid it. Pinned to b5e3566, whose Makefile.libretro blob is the exact pre-image the patch was written against.

Verified with #16's own method — fetch the commit, git apply --check both platform patches:

pin tg5040 tg5050
becde7dc (old) ✗ fails at line 458 ✗ fails at line 458
b5e3566 (new) ✓ applies clean ✓ applies clean

One deviation from upstream

Their mgba_MAKE ends -- $(PROCS), but the shared rule in all/cores/makefile already appends $(PROCS), expanding to -- -j4 -j4. Dropped ours and kept the --, so -j4 still reaches the native build tool rather than becoming a cmake flag (which would add a CMake ≥3.12 requirement). Upstream has the same duplication and may want the same fix.

Testing

Dry-ran the makefile expansion on both platforms — pin checkout, the now-skipped patch step, the cmake invocation, and the final mv all resolve correctly.

Not built for ARM here. There's no container runtime in this environment, so the cmake cross-compile itself is unproven on our side; CI is the real gate on that.

Why now

Upstream is mid-transition from GPL-3.0 to PolyForm Noncommercial (LoveRetro/NextUI#765). Their LICENSE is still GPL-3.0 today, so this is adoptable now; code taken after the transition would not be. Original authorship is preserved in the commit trailer.

Adopted from upstream LoveRetro#799 by Prashant Vaibhav, taken while
upstream is still GPL-3.0 (see LoveRetro#765). Clears the last two
boxes in #16.

Both cores were pinned backwards to dodge upstream drift. That was a holding
action; this is the real fix, so the pins move forwards instead.

mgba: libretro/mgba deleted Makefile.libretro in 8940477 when its CI moved to
cmake, and patches/mgba.patch existed only to add a platform block to that
file. The patch is deleted and the same flags now go to cmake directly via
mgba_MAKE, with mgba_CORE pointing at the build dir. Pinned to e31759b
(2026-08-05), verified cmake-only, exposing BUILD_LIBRETRO / LIBMGBA_ONLY /
LIBRETRO_STATIC and building target mgba_libretro. cmake is present in the
toolchain image, which also ships an aarch64 cross toolchain file.

fceumm: the rewritten patch targets the post-8ed0cb2 Makefile.libretro, so it
cannot apply to the commit we pinned to avoid that change. Pinned to b5e3566,
whose Makefile.libretro blob is the exact pre-image the patch was written
against. Verified per #16's method - `git apply --check` at the new pin passes
for both tg5040 and tg5050, and fails at the old pin, so patch and pin have to
move together.

Deviation from upstream: their mgba_MAKE ends `-- $(PROCS)`, but the shared
rule in all/cores/makefile already appends $(PROCS), which expanded to
`-- -j4 -j4`. Dropped ours, keeping the `--` so -j4 still reaches the native
build tool rather than becoming a cmake flag.

Not built for ARM here - no container runtime in this environment - so the
cmake cross-compile itself is still unproven on our side. CI covers it.

Co-Authored-By: Prashant Vaibhav <prashant@vaibhav.de>
@lepht
lepht merged commit 7054a42 into main Aug 12, 2026
63 checks passed
@lepht
lepht deleted the claude/adopt-upstream-799-core-builds branch August 12, 2026 04:30
lepht pushed a commit that referenced this pull request Aug 12, 2026
Brings in the three upstream adoptions (#26, #27, #28) now on main.

One conflict, in the scroll-text block of nextui.c. Both sides edited
adjacent lines for unrelated reasons:

  - this branch added SCREEN_CONTEXTMENU to the outer screen exclusion list
  - #27 added a total>0 guard to the inner condition

Resolved as the union of both, which is the only correct answer here.
Taking ours alone drops total>0 and reopens #6 two lines above the
top->entries->items[top->selected] read; taking theirs alone drops the
context menu exclusion and renders scroll text over it.

Git auto-merged the other five guard sites #27 added. Verified after the
merge: no assert(entry) remains, every read of entries->items[top->selected]
sits behind a count or total>0 check, nextui.c is syntax-clean against the
desktop platform headers, and make test passes.
lepht pushed a commit that referenced this pull request Aug 12, 2026
Carries the main merge (and with it #26, #27, #28) up the stack.

Same single conflict as one level down, in the same two lines of nextui.c:
this branch had added SCREEN_SEARCH to the outer screen exclusion list on
top of SCREEN_CONTEXTMENU, while #27 added a total>0 guard to the inner
condition. Resolved as the union again - all four screen exclusions kept,
total>0 kept.

Verified after the merge: no assert(entry) remains, every read of
entries->items[top->selected] is guarded, nextui.c is syntax-clean against
the desktop platform headers, and make test passes.
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