perf(build): give the Android NDK build the release optimisation flags

jni/Android.mk includes only Makefile.common, never the project Makefile,
so ndk-build never picked up any of the desktop release flags: no -O3, no
-DNDEBUG, and none of the visibility/interposition flags added to the
desktop ELF targets in the previous commit.

Add -O3 -DNDEBUG -fvisibility=hidden -fno-stack-protector
-fomit-frame-pointer -fno-semantic-interposition to COREFLAGS by hand,
with a comment explaining why Android needs its own copy. The vjchdr
static module's LOCAL_CFLAGS already composes from $(COREFLAGS), so it
picks up the new flags for free with no further change. LOCAL_LDFLAGS
already pins the production link.T version script, same as every other
ELF target, so -fvisibility=hidden is safe alongside it: libretro.h
declares every retro_* entry point RETRO_API (visibility("default")), so
those symbols stay exported.

No local Android NDK is available to build against in this environment;
see the task report for the reasoning on why LOCAL_CFLAGS's -O3 should
still win over ndk-build's own default (last-flag-wins, same mechanism
already relied on throughout the desktop Makefile) and for the CI job
that will be the first real exercise of this change.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Joseph MattielloandClaude Fable 5 committed 2026-08-22 06:22:59 -04:00
1 parent 06a8c65b70
commit f995fa0964
1 file changed
+14 -1
+14 -1
View File
@@ -38,7 +38,20 @@ include $(CORE_DIR)/Makefile.common
# arch .c compiles. Without it blitter.c falls back to the scalar inline
# set -- which links fine against the neon/sse2 vtable and just runs
# slower, so nothing would catch its absence at build time.
COREFLAGS := -DINLINE="inline" -D__LIBRETRO__ $(INCFLAGS) $(BLITTER_SIMD_DEFINE)
#
# -O3 -DNDEBUG -fvisibility=hidden -fno-stack-protector
# -fomit-frame-pointer -fno-semantic-interposition: the release
# optimisation/visibility flags from the desktop Makefile (issue #569),
# added by hand because ndk-build never includes Makefile -- only
# Makefile.common -- so without this line Android inherited none of
# them and built at whatever default APP_OPTIM/-O ndk-build picks.
# LOCAL_LDFLAGS below already pins the production link.T version
# script, same as every other ELF target; -fvisibility=hidden is safe
# alongside it because libretro.h declares every retro_* entry point
# RETRO_API (visibility("default")), so those symbols stay exported.
COREFLAGS := -DINLINE="inline" -D__LIBRETRO__ $(INCFLAGS) $(BLITTER_SIMD_DEFINE) \
-O3 -DNDEBUG -fvisibility=hidden -fno-stack-protector \
-fomit-frame-pointer -fno-semantic-interposition
# libretro.c includes the generated src/core/version.h. Generate it
# at parse time -- ndk-build doesn't go through the project Makefile,