mirror of
https://github.com/libretro/fuse-libretro.git
synced 2026-11-07 10:36:03 -10:00
Build with -ffunction-sections: 1796176 -> 1592424 bytes, 11.3% off
This core links whole vendored trees for the sake of a few entry points. libspectrum calls BZ2_bzBuffToBuffDecompress and BZ2_bzDecompress*, and nothing else in bzip2: its compression half and the FILE* API are dead. Of libretro-common only the VFS, path and string helpers are used; filestream_vscanf, filestream_copy and fill_pathname_abbreviated_or_relative are not. Without -ffunction-sections the linker's unit is the whole object file, so one live symbol keeps every dead one beside it. Trimming those functions out of the vendored sources would work and is the wrong fix. Divergence between this tree's deps/libretro-common and upstream is exactly what broke the six build-static jobs three commits ago, and hand-editing bzip2's internals to split decompress from compress buys the same problem in a second dependency. Give the linker per-symbol granularity and let it decide instead of the source. Dropped from the shared build, verified with nm: BZ2_hbMakeCodeLengths, mainSort, fallbackSort, bzopen_or_bzdopen, filestream_vscanf, filestream_copy, fill_pathname_abbreviated_or_relative. The export set is unchanged - the same 47 retro_* symbols before and after, diffed symbol for symbol. Static-linking platforms get the compile flags but not --gc-sections: they produce an archive and it is the frontend's link that resolves it, so the sections are there for RetroArch's linker to use. The findstring guard on SHARED keeps the link flag off emscripten, which sets no SHARED, and theos_ios, which links through its own rules.
This commit is contained in:
1 parent
04253082be
commit
7a3b7befdb
1 file changed
+26
-2
+26
-2
@@ -504,12 +504,36 @@ endif
|
||||
DEFINES := $(PLATFORM_DEFINES)
|
||||
DEFINES += -DHAVE_CONFIG_H
|
||||
|
||||
CFLAGS += $(fpic) $(DEFINES)
|
||||
# Give the linker per-symbol granularity so it can drop what nothing calls.
|
||||
# This core links whole vendored trees for the sake of a few entry points:
|
||||
# bzip2 for BZ2_bzBuffToBuffDecompress (its compression half, blocksort and
|
||||
# the FILE* API included, is never called), libretro-common for the VFS and
|
||||
# path helpers (filestream_vscanf, filestream_copy and friends are not),
|
||||
# fuse's own utils_find_file_path/utils_find_auxiliary_file and
|
||||
# settings_write_config have no callers left after the UI removal. Without
|
||||
# -ffunction-sections the linker's unit is the whole object file, so one
|
||||
# live symbol keeps every dead one beside it. Trimming those functions out
|
||||
# of the vendored sources instead would put this tree further out of step
|
||||
# with upstream, which is what broke the static-link builds in the first
|
||||
# place, so let the linker decide rather than the source.
|
||||
#
|
||||
# Static-linking platforms get the flags too but not the --gc-sections
|
||||
# below: they build an archive and it is the frontend's link that resolves
|
||||
# it, so the sections are there for RetroArch's linker to use.
|
||||
SECTION_FLAGS := -ffunction-sections -fdata-sections
|
||||
|
||||
CFLAGS += $(fpic) $(DEFINES) $(SECTION_FLAGS)
|
||||
CFLAGS += -Wall
|
||||
|
||||
CXXFLAGS += $(fpic) $(DEFINES)
|
||||
CXXFLAGS += $(fpic) $(DEFINES) $(SECTION_FLAGS)
|
||||
CXXFLAGS += -Wall
|
||||
|
||||
ifneq ($(STATIC_LINKING), 1)
|
||||
ifneq (,$(findstring -shared,$(SHARED)))
|
||||
SHARED += -Wl,--gc-sections
|
||||
endif
|
||||
endif
|
||||
|
||||
LDFLAGS += $(LIBM)
|
||||
|
||||
ROMS =
|
||||
|
||||
Reference in new issue
Block a user