Skip to content

Commit

Permalink
PKG: optimize v2 libretro-scummvm and strip obj. on all (#151)
Browse files Browse the repository at this point in the history
* PKG: strip `lr-scummvm` & `lr-scummvm-legacy`

* PKG: optimize `libretro-scummvm` by removing heavy engines (leave only lesser ones by shared obj plugin size)
  • Loading branch information
Apaczer authored Feb 14, 2025
1 parent e1c3756 commit 9058c40
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ define LIBRETRO_SCUMMVM_LEGACY_BUILD_CMDS
CXXFLAGS="$(TARGET_CXXFLAGS) $(LIBRETRO_SCUMMVM_LEGACY_LTO_CXXFLAGS) -ffat-lto-objects" \
LDFLAGS="$(TARGET_LDFLAGS) $(LIBRETRO_SCUMMVM_LEGACY_LTO_LDFLAGS) -ffat-lto-objects -shared -Wl,--no-undefined" \
$(MAKE) all TOOLSET="$(TARGET_CROSS)" -C $(@D)/backends/platform/libretro/build/ platform="$(RETROARCH_LIBRETRO_PLATFORM)"
$(TARGET_STRIP) --strip-unneeded $(@D)/backends/platform/libretro/build/scummvm_libretro.so
endef

define LIBRETRO_SCUMMVM_LEGACY_INSTALL_TARGET_CMDS
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
From 8902a8a1afb00339bb66b72710c0887a8d0ca449 Mon Sep 17 00:00:00 2001
From: Apaczer <[email protected]>
Date: Wed, 12 Feb 2025 22:11:13 +0100
Subject: [PATCH 3/5] LIBRETRO: disable large engines with HEAVY flag

0 - default
1 - enable
2 - disable
---
backends/platform/libretro/Makefile.common | 3 ++-
backends/platform/libretro/heavy_engines.list | 22 +++++++++++++++++++
.../libretro/scripts/configure_engines.sh | 16 +++++++++++++-
3 files changed, 39 insertions(+), 2 deletions(-)
create mode 100644 backends/platform/libretro/heavy_engines.list

diff --git a/backends/platform/libretro/Makefile.common b/backends/platform/libretro/Makefile.common
index 01f2ef19ec2..8e179c48c05 100644
--- a/backends/platform/libretro/Makefile.common
+++ b/backends/platform/libretro/Makefile.common
@@ -29,6 +29,7 @@ ENABLE_VKEYBD = 1
HAVE_GCC3 = 1
STATIC_LINKING ?= 0
LITE ?= 0
+HEAVY ?= 0
NO_WIP ?= 1
USE_LIBCO ?= 1
USE_MT32EMU ?= 1
@@ -212,7 +213,7 @@ endif

ifeq (,$(filter clean datafiles coreinfo,$(MAKECMDGOALS)))
$(info Configuring ScummVM engines...)
-ifneq ($(shell cd $(SCRIPTS_PATH); ./configure_engines.sh $(ROOT_PATH) $(SCUMMVM_PATH) $(NO_WIP) $(STATIC_LINKING) $(LITE) $(UNAVAILABLE_DEPS)),0)
+ifneq ($(shell cd $(SCRIPTS_PATH); ./configure_engines.sh $(ROOT_PATH) $(SCUMMVM_PATH) $(NO_WIP) $(STATIC_LINKING) $(LITE) $(HEAVY) $(UNAVAILABLE_DEPS)),0)
$(error Configuring ScummVM engines failed)
else
-include $(SCUMMVM_PATH)/config.mk.engines
diff --git a/backends/platform/libretro/heavy_engines.list b/backends/platform/libretro/heavy_engines.list
new file mode 100644
index 00000000000..85606b3fa9c
--- /dev/null
+++ b/backends/platform/libretro/heavy_engines.list
@@ -0,0 +1,22 @@
+ags
+
+glk
+
+kyra
+lol
+eob
+
+mads
+madsv2
+
+mm
+mm1
+xeen
+
+tsage
+
+ultima
+ultima1
+ultima4
+ultima6
+ultima8
diff --git a/backends/platform/libretro/scripts/configure_engines.sh b/backends/platform/libretro/scripts/configure_engines.sh
index 43a355bd395..3e1ccecf993 100755
--- a/backends/platform/libretro/scripts/configure_engines.sh
+++ b/backends/platform/libretro/scripts/configure_engines.sh
@@ -22,12 +22,13 @@
# $3 [REQ] NO_WIP [0,1]
# $4 [REQ] STATIC_LINKING [0,1]
# $5 [REQ] LITE [0,1,2]
+# $6 [REQ] HEAVY [0,1,2]
# $[...] [OPT] Engines dependencies not available

set -e

# Exit if in parameters are not provided
-if [ -z $1 ] || [ -z $2 ] || [ -z $3 ] || [ -z $4 ] || [ -z $5 ] ; then
+if [ -z $1 ] || [ -z $2 ] || [ -z $3 ] || [ -z $4 ] || [ -z $5 ] || [ -z $6 ]; then
exit 1
fi

@@ -42,6 +43,8 @@ STATIC_LINKING=$1
shift
LITE=$1
shift
+HEAVY=$1
+shift
no_deps=$@

cd "${SCUMMVM_PATH}"
@@ -60,6 +63,17 @@ tot_deps=""
# Test LITE
[ $LITE -ne 0 ] && engine_disable_all

+# Test HEAVY
+if [ $HEAVY -eq 1 ] ; then
+ for eng in $(cat "${BUILD_PATH}"/heavy_engines.list) ; do
+ engine_enable "$eng"
+ done
+elif [ $HEAVY -eq 2 ] ; then
+ for eng in $(cat "${BUILD_PATH}"/heavy_engines.list) ; do
+ engine_disable "$eng"
+ done
+fi
+
if [ $LITE -eq 1 ] ; then
for eng in $(cat "${BUILD_PATH}"/lite_engines.list) ; do
engine_enable "$eng"
--
2.45.2.windows.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 67682387370edddb2205ff9c1b0fc80b41be23c6 Mon Sep 17 00:00:00 2001
From: Apaczer <[email protected]>
Date: Tue, 11 Feb 2025 22:22:49 +0100
Subject: [PATCH 5/5] LR-Makefile: use TREMOR explicitly

thus disable Fluidsynth from build
also use -fno-PIC
---
backends/platform/libretro/Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/backends/platform/libretro/Makefile b/backends/platform/libretro/Makefile
index 4a3cdc99236..a7508996a64 100644
--- a/backends/platform/libretro/Makefile
+++ b/backends/platform/libretro/Makefile
@@ -280,12 +280,13 @@ else ifeq ($(platform), miyoo)
LD = /opt/miyoo/usr/bin/arm-linux-g++
AR = /opt/miyoo/usr/bin/arm-linux-ar cru
RANLIB = /opt/miyoo/usr/bin/arm-linux-ranlib
- DEFINES += -DDINGUX -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -fPIC
+ DEFINES += -DDINGUX -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -fno-PIC
DEFINES += -ffunction-sections -fdata-sections -DDEFAULT_PERF_TUNER -DREDUCE_MEMORY_USAGE -DUNCACHED_PLUGINS
- LDFLAGS += -shared -Wl,--gc-sections -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
+ LDFLAGS += -shared -Wl,--gc-sections -Wl,--version-script=$(ROOT_PATH)/link.T -fno-PIC
USE_VORBIS = 0
USE_THEORADEC = 0
USE_TREMOR = 1
+ USE_FLUIDSYNTH = 0
USE_LIBCO = 0
USE_CURL = 0
USE_MT32EMU = 0
--
2.45.2.windows.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 3e4f8c0f3f3a97cdf9a5e298e8018536029a0c24 Mon Sep 17 00:00:00 2001
From: Apaczer <[email protected]>
Date: Fri, 14 Feb 2025 14:54:36 +0100
Subject: [PATCH 6/6] LIBRETRO: force "disable all unstable eng" if NO_WIP=1

---
backends/platform/libretro/scripts/configure_engines.sh | 3 +++
1 file changed, 3 insertions(+)

diff --git a/backends/platform/libretro/scripts/configure_engines.sh b/backends/platform/libretro/scripts/configure_engines.sh
index 3e1ccecf993..cf69709655e 100755
--- a/backends/platform/libretro/scripts/configure_engines.sh
+++ b/backends/platform/libretro/scripts/configure_engines.sh
@@ -80,6 +80,9 @@ if [ $LITE -eq 1 ] ; then
done
fi

+# Test NO_WIP #2
+[ $NO_WIP -eq 1 ] && engine_disable_all_unstable
+
# Define engines list
for a in $_engines ; do
# Collect all default engines dependencies and force to yes
--
2.45.2.windows.1

3 changes: 2 additions & 1 deletion package/miyoo/retroarch/libretro-scummvm/libretro-scummvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ define LIBRETRO_SCUMMVM_BUILD_CMDS
CFLAGS="$(TARGET_CFLAGS) $(LIBRETRO_SCUMMVM_LTO_CFLAGS) -ffat-lto-objects" \
CXXFLAGS="$(TARGET_CXXFLAGS) $(LIBRETRO_SCUMMVM_LTO_CXXFLAGS) -ffat-lto-objects" \
LDFLAGS="$(TARGET_LDFLAGS) $(LIBRETRO_SCUMMVM_LTO_LDFLAGS) -ffat-lto-objects -shared -Wl,--no-undefined" \
$(MAKE) all TOOLSET="$(TARGET_CROSS)" -C $(@D)/backends/platform/libretro/ platform="$(RETROARCH_LIBRETRO_PLATFORM)"
$(MAKE) all TOOLSET="$(TARGET_CROSS)" -C $(@D)/backends/platform/libretro/ HEAVY=2 platform="$(RETROARCH_LIBRETRO_PLATFORM)"
$(TARGET_STRIP) --strip-unneeded $(@D)/backends/platform/libretro/scummvm_libretro.so
endef

define LIBRETRO_SCUMMVM_INSTALL_TARGET_CMDS
Expand Down

0 comments on commit 9058c40

Please sign in to comment.