Makefile.win: definitions and objects agree, and imm32 links

Two kinds of drift a direct mingw build tripped over, found while
building the audit lane. DEFINES has carried -DHAVE_OVERLAY since
before the object list moved to Makefile.common, which keys off the
make variables: the define without the variable compiled overlay
callers against overlay objects that were never built, and
screenshots without HAVE_RPNG could not encode - both surfacing as
undefined references at link. The variables are now set where the
other HAVE_ ones are, so definitions and objects agree again.

And win32_common.c pulls imm32 with #pragma comment(lib), which
MSVC honours and GNU ld silently ignores, leaving the IME
composition calls undefined; the library is now on LIBS explicitly.

The audit lane script drops both of its compensations - the
variable overrides and the manual relink that appended imm32 - and
its plain make now compiles and links the audit subject in one
step, which is the fix demonstrating itself.

Verified: a clean cross build linking through the makefile's own
rule, and the PE audit at its standing zero findings.
This commit is contained in:
LibretroAdmin authored and libretroadmin committed 2026-09-16 13:28:35 +02:00
1 parent 85ee5c9fe7
commit e9d708f269
2 files changed
+16 -9

No files matched your search

+12 -1
View File
@@ -1,6 +1,14 @@
TARGET = retroarch.exe
HAVE_SCREENSHOTS = 1
# DEFINES below has carried -DHAVE_OVERLAY since before the object
# list moved to Makefile.common, which keys off these variables: the
# define without the variable compiled overlay callers against
# overlay objects that were never built, and screenshots without
# rpng could not encode. Set the variables so definitions and
# objects agree again.
HAVE_OVERLAY = 1
HAVE_RPNG = 1
HAVE_AUDIOMIXER = 1
HAVE_RWAV = 1
HAVE_DINPUT = 1
@@ -95,7 +103,10 @@ OBJDIR := obj-w32
OS := Win32
OBJ :=
LIBS := -lm
# imm32: win32_common.c pulls it with #pragma comment(lib), which
# MSVC honours and GNU ld silently ignores - link it explicitly or
# the IME composition calls are undefined under mingw.
LIBS := -lm -limm32
DEFINES :=
DEFINES += -I. -Ilibretro-common/include -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DHAVE_OVERLAY
LDFLAGS := -L. -static-libgcc
+4 -8
View File
@@ -8,10 +8,8 @@
# from older mingw-w64 (d3dkmthk.h; the unversioned d3d12 serialize
# PFN; three D3D interface names mapped to IUnknown - layout is
# irrelevant, only call edges are read), and imm32 is appended by
# relinking manually because Makefile.win assigns LIBS with := so no
# variable reaches the link from outside. HAVE_OVERLAY and HAVE_RPNG
# are set because Makefile.win's DEFINES already assume them while
# the object list keys off the make variables.
# (Makefile.win now links imm32 and sets HAVE_OVERLAY/HAVE_RPNG
# itself, so this script no longer compensates for either.)
# Usage: tools/mingw-audit-build.sh (then:)
# python3 tools/thread_read_audit.py --binary retroarch.exe \
# --objdump x86_64-w64-mingw32-objdump
@@ -22,8 +20,6 @@ export CFLAGS="-I$STUBS -include $STUBS/d3d12_fixup.h \
-DID3D12InfoQueue=IUnknown -DD3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP=17"
MK="make -f Makefile.win HOST_PREFIX=x86_64-w64-mingw32- \
CXX=x86_64-w64-mingw32-gcc HAVE_D3D11=1 HAVE_D3D12=1 HAVE_FREETYPE=0 \
HAVE_CG=0 HAVE_XAUDIO=0 HAVE_OVERLAY=1 HAVE_RPNG=1"
$MK -j"$(nproc)" || true # everything except the exe rule's link
$MK -n 2>/dev/null | grep "o retroarch.exe" | head -1 \
| sed 's/$/ -limm32/' | sh
HAVE_CG=0 HAVE_XAUDIO=0"
$MK -j"$(nproc)"
ls -la retroarch.exe