Files
virtualjaguar-libretro/Makefile.common
T
Joseph MattielloandClaude Sonnet 5.5 e873883e33 feat(debug): core side of the app debug interface (vjdebug.c) with socket-less halt pump
src/debug/vjdebug.c implements struct vj_debug_iface: side-effect-free peek
(JaguarReadByte DEBUGGER), policy-checked poke, both RISC register banks, RISC
disassembly, attach/halt-pump/breakpoints on the existing GDB halt machinery
(a host can attach without a socket; GDBHalt pumps it and never blocks when
nothing could resume it), a one-walk OP display-list snapshot taken before the
OP rewrites HEIGHT/DATA, a blitter launch log ring, TexReplaceReload, and the
frame counter.

The interface is handed over once via VJ_ENV_SET_DEBUG_IFACE, only to a
frontend that set VJ_CAP_DEBUG (RetroArch never does).  Detached cost: one
global test per OPProcessList call and one per blitter launch.  Statics reset
on unload and deinit.

test/test_debug_iface.c drives it on yarc.j64: who gets the interface, peek ==
jaguarMainRAM, the poke policy, halt/step/continue/detach through a scripted
host, breakpoint re-hit, OP snapshot, blit log, and an identical frame + RAM
hash with everything switched on.

Refs #652 Refs #833

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-13 20:23:06 -04:00

282 lines
11 KiB
Makefile

LIBRETRO_COMM_DIR = $(CORE_DIR)/libretro-common
LIBCHDR_DIR := $(CORE_DIR)/deps/libchdr
INCFLAGS := -I$(CORE_DIR) \
-I$(CORE_DIR)/src \
-I$(CORE_DIR)/src/core \
-I$(CORE_DIR)/src/tom \
-I$(CORE_DIR)/src/jerry \
-I$(CORE_DIR)/src/cd \
-I$(CORE_DIR)/src/bios \
-I$(CORE_DIR)/src/m68000 \
-I$(CORE_DIR)/src/debug \
-I$(LIBRETRO_COMM_DIR)/include \
-I$(LIBCHDR_DIR)/include \
-I$(LIBCHDR_DIR)/deps/lzma-25.01/include \
-I$(LIBCHDR_DIR)/deps/miniz-3.1.1 \
-I$(LIBCHDR_DIR)/deps/zstd-1.5.7
# libchdr is C99 (vendored). Compiled as its own translation unit
# (unity.c) with -std=c99; see the unity.o rule in the Makefile.
# _7ZIP_ST is the LZMA single-thread decode config libchdr expects.
# -std=c99 / -Wno-* are GCC/Clang only; cl.exe rejects both.
# MINIZ_DEFLATE_APIS restores miniz's compressor (unity.c disables it
# with MINIZ_NO_DEFLATE_APIS behind an #ifndef guard, precisely so
# dependents can turn it back on): texture dump (src/tom/texdump.c,
# issue #369) calls tdefl_write_image_to_png_file_in_memory_ex for its
# preview PNGs. Lives here rather than on the unity.o rule alone so the
# theos_ios path, which compiles unity.c without that rule, gets it too.
LIBCHDR_CFLAGS := -D_7ZIP_ST -DMINIZ_DEFLATE_APIS \
-DWANT_RAW_DATA_SECTOR=1 -DWANT_SUBCODE=1 -DVERIFY_BLOCK_CRC=1
ifeq (,$(findstring msvc,$(platform)))
LIBCHDR_CFLAGS += -std=c99
LIBCHDR_WARNFLAGS := -Wno-unused-function -Wno-unused-variable
else
LIBCHDR_WARNFLAGS :=
endif
SOURCES_LIBCHDR := $(LIBCHDR_DIR)/unity.c
ifneq (,$(findstring msvc2003,$(platform)))
INCFLAGS += -I$(LIBRETRO_COMM_DIR)/include/compat/msvc
endif
SOURCES_CXX :=
SOURCES_C := \
$(CORE_DIR)/libretro.c \
$(CORE_DIR)/src/tom/blit_memo.c \
$(CORE_DIR)/src/tom/blitter.c \
$(CORE_DIR)/src/tom/blitter_compare.c \
$(CORE_DIR)/src/tom/blitter_mmio.c \
$(CORE_DIR)/src/jerry/dac.c \
$(CORE_DIR)/src/jerry/dsp.c \
$(CORE_DIR)/src/core/file.c \
$(CORE_DIR)/src/tom/gpu.c \
$(CORE_DIR)/src/core/jaguar.c \
$(CORE_DIR)/src/jerry/jerry.c \
$(CORE_DIR)/src/jerry/jlink.c \
$(CORE_DIR)/src/jerry/jlink_tcp.c \
$(CORE_DIR)/src/jerry/jlink_discover.c \
$(CORE_DIR)/src/jerry/jlink_netpacket.c \
$(CORE_DIR)/src/jerry/voicemodem.c \
$(CORE_DIR)/src/jerry/voicechat.c \
$(CORE_DIR)/src/jerry/uart.c \
$(CORE_DIR)/src/tom/op.c \
$(CORE_DIR)/src/tom/shadowfb.c \
$(CORE_DIR)/src/tom/texdump.c \
$(CORE_DIR)/src/tom/texreplace.c \
$(CORE_DIR)/src/tom/tom.c \
$(CORE_DIR)/src/cd/cdintf.c \
$(CORE_DIR)/src/cd/cdrom.c \
$(CORE_DIR)/src/cd/jagcd_bios.c \
$(CORE_DIR)/src/cd/jagcd_cart.c \
$(CORE_DIR)/src/cd/jagcd_hle.c \
$(CORE_DIR)/src/core/biosdb.c \
$(CORE_DIR)/src/core/bus_arbiter.c \
$(CORE_DIR)/src/core/cheat.c \
$(CORE_DIR)/src/core/crc32.c \
$(CORE_DIR)/src/core/perf_counters.c \
$(CORE_DIR)/src/core/perf_iface.c \
$(CORE_DIR)/src/core/crash_detect.c \
$(CORE_DIR)/src/core/event.c \
$(CORE_DIR)/src/jerry/eeprom.c \
$(CORE_DIR)/src/core/filedb.c \
$(CORE_DIR)/src/core/titledb.c \
$(CORE_DIR)/src/core/titlehook.c \
$(CORE_DIR)/src/core/hookfile.c \
$(CORE_DIR)/src/m68000/cpustbl.c \
$(CORE_DIR)/src/m68000/cpudefs.c \
$(CORE_DIR)/src/m68000/cpuemu.c \
$(CORE_DIR)/src/m68000/cpuextra.c \
$(CORE_DIR)/src/m68000/m68kinterface.c \
$(CORE_DIR)/src/m68000/readcpu.c \
$(CORE_DIR)/src/bios/jagbios.c \
$(CORE_DIR)/src/bios/jagbios_m.c \
$(CORE_DIR)/src/bios/jagcdbios.c \
$(CORE_DIR)/src/bios/jagdevcdbios.c \
$(CORE_DIR)/src/jerry/joystick.c \
$(CORE_DIR)/src/jerry/quadrature.c \
$(CORE_DIR)/src/jerry/axistune.c \
$(CORE_DIR)/src/jerry/inputdev.c \
$(CORE_DIR)/src/jerry/paddle.c \
$(CORE_DIR)/src/core/settings.c \
$(CORE_DIR)/src/core/memtrack.c \
$(CORE_DIR)/src/core/jaggd.c \
$(CORE_DIR)/src/core/jaggd_fs.c \
$(CORE_DIR)/src/core/nvmbios.c \
$(CORE_DIR)/src/core/vjag_memory.c \
$(CORE_DIR)/src/core/vjtrace.c \
$(CORE_DIR)/src/core/vj_frontend_ext.c \
$(CORE_DIR)/src/core/universalhdr.c \
$(CORE_DIR)/src/jerry/wavetable.c \
$(CORE_DIR)/src/debug/gdbstub.c \
$(CORE_DIR)/src/debug/gdbtarget.c \
$(CORE_DIR)/src/debug/vjdebug.c \
$(CORE_DIR)/src/debug/gdbsock.c
# SIMD-accelerated blitter operations: select arch-specific implementation.
# BLITTER_SIMD may be set explicitly to one of: scalar, sse2, neon.
BLITTER_SIMD_SRC :=
ifneq ($(BLITTER_SIMD),)
ifeq (,$(filter scalar sse2 neon,$(BLITTER_SIMD)))
$(error Unsupported BLITTER_SIMD '$(BLITTER_SIMD)'; expected one of: scalar sse2 neon)
endif
endif
ifeq ($(BLITTER_SIMD),sse2)
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_sse2.c
else ifeq ($(BLITTER_SIMD),neon)
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_neon.c
else ifeq ($(BLITTER_SIMD),scalar)
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_scalar.c
else
# Derive ARCH from the toolchain triple when the platform block did not set
# it. Issue #560.
#
# The rules below key on $(ARCH); the native `uname -m` fallback further
# down is deliberately skipped for cross-compilers (BLITTER_CROSS_CC); and
# no platform block sets ARCH for a generic `platform=unix` cross-build. So
# a cross-compiled aarch64 build matched nothing and fell through to the
# SCALAR blitter on hardware where NEON is architecturally mandatory. The
# guard written to prevent false detection was, by itself, forcing the slow
# path.
#
# NOT the official Linux ARM64 cores, to be clear: both the GitLab buildbot
# (ci-templates linux-aarch64.yml, `tags: aarch64`) and the GitHub
# release/nightly matrix row build NATIVELY with plain `gcc`, so `uname -m`
# fired and they always had NEON. This hits cross-builds -- distro
# packagers, container cross-compiles, anyone following a cross recipe.
#
# Only aarch64 is inferred. A 32-bit arm-*-gnueabihf triple says nothing
# about NEON (the armhf baseline is VFP; ARMv6 parts such as the Pi 1 and
# Zero have no NEON at all), so those keep falling through to scalar rather
# than guessing. Set HAVE_NEON=1 by hand for an armv7 toolchain you know.
ifeq ($(ARCH),)
ifneq (,$(findstring aarch64-,$(CC)))
ARCH := aarch64
endif
endif
# ARM targets: prefer NEON when guaranteed or explicitly enabled.
ifeq ($(HAVE_NEON), 1)
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_neon.c
endif
ifneq (,$(filter ios-arm64 tvos-arm64,$(platform)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_neon.c
endif
# aarch64/arm64 always have NEON; plain 'arm' may lack it.
ifneq (,$(filter aarch64 arm64,$(ARCH)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_neon.c
endif
# armv8+ implies NEON; armv7/armhf only use NEON if HAVE_NEON was set above.
ifneq (,$(filter arm64 armv8%,$(platform)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_neon.c
endif
# x86/x64 targets: use SSE2.
ifneq (,$(filter x86_64 x86 i686 i386,$(ARCH)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_sse2.c
endif
ifneq (,$(filter x86_64 x86 i686 i386 win-x64 win32,$(platform)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_sse2.c
endif
# MSYS2/MinGW
ifneq (,$(filter MINGW64% MINGW32%,$(MSYSTEM)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_sse2.c
endif
# MSVC. None of the matches above ever fire for these -- the platform
# strings are windows_msvc*, ARCH is unset -- so every MSVC core used
# to fall through to scalar. x64 has SSE2 in the ABI baseline, and
# MSVC 2015/2017 x86 already compiles to /arch:SSE2 by default, so
# neither adds a runtime CPU requirement.
#
# Spelled out one platform at a time rather than matched with
# findstring: several MSVC platform names must NOT land here.
# windows_msvc2017_*_arm, *_arm64 -- no x86 intrinsics at all
# xbox1_msvc2003 -- Pentium III: SSE, but no SSE2
# windows_msvc2010_*, -- C89-only C mode plus the
# windows_msvc2005_x86, _MSC_VER < 1700 SSE2_SET64
# windows_msvc2003_x86 path; the msvc-check CI job
# runs VS2022 and cannot verify
# either, so they stay scalar.
# No -msse2 for any of these -- cl.exe doesn't take it; see the flag
# block below.
MSVC_SSE2_PLATFORMS := \
windows_msvc2017_desktop_x64 windows_msvc2017_desktop_x86 \
windows_msvc2017_uwp_x64 windows_msvc2017_uwp_x86 \
windows_msvc2015_x64 windows_msvc2015_x86
ifneq (,$(filter $(MSVC_SSE2_PLATFORMS),$(platform)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_sse2.c
endif
# Native build fallback: auto-detect from host architecture, but only for
# native-build platforms (unix/osx/win). Cross-compile targets (vita, ps3,
# libnx, etc.) set platform explicitly and should not use host detection.
# Also skip when CC looks like a cross-compiler (e.g. arm-webos-linux-gnueabi-gcc).
BLITTER_CROSS_CC := $(findstring arm-,$(CC))$(findstring aarch64-,$(CC))$(findstring mips,$(CC))$(findstring powerpc,$(CC))
ifeq ($(BLITTER_SIMD_SRC),)
ifeq ($(BLITTER_CROSS_CC),)
ifneq (,$(filter unix osx win,$(platform)))
ifneq (,$(filter x86_64 i686 i386,$(shell uname -m 2>/dev/null)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_sse2.c
endif
ifneq (,$(filter aarch64 arm64,$(shell uname -m 2>/dev/null)))
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_neon.c
endif
endif
endif
endif
endif
# Fall back to scalar if no SIMD was selected (e.g., exotic platforms)
ifeq ($(BLITTER_SIMD_SRC),)
BLITTER_SIMD_SRC := $(CORE_DIR)/src/tom/blitter_simd_scalar.c
endif
SOURCES_C += $(BLITTER_SIMD_SRC)
# Tell blitter_simd.h which implementation header to inline into
# blitter.c. This must agree with the .c file selected above; if it
# doesn't, that .c fails to compile (duplicate definitions) instead of
# quietly running one impl while the vtable test validates another.
#
# Kept in its own variable because jni/Android.mk builds its own flag
# set from scratch (COREFLAGS) and never sees $(CFLAGS) -- it needs this
# define and nothing else from here.
ifeq ($(BLITTER_SIMD_SRC),$(CORE_DIR)/src/tom/blitter_simd_sse2.c)
BLITTER_SIMD_DEFINE := -DBLITTER_SIMD_SSE2
else ifeq ($(BLITTER_SIMD_SRC),$(CORE_DIR)/src/tom/blitter_simd_neon.c)
BLITTER_SIMD_DEFINE := -DBLITTER_SIMD_NEON
else
BLITTER_SIMD_DEFINE := -DBLITTER_SIMD_SCALAR
endif
CFLAGS += $(BLITTER_SIMD_DEFINE)
# Add -msse2 flag for all GCC/Clang SSE2 builds. No-op on x86_64 (baseline),
# required on i686 / gcc -m32. Skip for MSVC (uses /arch:SSE2, not -msse2).
ifeq ($(BLITTER_SIMD_SRC),$(CORE_DIR)/src/tom/blitter_simd_sse2.c)
ifeq (,$(findstring msvc,$(platform)))
CFLAGS += -msse2
endif
endif
ifneq ($(STATIC_LINKING), 1)
SOURCES_C += \
$(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \
$(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \
$(LIBRETRO_COMM_DIR)/compat/compat_snprintf.c \
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c \
$(LIBRETRO_COMM_DIR)/compat/compat_posix_string.c \
$(LIBRETRO_COMM_DIR)/compat/fopen_utf8.c \
$(LIBRETRO_COMM_DIR)/streams/file_stream.c \
$(LIBRETRO_COMM_DIR)/streams/file_stream_transforms.c \
$(LIBRETRO_COMM_DIR)/string/stdstring.c \
$(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.c \
$(LIBRETRO_COMM_DIR)/file/file_path.c \
$(LIBRETRO_COMM_DIR)/file/file_path_io.c \
$(LIBRETRO_COMM_DIR)/time/rtime.c
endif