Enable prelinking in static libretro builds

This commit is contained in:
刘皓 2025-02-13 19:42:29 -05:00
parent 157689225d
commit 4fdb7316b2
No known key found for this signature in database
GPG key ID: 7901753DB465B711
5 changed files with 28 additions and 7 deletions

View file

@ -895,7 +895,7 @@ jobs:
echo "endian = 'little'" | tee -a ~/cross.ini
echo '--------------------------------------------------------------------------------'
git config --global --add safe.directory "$(pwd)"
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=false -Dretro_phase1_path=retro/build/retro-phase1
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=true -Dretro_phase1_path=retro/build/retro-phase1
- name: Build core
run: |
@ -961,7 +961,7 @@ jobs:
echo "endian = 'big'" | tee -a ~/cross.ini
echo '--------------------------------------------------------------------------------'
git config --global --add safe.directory "$(pwd)"
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=false -Dretro_phase1_path=retro/build/retro-phase1
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=true -Dretro_phase1_path=retro/build/retro-phase1
- name: Build core
run: |
@ -1024,7 +1024,7 @@ jobs:
echo "endian = 'little'" | tee -a ~/cross.ini
echo '--------------------------------------------------------------------------------'
git config --global --add safe.directory "$(pwd)"
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=false -Dretro_phase1_path=retro/build/retro-phase1
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=true -Dretro_phase1_path=retro/build/retro-phase1
- name: Build core
run: |
@ -1089,7 +1089,7 @@ jobs:
echo "endian = 'big'" | tee -a ~/cross.ini
echo '--------------------------------------------------------------------------------'
git config --global --add safe.directory "$(pwd)"
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=false -Dretro_phase1_path=retro/build/retro-phase1
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=true -Dretro_phase1_path=retro/build/retro-phase1
- name: Build core
run: |
@ -1217,7 +1217,7 @@ jobs:
echo "endian = 'little'" | tee -a ~/cross.ini
echo '--------------------------------------------------------------------------------'
git config --global --add safe.directory "$(pwd)"
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=false -Dretro_phase1_path=retro/build/retro-phase1
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=true -Dretro_phase1_path=retro/build/retro-phase1
- name: Build core
run: |

View file

@ -7,6 +7,15 @@ is_retro = get_option('retro_phase1_path') != ''
is_emscripten = host_system == 'emscripten'
core_is_static = host_system == 'bare' or host_system == 'none'
# Meson for some reason does not support prelinking when using non-Apple Clang even though it's supported by Clang. Remove the Darwin and Clang check once Meson gets Clang prelinking support.
compiler_id = meson.get_compiler('cpp').get_id()
is_clang = compiler_id == 'clang' or compiler_id == 'armclang' or compiler_id == 'clang-cl'
core_is_prelinked = core_is_static and (host_system == 'darwin' or not is_clang)
if is_retro and core_is_static and not core_is_prelinked and get_option('b_lto') == true
error('\nCannot use LTO on this platform.')
endif
if not is_retro and host_system == 'darwin'
error('\nThis Meson project no longer supports macOS. Please use the Xcode project instead.')
endif
@ -297,6 +306,7 @@ if is_retro
cpp_args: ['-Wno-unused-command-line-argument'] + retro_cppflags + retro_defines,
link_args: retro_link_args,
gnu_symbol_visibility: 'hidden',
prelink: core_is_prelinked,
install: true, # Prevents Meson from creating thin archives; see https://github.com/mesonbuild/meson/issues/9479
include_directories: [
include_directories('.'),

View file

@ -41,7 +41,7 @@ No software libraries are required other than the system libraries.
Go to the root directory of this repository and run:
```
meson setup build -Dretro=true -Dretro_phase1_path=path/to/retro-phase1
meson setup build -Dretro_phase1_path=path/to/retro-phase1
cd build
ninja
```

View file

@ -4,4 +4,4 @@ url = https://github.com/madebr/mpg123
revision = 45fbaaeb00072d689b9c2ac4b7d109343f30abee
depth = 1
patch_directory = mpg123
diff_files = mpg123-emscripten-endian.patch, mpg123-intrinsics.patch, mpg123-libsyn123.patch, mpg123-offset.patch, mpg123-signal.patch
diff_files = mpg123-compat-str.patch, mpg123-emscripten-endian.patch, mpg123-intrinsics.patch, mpg123-libsyn123.patch, mpg123-offset.patch, mpg123-signal.patch

View file

@ -0,0 +1,11 @@
# Removes the duplicate inclusion of compat_str.c because it results in duplicate symbol errors when building a static libretro core.
--- a/ports/cmake/src/compat/CMakeLists.txt
+++ b/ports/cmake/src/compat/CMakeLists.txt
@@ -8,6 +8,3 @@ add_library(${TARGET}_dl OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_dl.c")
set_target_properties(${TARGET}_dl PROPERTIES POSITION_INDEPENDENT_CODE ON)
-add_library(${TARGET}_str OBJECT
- "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_str.c")
-set_target_properties(${TARGET}_str PROPERTIES POSITION_INDEPENDENT_CODE ON)