build: Make libFLAC optional and off by default; rflac is the default

FLAC decoding no longer has any consumer of libFLAC: the audio
mixer decodes through rflac (HAVE_RFLAC) and libchdr's CHD FLAC
codec was ported to rflac as well. The libFLAC dependency -
whether the bundled copy under deps/libFLAC (HAVE_BUILTINFLAC)
or the system library (-lFLAC) - was compiled and linked into
default builds without a single call site.

qb/configure:
- HAVE_FLAC now defaults to 'no' and means only 'link/build the
  libFLAC library'; it can still be opted into with
  --enable-flac (system library, probed) or together with
  --enable-builtinflac (bundled sources, no probe).
- New HAVE_RFLAC option, default 'yes' - native FLAC decode for
  the audio mixer and CHD.
- --enable-builtinflac now works on systems without libFLAC
  headers: builtin implies HAVE_FLAC without running the system
  library probe (previously the probe could not be reached with
  flac disabled, and force-enabling flac hard-failed without
  the system package). Explicitly contradictory
  --disable-flac --enable-builtinflac errors out.

Makefile.common:
- Standalone HAVE_RFLAC block supplies -DHAVE_RFLAC, rflac.o
  and audio_transfer.o; all five audio_transfer.o
  deduplication chains (RMP3, RMODTRACKER, ROPUS, RVORBIS,
  BUILTINFLAC) and the BUILTINFLAC block's own rflac additions
  are guarded so every flag combination yields exactly one copy
  of each object.
- The CHD block gates libchdr_flac.o/libchdr_flac_codec.o on
  HAVE_FLAC or HAVE_RFLAC, with the rflac.o addition guarded
  against both other providers.

Sources:
- The nine CHD FLAC codec guards in libchdr_chd.c and the
  libchdr_flac includes in griffin.c change from HAVE_FLAC to
  defined(HAVE_FLAC) || defined(HAVE_RFLAC). The compatible
  form is deliberate: static platform Makefiles (e.g. webos)
  that only define the legacy flags retain CHD FLAC unchanged.

Apple (all xcodeprojs / xcconfig):
- BaseConfig.xcconfig: -DHAVE_FLAC replaced by -DHAVE_RFLAC;
  -DFLAC__HAS_OGG=0 and the libFLAC header search path removed.
- RetroArch_Metal / RetroArch / RetroArch_OSX107 project files:
  same define swap where locally specified, FLAC__HAS_OGG and
  all deps/libFLAC include paths removed.
- All Apple targets build through griffin, so dropping
  HAVE_FLAC removes the libFLAC translation units automatically
  and adding HAVE_RFLAC additionally enables audio mixer FLAC
  playback, which the Apple builds previously lacked.

Verification (x86_64 Linux, qb):
- Configure matrix: default / --enable-builtinflac /
  --enable-flac / both / contradictory / --disable-rflac all
  resolve or error as intended.
- Object matrix across seven flag combinations (make database
  dump): exactly one rflac.o and one audio_transfer.o in every
  combination that wants them; deps/libFLAC objects present
  only under BUILTINFLAC.
- Default configure builds and links: 38 rflac_* symbols, zero
  FLAC__stream_* symbols, CHD FLAC codec present, no libFLAC in
  the link, binary runs.
- --enable-builtinflac full build links clean with no duplicate
  symbol errors (libFLAC and the standalone rflac block
  coexist).

Apple project edits are mechanical flag/path changes and are
not build-tested here; they should get a CI or local Xcode
pass. The stray -DHAVE_DR_FLAC in the Apple configs has no
source consumers but is left untouched as out of scope.
This commit is contained in:
libretroadmin authored and libretroadmin committed 2026-07-22 19:51:51 +02:00
1 parent 9e480fe1c6
commit 04b398f06e
9 files changed
+51 -39

No files matched your search

+23 -4
View File
@@ -235,12 +235,14 @@ endif
ifeq ($(HAVE_RMP3), 1)
DEFINES += -DHAVE_RMP3
OBJ += $(LIBRETRO_COMM_DIR)/formats/mp3/rmp3.o
ifneq ($(HAVE_RFLAC),1)
ifneq ($(HAVE_BUILTINFLAC),1)
ifneq ($(HAVE_RVORBIS),1)
OBJ += $(LIBRETRO_COMM_DIR)/formats/audio_transfer.o
endif
endif
endif
endif
OBJ += frontend/frontend_driver.o \
retroarch.o \
@@ -2059,6 +2061,7 @@ endif
ifeq ($(HAVE_RMODTRACKER), 1)
DEFINES += -DHAVE_RMODTRACKER
OBJ += $(LIBRETRO_COMM_DIR)/formats/mod/rmodtracker.o
ifneq ($(HAVE_RFLAC),1)
ifneq ($(HAVE_BUILTINFLAC),1)
ifneq ($(HAVE_RVORBIS),1)
ifneq ($(HAVE_RMP3),1)
@@ -2067,6 +2070,7 @@ endif
endif
endif
endif
endif
ifeq ($(HAVE_RAAC), 1)
DEFINES += -DHAVE_RAAC
@@ -2076,6 +2080,7 @@ endif
ifeq ($(HAVE_ROPUS), 1)
DEFINES += -DHAVE_ROPUS
OBJ += $(LIBRETRO_COMM_DIR)/formats/opus/ropus.o
ifneq ($(HAVE_RFLAC),1)
ifneq ($(HAVE_BUILTINFLAC),1)
ifneq ($(HAVE_RVORBIS),1)
ifneq ($(HAVE_RMP3),1)
@@ -2086,14 +2091,24 @@ endif
endif
endif
endif
endif
ifeq ($(HAVE_RFLAC),1)
DEFINES += -DHAVE_RFLAC
OBJ += $(LIBRETRO_COMM_DIR)/formats/flac/rflac.o \
$(LIBRETRO_COMM_DIR)/formats/audio_transfer.o
endif
ifeq ($(HAVE_BUILTINFLAC),1)
HAVE_FLAC = 1
DEFINES += -DHAVE_FLAC -DHAVE_RFLAC -DHAVE_STDINT_H -DHAVE_LROUND -DFLAC__HAS_OGG=0 \
DEFINES += -DHAVE_FLAC -DHAVE_STDINT_H -DHAVE_LROUND -DFLAC__HAS_OGG=0 \
-DFLAC_PACKAGE_VERSION="\"retroarch\""
INCLUDE_DIRS += -I$(DEPS_DIR) -I$(DEPS_DIR)/libFLAC/include
ifneq ($(HAVE_RFLAC),1)
DEFINES += -DHAVE_RFLAC
OBJ += $(LIBRETRO_COMM_DIR)/formats/audio_transfer.o \
$(LIBRETRO_COMM_DIR)/formats/flac/rflac.o
endif
FLACOBJ = $(DEPS_DIR)/libFLAC/bitmath.o \
$(DEPS_DIR)/libFLAC/bitreader.o \
$(DEPS_DIR)/libFLAC/cpu.o \
@@ -2124,10 +2139,12 @@ endif
ifeq ($(HAVE_RVORBIS),1)
DEFINES += -DHAVE_RVORBIS
OBJ += $(LIBRETRO_COMM_DIR)/formats/vorbis/rvorbis.o
ifneq ($(HAVE_RFLAC),1)
ifneq ($(HAVE_BUILTINFLAC),1)
OBJ += $(LIBRETRO_COMM_DIR)/formats/audio_transfer.o
endif
endif
endif
ifeq ($(HAVE_BUILTINZLIB), 1)
HAVE_ZLIB_COMMON = 1
@@ -2257,14 +2274,16 @@ ifeq ($(HAVE_ZLIB_COMMON), 1)
$(LIBRETRO_COMM_DIR)/streams/chd_stream.o \
$(LIBRETRO_COMM_DIR)/formats/libchdr/libchdr_zlib.o
ifeq ($(HAVE_FLAC),1)
ifneq ($(filter 1,$(HAVE_FLAC) $(HAVE_RFLAC)),)
OBJ += $(LIBRETRO_COMM_DIR)/formats/libchdr/libchdr_flac.o \
$(LIBRETRO_COMM_DIR)/formats/libchdr/libchdr_flac_codec.o
# libchdr decodes CHD FLAC through rflac; when the built-in FLAC
# library is not in use it has not already added the object.
# libchdr decodes CHD FLAC through rflac; add the object only
# when neither the RFLAC nor the BUILTINFLAC block already has.
ifneq ($(HAVE_RFLAC),1)
ifneq ($(HAVE_BUILTINFLAC),1)
OBJ += $(LIBRETRO_COMM_DIR)/formats/flac/rflac.o
endif
endif
endif
ifeq ($(HAVE_7ZIP), 1)
+1 -1
View File
@@ -1526,7 +1526,7 @@ DEPENDENCIES
#include "../libretro-common/formats/libchdr/libchdr_chd.c"
#include "../libretro-common/formats/libchdr/libchdr_huffman.c"
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
#include "../libretro-common/formats/libchdr/libchdr_flac.c"
#include "../libretro-common/formats/libchdr/libchdr_flac_codec.c"
#endif
@@ -48,7 +48,7 @@
#include <libchdr/huffman.h>
#include <libchdr/minmax.h>
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
#include <libchdr/flac.h>
#endif
@@ -232,7 +232,7 @@ struct _chd_file
lzma_codec_data lzma_codec_data; /* lzma codec data */
cdlz_codec_data cdlz_codec_data; /* cdlz codec data */
#endif
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
flac_codec_data flac_codec_data; /* flac codec data */
cdfl_codec_data cdfl_codec_data; /* cdfl codec data */
#endif
@@ -472,7 +472,7 @@ static const codec_interface codec_interfaces[] =
huff_codec_decompress,
NULL
},
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
/* V5 flac compression */
{
CHD_CODEC_FLAC,
@@ -1088,7 +1088,7 @@ CHD_EXPORT chd_error chd_open_core_file(core_file *file, int mode, chd_file *par
break;
case CHD_CODEC_FLAC:
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
codec = &newchd->flac_codec_data;
#endif
break;
@@ -1112,7 +1112,7 @@ CHD_EXPORT chd_error chd_open_core_file(core_file *file, int mode, chd_file *par
break;
case CHD_CODEC_CD_FLAC:
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
codec = &newchd->cdfl_codec_data;
#endif
break;
@@ -1267,7 +1267,7 @@ CHD_EXPORT void chd_close(chd_file *chd)
break;
case CHD_CODEC_FLAC:
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
codec = &chd->flac_codec_data;
#endif
break;
@@ -1291,7 +1291,7 @@ CHD_EXPORT void chd_close(chd_file *chd)
break;
case CHD_CODEC_CD_FLAC:
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
codec = &chd->cdfl_codec_data;
#endif
break;
@@ -2030,7 +2030,7 @@ static chd_error hunk_read_into_memory(chd_file *chd, uint32_t hunknum, uint8_t
break;
case CHD_CODEC_FLAC:
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
codec = &chd->flac_codec_data;
#endif
break;
@@ -2054,7 +2054,7 @@ static chd_error hunk_read_into_memory(chd_file *chd, uint32_t hunknum, uint8_t
break;
case CHD_CODEC_CD_FLAC:
#ifdef HAVE_FLAC
#if defined(HAVE_FLAC) || defined(HAVE_RFLAC)
codec = &chd->cdfl_codec_data;
#endif
break;
+1 -3
View File
@@ -13,7 +13,6 @@ MBEDTLS_BUILTIN_FLAG = -DHAVE_BUILTINMBEDTLS
OTHER_CFLAGS = $(inherited) $(GLSLANG_BUILTIN_FLAG)
OTHER_CFLAGS = $(inherited) $(MBEDTLS_BUILTIN_FLAG)
OTHER_CFLAGS = $(inherited) -DFLAC__HAS_OGG=0
OTHER_CFLAGS = $(inherited) -DHAVE_7ZIP
OTHER_CFLAGS = $(inherited) -DHAVE_ACCESSIBILITY
OTHER_CFLAGS = $(inherited) -DHAVE_AL
@@ -38,7 +37,6 @@ OTHER_CFLAGS = $(inherited) -DHAVE_DSP_FILTER
OTHER_CFLAGS = $(inherited) -DHAVE_DYNAMIC
OTHER_CFLAGS = $(inherited) -DHAVE_EASTEREGG
OTHER_CFLAGS = $(inherited) -DHAVE_FILTERS_BUILTIN
OTHER_CFLAGS = $(inherited) -DHAVE_FLAC
OTHER_CFLAGS = $(inherited) -DHAVE_GCD
OTHER_CFLAGS = $(inherited) -DHAVE_GFX_WIDGETS
OTHER_CFLAGS = $(inherited) -DHAVE_GIT_VERSION
@@ -68,6 +66,7 @@ OTHER_CFLAGS = $(inherited) -DHAVE_OZONE
OTHER_CFLAGS = $(inherited) -DHAVE_PATCH
OTHER_CFLAGS = $(inherited) -DHAVE_RBMP
OTHER_CFLAGS = $(inherited) -DHAVE_REWIND
OTHER_CFLAGS = $(inherited) -DHAVE_RFLAC
OTHER_CFLAGS = $(inherited) -DHAVE_RGUI
OTHER_CFLAGS = $(inherited) -DHAVE_RJPEG
OTHER_CFLAGS = $(inherited) -DHAVE_RPNG
@@ -170,7 +169,6 @@ HEADER_SEARCH_PATHS = $(inherited) $(DEPS_DIR)
HEADER_SEARCH_PATHS = $(inherited) $(DEPS_DIR)/7zip
HEADER_SEARCH_PATHS = $(inherited) $(DEPS_DIR)/SPIRV-Cross
HEADER_SEARCH_PATHS = $(inherited) $(GLSLANG_BUILTIN_HEADER_SEARCH_PATHS)
HEADER_SEARCH_PATHS = $(inherited) $(DEPS_DIR)/libFLAC/include
HEADER_SEARCH_PATHS = $(inherited) $(DEPS_DIR)/rcheevos/include
HEADER_SEARCH_PATHS = $(inherited) $(DEPS_DIR)/stb
HEADER_SEARCH_PATHS = $(inherited) $(DEPS_DIR)/zstd/lib
@@ -399,7 +399,6 @@
"$(SRCROOT)/../../libretro-common/include",
"$(SRCROOT)/../../libretro-common/include/compat/zlib",
"$(SRCROOT)/../../deps/discord-rpc/include",
"$(SRCROOT)/../../deps/libFLAC/include",
"$(SRCROOT)/../../deps/rcheevos/include",
"$(SRCROOT)/../../deps/7zip",
"$(SRCROOT)/../../deps/stb",
@@ -442,7 +441,6 @@
"$(SRCROOT)/../../libretro-common/include",
"$(SRCROOT)/../../libretro-common/include/compat/zlib",
"$(SRCROOT)/../../deps/discord-rpc/include",
"$(SRCROOT)/../../deps/libFLAC/include",
"$(SRCROOT)/../../deps/rcheevos/include",
"$(SRCROOT)/../../deps/7zip",
"$(SRCROOT)/../../deps/stb",
@@ -488,7 +486,6 @@
"$(SRCROOT)/../../libretro-common/include",
"$(SRCROOT)/../../libretro-common/include/compat/zlib",
"$(SRCROOT)/../../deps/discord-rpc/include",
"$(SRCROOT)/../../deps/libFLAC/include",
"$(SRCROOT)/../../deps/rcheevos/include",
"$(SRCROOT)/../../deps/7zip",
"$(SRCROOT)/../../deps/stb",
@@ -528,7 +525,6 @@
"$(SRCROOT)/../../libretro-common/include",
"$(SRCROOT)/../../libretro-common/include/compat/zlib",
"$(SRCROOT)/../../deps/discord-rpc/include",
"$(SRCROOT)/../../deps/libFLAC/include",
"$(SRCROOT)/../../deps/rcheevos/include",
"$(SRCROOT)/../../deps/7zip",
"$(SRCROOT)/../../deps/stb",
@@ -564,11 +560,10 @@
"-DHAVE_COMMAND",
"-DHAVE_NETWORK_CMD",
"-DHAVE_GRIFFIN",
"-DHAVE_FLAC",
"-DHAVE_RFLAC",
"-DHAVE_DR_FLAC",
"-DHAVE_DR_MP3",
"-DHAVE_LROUND",
"-DFLAC__HAS_OGG=0",
"-DHAVE_CHD",
"-DHAVE_STB_VORBIS",
"-DHAVE_UPDATE_ASSETS",
@@ -653,11 +648,10 @@
"-DHAVE_COMMAND",
"-DHAVE_NETWORK_CMD",
"-DHAVE_GRIFFIN",
"-DHAVE_FLAC",
"-DHAVE_RFLAC",
"-DHAVE_DR_FLAC",
"-DHAVE_DR_MP3",
"-DHAVE_LROUND",
"-DFLAC__HAS_OGG=0",
"-DHAVE_CHD",
"-DHAVE_STB_VORBIS",
"-DHAVE_UPDATE_ASSETS",
@@ -1925,7 +1925,6 @@
"$(SRCBASE)/libretro-common/include",
"$(SRCBASE)/libretro-common/include/compat/zlib",
"$(DEPS_DIR)/discord-rpc/include",
"$(DEPS_DIR)/libFLAC/include",
"$(DEPS_DIR)/7zip",
"$(DEPS_DIR)/rcheevos/include",
"$(DEPS_DIR)/stb",
@@ -2009,7 +2008,6 @@
"$(SRCBASE)/libretro-common/include",
"$(SRCBASE)/libretro-common/include/compat/zlib",
"$(DEPS_DIR)/discord-rpc/include",
"$(DEPS_DIR)/libFLAC/include",
"$(DEPS_DIR)/7zip",
"$(DEPS_DIR)/rcheevos/include",
"$(DEPS_DIR)/stb",
@@ -377,7 +377,6 @@
"$(SRCROOT)/../../deps/glslang/glslang/Public",
"$(SRCROOT)/../../deps/glslang/glslang/SPIRV",
"$(SRCROOT)/../../deps/glslang/",
"$(SRCROOT)/../../deps/libFLAC/include",
"$(SRCROOT)/../../deps/rcheevos/include",
"$(SRCROOT)/../../deps/7zip",
"$(SRCROOT)/../../deps/stb",
@@ -420,7 +419,6 @@
"$(SRCROOT)/../../deps/glslang/glslang/Public",
"$(SRCROOT)/../../deps/glslang/glslang/SPIRV",
"$(SRCROOT)/../../deps/glslang/",
"$(SRCROOT)/../../deps/libFLAC/include",
"$(SRCROOT)/../../deps/rcheevos/include",
"$(SRCROOT)/../../deps/7zip",
"$(SRCROOT)/../../deps/stb",
@@ -465,7 +463,6 @@
"$(SRCROOT)/../../deps/glslang/glslang/Public",
"$(SRCROOT)/../../deps/glslang/glslang/SPIRV",
"$(SRCROOT)/../../deps/glslang/",
"$(SRCROOT)/../../deps/libFLAC/include",
"$(SRCROOT)/../../deps/rcheevos/include",
"$(SRCROOT)/../../deps/7zip",
"$(SRCROOT)/../../deps/stb",
@@ -504,7 +501,6 @@
"$(SRCROOT)/../../deps/glslang/glslang/Public",
"$(SRCROOT)/../../deps/glslang/glslang/SPIRV",
"$(SRCROOT)/../../deps/glslang/",
"$(SRCROOT)/../../deps/libFLAC/include",
"$(SRCROOT)/../../deps/rcheevos/include",
"$(SRCROOT)/../../deps/7zip",
"$(SRCROOT)/../../deps/stb",
@@ -546,11 +542,10 @@
"-DHAVE_SSL",
"-DHAVE_BUILTINMBEDTLS",
"-DHAVE_GRIFFIN",
"-DHAVE_FLAC",
"-DHAVE_RFLAC",
"-DHAVE_DR_FLAC",
"-DHAVE_DR_MP3",
"-DHAVE_LROUND",
"-DFLAC__HAS_OGG=0",
"-DHAVE_CHD",
"-DHAVE_STB_VORBIS",
"-DHAVE_UPDATE_ASSETS",
@@ -637,11 +632,10 @@
"-DHAVE_SSL",
"-DHAVE_BUILTINMBEDTLS",
"-DHAVE_GRIFFIN",
"-DHAVE_FLAC",
"-DHAVE_RFLAC",
"-DHAVE_DR_FLAC",
"-DHAVE_DR_MP3",
"-DHAVE_LROUND",
"-DFLAC__HAS_OGG=0",
"-DHAVE_CHD",
"-DHAVE_STB_VORBIS",
"-DHAVE_UPDATE_ASSETS",
+11 -3
View File
@@ -472,9 +472,17 @@ if [ "$HAVE_QT" != 'no' ]; then
check_pkgconf OPENSSL openssl 1.0.0
fi
check_enabled FLAC BUILTINFLAC 'builtin flac' 'flac is' true
check_val '' FLAC '-lFLAC' '' flac '' '' false
if [ "$HAVE_BUILTINFLAC" = 'yes' ]; then
if [ "${USER_FLAC:-}" = 'no' ]; then
die 1 'Error: flac is disabled and forced to build with builtin flac support.'
fi
# Builtin flac compiles the bundled libFLAC sources; no system
# library probe is required (or wanted - it may not be present).
HAVE_FLAC=yes
else
[ "$HAVE_BUILTINFLAC" = 'auto' ] && HAVE_BUILTINFLAC=no
check_val '' FLAC '-lFLAC' '' flac '' '' false
fi
check_enabled SSL SYSTEMMBEDTLS 'system mbedtls' 'ssl is' false
+2 -1
View File
@@ -146,8 +146,9 @@ HAVE_CHD=yes # Compile in chd support
CXX_CHD=no
HAVE_7ZIP=yes # Compile in 7z support
HAVE_ZSTD=yes # Compile in Zstandard support
HAVE_FLAC=auto # Compile in flac support
HAVE_FLAC=no # Link against libFLAC (unused by default; FLAC decode is provided by rflac)
HAVE_RMP3=yes # Compile in Dr. MP3 support
HAVE_RFLAC=yes # Native FLAC decode support
HAVE_BUILTINFLAC=auto # Bake in flac support
HAVE_ONLINE_UPDATER=yes # Disable the online updater
HAVE_UPDATE_CORES=yes # Disable downloading cores with online updater