mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-24 07:43:44 +02:00
Merge branch 'libretro-compat' into libretro
This commit is contained in:
commit
9677ab899b
9 changed files with 105 additions and 23 deletions
42
.github/workflows/autobuild.yml
vendored
42
.github/workflows/autobuild.yml
vendored
|
@ -727,22 +727,44 @@ jobs:
|
|||
|
||||
build-libretro-darwin:
|
||||
needs: build-libretro-stage1
|
||||
name: LR Darwin ${{ matrix.arch_mkxpz }}
|
||||
name: LR ${{ matrix.system_name }} ${{ matrix.arch_mkxpz }}
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch_mkxpz: arm64
|
||||
arch_llvm: aarch64-apple-darwin
|
||||
- system_name: macOS
|
||||
system_mkxpz: macos
|
||||
sdk: macosx
|
||||
arch_mkxpz: arm64
|
||||
arch_llvm: arm64
|
||||
cpu_family: aarch64
|
||||
cpu: generic-armv8-a
|
||||
endian: little
|
||||
- arch_mkxpz: x86_64
|
||||
arch_llvm: x86_64-apple-darwin
|
||||
- system_name: macOS
|
||||
system_mkxpz: macos
|
||||
sdk: macosx
|
||||
arch_mkxpz: x86_64
|
||||
arch_llvm: x86_64
|
||||
cpu_family: x86_64
|
||||
cpu: x86_64
|
||||
endian: little
|
||||
- system_name: iOS
|
||||
system_mkxpz: ios
|
||||
sdk: iphoneos
|
||||
arch_mkxpz: arm64
|
||||
arch_llvm: arm64
|
||||
cpu_family: aarch64
|
||||
cpu: generic-armv8-a
|
||||
endian: little
|
||||
- system_name: tvOS
|
||||
system_mkxpz: tvos
|
||||
sdk: appletvos
|
||||
arch_mkxpz: arm64
|
||||
arch_llvm: arm64
|
||||
cpu_family: aarch64
|
||||
cpu: generic-armv8-a
|
||||
endian: little
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
@ -766,8 +788,8 @@ jobs:
|
|||
- name: Configure core
|
||||
run: |
|
||||
echo "[binaries]" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "c = ['clang', '--target=${{ matrix.arch_llvm }}']" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "cpp = ['clang++', '--target=${{ matrix.arch_llvm }}']" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "c = ['xcrun', '--sdk', '${{ matrix.sdk }}', 'clang', '-arch', '${{ matrix.arch_llvm }}']" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "cpp = ['xcrun', '--sdk', '${{ matrix.sdk }}', 'clang++', '-arch', '${{ matrix.arch_llvm }}']" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "ar = 'ar'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "strip = 'strip'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "[host_machine]" | tee -a ${{ runner.temp }}/cross.ini
|
||||
|
@ -775,6 +797,8 @@ jobs:
|
|||
echo "cpu_family = '${{ matrix.cpu_family }}'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "cpu = '${{ matrix.cpu }}'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "endian = '${{ matrix.endian }}'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "[cmake]" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "CMAKE_OSX_SYSROOT = '/nonexistent'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo '--------------------------------------------------------------------------------'
|
||||
CLICOLOR_FORCE=1 meson setup build --cross-file ${{ runner.temp }}/cross.ini --buildtype release -Db_lto=true -Dlibretro=true
|
||||
|
||||
|
@ -789,7 +813,7 @@ jobs:
|
|||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mkxp-z_libretro.darwin.${{ matrix.arch_mkxpz }}.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }}
|
||||
name: mkxp-z_libretro.${{ matrix.system_mkxpz }}.${{ matrix.arch_mkxpz }}.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }}
|
||||
path: ${{ runner.temp }}/dist
|
||||
|
||||
build-libretro-emscripten:
|
||||
|
@ -903,7 +927,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=true -Dlibretro=true
|
||||
CLICOLOR_FORCE=1 meson setup build --cross-file ~/cross.ini --buildtype release -Db_lto=false -Druby_lto=true -Dlibretro=true
|
||||
|
||||
- name: Build core
|
||||
run: |
|
||||
|
|
27
meson.build
27
meson.build
|
@ -40,6 +40,7 @@ if is_libretro
|
|||
libretro_link_args = []
|
||||
libretro_cflags = ['-Wno-unused-command-line-argument']
|
||||
libretro_cppflags = ['-Wno-unused-command-line-argument']
|
||||
libretro_ruby_cflags = []
|
||||
|
||||
if core_is_static and not is_emscripten and get_option('b_lto')
|
||||
compilers['c'].has_argument('-ffat-lto-objects', required: true)
|
||||
|
@ -48,9 +49,16 @@ if is_libretro
|
|||
libretro_cppflags += '-ffat-lto-objects'
|
||||
endif
|
||||
|
||||
if (host_cpu_family == 'ppc' or host_cpu_family == 'ppc64') and not get_option('b_lto')
|
||||
if get_option('ruby_lto') and not get_option('b_lto')
|
||||
compilers['c'].has_argument('-flto', required: true)
|
||||
compilers['c'].has_argument('-ffat-lto-objects', required: true)
|
||||
libretro_ruby_cflags += '-flto'
|
||||
libretro_ruby_cflags += '-ffat-lto-objects'
|
||||
endif
|
||||
|
||||
if (host_cpu_family == 'ppc' or host_cpu_family == 'ppc64') and not get_option('b_lto') and not get_option('ruby_lto')
|
||||
# We get a bunch of "relocation truncated to fit" when linking if LTO isn't enabled.
|
||||
error('LTO is required when building for PowerPC architectures.')
|
||||
error('LTO is required when building for PowerPC architectures. Please pass either `-Db_lto=true` or `-Druby_lto=true` to Meson.')
|
||||
endif
|
||||
|
||||
if host_cpu_family == 'ppc64'
|
||||
|
@ -235,6 +243,17 @@ if is_libretro
|
|||
libretro_defines += '-DMKXPZ_HAVE_ALIGNED_ALLOC'
|
||||
endif
|
||||
|
||||
if compilers['cpp'].has_header('sys/stat.h') and (not compilers['cpp'].has_header_symbol('sys/stat.h', 'lstat') or not compilers['cpp'].links('''
|
||||
#include <sys/stat.h>
|
||||
int main() {
|
||||
struct stat stat;
|
||||
lstat("/", &stat);
|
||||
return 0;
|
||||
}
|
||||
''', name: 'lstat sanity check'))
|
||||
libretro_defines += '-DMKXPZ_NO_LSTAT'
|
||||
endif
|
||||
|
||||
# Enable integer-only mode in FLAC when building with Vita SDK. Otherwise, we get an internal compiler error in FLAC__window_triangle:
|
||||
#
|
||||
# ../subprojects/flac/src/libFLAC/window.c: In function 'FLAC__window_triangle':
|
||||
|
@ -483,6 +502,7 @@ if is_libretro
|
|||
cmake.subproject('libzip', options: libzip_options).dependency('zip'),
|
||||
cmake.subproject('physfs', options: physfs_options).dependency('physfs-static'),
|
||||
cmake.subproject('openal-soft', options: openal_options).dependency('OpenAL'),
|
||||
cmake.subproject('openal-soft', options: openal_options).dependency('alsoft.fmt'),
|
||||
cmake.subproject('fluidlite', options: fluidlite_options).dependency('fluidlite-static'),
|
||||
cmake.subproject('ogg', options: ogg_options).dependency('ogg'),
|
||||
cmake.subproject('vorbis', options: vorbis_options).dependency('vorbis'),
|
||||
|
@ -490,6 +510,7 @@ if is_libretro
|
|||
cmake.subproject('flac', options: flac_options).dependency('FLAC'),
|
||||
cmake.subproject('opus', options: opus_options).dependency('opus'),
|
||||
cmake.subproject('mpg123', options: mpg123_options).dependency('libmpg123'),
|
||||
cmake.subproject('mpg123', options: mpg123_options).dependency('compat'),
|
||||
cmake.subproject('libsndfile', options: libsndfile_options).dependency('sndfile'),
|
||||
cmake.subproject('pixman-region', options: pixman_region_options).dependency('pixman-region'),
|
||||
subproject('stb').get_variable('stb'),
|
||||
|
@ -498,7 +519,7 @@ if is_libretro
|
|||
declare_dependency(
|
||||
link_with: static_library(
|
||||
'ruby',
|
||||
c_args: libretro_cflags + libretro_defines + [
|
||||
c_args: libretro_cflags + libretro_ruby_cflags + libretro_defines + [
|
||||
'-fno-optimize-sibling-calls',
|
||||
'-frounding-math',
|
||||
'-fsignaling-nans',
|
||||
|
|
|
@ -24,3 +24,4 @@ option('gfx_backend', type: 'combo', value: 'gl', choices: ['gl', 'gles'], descr
|
|||
|
||||
option('libretro', type: 'boolean', value: false, description: 'Build a libretro core instead of an executable')
|
||||
option('libretro_stage1_path', type: 'string', value: 'libretro/build/libretro-stage1', description: 'Path to libretro-stage1 for libretro builds')
|
||||
option('ruby_lto', type: 'boolean', value: false, description: 'Enable link-time optimization for libruby in libretro builds, even if link-time optimization is disabled for everything else')
|
||||
|
|
|
@ -3,13 +3,16 @@
|
|||
|
||||
--- a/ports/cmake/src/compat/CMakeLists.txt
|
||||
+++ b/ports/cmake/src/compat/CMakeLists.txt
|
||||
@@ -2,12 +2,6 @@ set(TARGET compat)
|
||||
add_library(${TARGET} OBJECT
|
||||
@@ -1,13 +1,7 @@
|
||||
set(TARGET compat)
|
||||
-add_library(${TARGET} OBJECT
|
||||
+add_library(${TARGET} STATIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_str.c")
|
||||
-set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
add_library(${TARGET}_dl OBJECT
|
||||
-add_library(${TARGET}_dl OBJECT
|
||||
+add_library(${TARGET}_dl STATIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_dl.c")
|
||||
-set_target_properties(${TARGET}_dl PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
-
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
# devkitPro platforms don't have usable flockfile and funlockfile functions.
|
||||
# This patch disables the use of those functions when using devkitPro.
|
||||
# Disables OpenAL Soft's use of flockfile and funlockfile since not every platform we support has those functions.
|
||||
# Besides, OpenAL Soft shouldn't even be using the filesystem or the standard streams.
|
||||
|
||||
--- a/fmt-11.1.1/include/fmt/format-inl.h
|
||||
+++ b/fmt-11.1.1/include/fmt/format-inl.h
|
||||
@@ -1479,7 +1479,11 @@ struct has_flockfile : std::false_type {};
|
||||
@@ -1479,7 +1479,7 @@ struct has_flockfile : std::false_type {};
|
||||
|
||||
template <typename F>
|
||||
struct has_flockfile<F, void_t<decltype(flockfile(&std::declval<F&>()))>>
|
||||
+#if defined(__DEVKITPRO__)
|
||||
- : std::true_type {};
|
||||
+ : std::false_type {};
|
||||
+#else
|
||||
: std::true_type {};
|
||||
+#endif
|
||||
|
||||
// A FILE wrapper. F is FILE defined as a template parameter to make system API
|
||||
// detection work.
|
||||
|
|
|
@ -13,6 +13,15 @@
|
|||
unset(HAS_ROUTER)
|
||||
--- a/fmt-11.1.1/CMakeLists.txt
|
||||
+++ b/fmt-11.1.1/CMakeLists.txt
|
||||
@@ -58,7 +58,7 @@ add_headers(FMT_HEADERS args.h base.h chrono.h color.h compile.h core.h format.h
|
||||
xchar.h)
|
||||
set(FMT_SOURCES src/format.cc src/os.cc)
|
||||
|
||||
-add_library(alsoft.fmt OBJECT ${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md)
|
||||
+add_library(alsoft.fmt STATIC ${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md)
|
||||
add_library(alsoft::fmt ALIAS alsoft.fmt)
|
||||
|
||||
if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
|
||||
@@ -73,7 +73,7 @@ target_include_directories(alsoft.fmt PUBLIC
|
||||
set_target_properties(alsoft.fmt PROPERTIES ${ALSOFT_STD_VERSION_PROPS}
|
||||
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}
|
||||
|
|
|
@ -42,3 +42,14 @@
|
|||
|
||||
return retval;
|
||||
} /* __PHYSFS_platformCalcUserDir */
|
||||
--- a/src/physfs_platform_unix.c
|
||||
+++ b/src/physfs_platform_unix.c
|
||||
@@ -227,7 +227,7 @@ static char *readSymLink(const char *path)
|
||||
break; /* out of memory. */
|
||||
retval = ptr;
|
||||
|
||||
- rc = readlink(path, retval, len);
|
||||
+ rc = -1;
|
||||
if (rc == -1)
|
||||
break; /* not a symlink, i/o error, etc. */
|
||||
|
||||
|
|
16
subprojects/packagefiles/physfs-lstat.patch
Normal file
16
subprojects/packagefiles/physfs-lstat.patch
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Prevents PhysFS from using lstat if the lstat sanity check in our meson.build failed.
|
||||
|
||||
--- a/src/physfs_platform_posix.c
|
||||
+++ b/src/physfs_platform_posix.c
|
||||
@@ -331,7 +331,11 @@ int __PHYSFS_platformDelete(const char *path)
|
||||
int __PHYSFS_platformStat(const char *fname, PHYSFS_Stat *st, const int follow)
|
||||
{
|
||||
struct stat statbuf;
|
||||
+#ifdef MKXPZ_NO_LSTAT
|
||||
+ const int rc = stat(fname, &statbuf);
|
||||
+#else
|
||||
const int rc = follow ? stat(fname, &statbuf) : lstat(fname, &statbuf);
|
||||
+#endif
|
||||
BAIL_IF(rc == -1, errcodeFromErrno(), 0);
|
||||
|
||||
if (S_ISREG(statbuf.st_mode))
|
|
@ -2,4 +2,4 @@
|
|||
url = https://github.com/icculus/physfs
|
||||
revision = release-3.2.0
|
||||
depth = 1
|
||||
diff_files = physfs-darwin.patch, physfs-dir.patch, physfs-mkxp-threads.patch, physfs-unknown-platform.patch
|
||||
diff_files = physfs-darwin.patch, physfs-dir.patch, physfs-lstat.patch, physfs-mkxp-threads.patch, physfs-unknown-platform.patch
|
||||
|
|
Loading…
Add table
Reference in a new issue