diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 87fd00a470..b80e2a2e6f 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -3,15 +3,17 @@ # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later -cat << EOF >"ps4-toolchain.cmake" +OO_PS4_TOOLCHAIN="/home/xerix/src/ps4-sdk/prefix" + +[ -f "ps4-toolchain.cmake" ] || cat << EOF >"ps4-toolchain.cmake" set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") -set(CMAKE_C_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -funwind-tables -isystem $OO_PS4_TOOLCHAIN/include -isystem $OO_PS4_TOOLCHAIN/include/c++/v1") -set(CMAKE_CXX_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -funwind-tables -isystem $OO_PS4_TOOLCHAIN/include -isystem $OO_PS4_TOOLCHAIN/include/c++/v1") +set(CMAKE_C_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables -nostdinc -isystem $OO_PS4_TOOLCHAIN/include/c++/v1 -isystem $OO_PS4_TOOLCHAIN/include") +set(CMAKE_CXX_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables -nostdinc -isystem $OO_PS4_TOOLCHAIN/include/c++/v1 -isystem $OO_PS4_TOOLCHAIN/include") -set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lc++ -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") -set(CMAKE_C_LINK_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") -set(CMAKE_CXX_LINK_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lc++ -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") +set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib") +set(CMAKE_C_LINK_FLAGS "-lc -lkernel -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") +set(CMAKE_CXX_LINK_FLAGS " -lc++") set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) @@ -36,9 +38,7 @@ fi # Normally a platform has a package manager # PS4 does not, atleast not in the normal sense export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) -mkdir -p build -cd build -cmake .. -G Ninja \ +cmake -S . -B build -G Ninja \ -DCMAKE_TOOLCHAIN_FILE="ps4-toolchain.cmake" \ -DENABLE_QT_TRANSLATION=OFF \ -DENABLE_CUBEB=OFF \ @@ -54,4 +54,4 @@ cmake .. -G Ninja \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit -ninja -j${NPROC} || exit +cmake --build build --parallel diff --git a/.patch/boost/0004-openorbis.patch b/.patch/boost/0004-openorbis.patch new file mode 100644 index 0000000000..c027956500 --- /dev/null +++ b/.patch/boost/0004-openorbis.patch @@ -0,0 +1,17 @@ +diff --git a/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp b/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp +index 0129511c..10fc9b04 100644 +--- a/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp ++++ b/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp +@@ -15,6 +15,12 @@ + # pragma once + #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + ++// hacky fix for ps4 ++#if defined(_LIBCPP_HAS_MUSL_LIBC) ++# define FIONBIO 0 ++# define FIONREAD 1 ++#endif ++ + #include + + #include diff --git a/.patch/enet/0001-openorbis.patch b/.patch/enet/0001-openorbis.patch new file mode 100644 index 0000000000..4e6dab279e --- /dev/null +++ b/.patch/enet/0001-openorbis.patch @@ -0,0 +1,13 @@ +diff --git a/unix.c b/unix.c +index 6669216..86a2faa 100644 +--- a/unix.c ++++ b/unix.c +@@ -53,7 +53,7 @@ + #include + #endif + +-#if !defined(HAS_SOCKLEN_T) && !defined(__socklen_t_defined) ++#if !defined(_LIBCPP_HAS_MUSL_LIBC) && !defined(HAS_SOCKLEN_T) && !defined(__socklen_t_defined) + typedef int socklen_t; + #endif + diff --git a/.patch/mbedtls/0001-aesni-fix.patch b/.patch/mbedtls/0001-aesni-fix.patch index 5587e4c22d..b953bb4231 100644 --- a/.patch/mbedtls/0001-aesni-fix.patch +++ b/.patch/mbedtls/0001-aesni-fix.patch @@ -25,7 +25,7 @@ index 2857068..3e104ab 100644 #pragma GCC target ("pclmul,sse2,aes") #define MBEDTLS_POP_TARGET_PRAGMA -#elif defined(__clang__) && (__clang_major__ >= 5) -+#elif defined(__clang__) ++#elif defined(__clang__) && !defined(_LIBCPP_HAS_MUSL_LIBC) #pragma clang attribute push (__attribute__((target("pclmul,sse2,aes"))), apply_to=function) #define MBEDTLS_POP_TARGET_PRAGMA #endif diff --git a/.patch/mbedtls/0002-aesni-fix.patch b/.patch/mbedtls/0002-aesni-fix.patch new file mode 100644 index 0000000000..5112ded892 --- /dev/null +++ b/.patch/mbedtls/0002-aesni-fix.patch @@ -0,0 +1,13 @@ +diff --git a/library/aesni.h b/library/aesni.h +index 754c984c79..59e27afd3e 100644 +--- a/library/aesni.h ++++ b/library/aesni.h +@@ -35,7 +35,7 @@ + /* GCC-like compilers: currently, we only support intrinsics if the requisite + * target flag is enabled when building the library (e.g. `gcc -mpclmul -msse2` + * or `clang -maes -mpclmul`). */ +-#if (defined(__GNUC__) || defined(__clang__)) && defined(__AES__) && defined(__PCLMUL__) ++#if (defined(__GNUC__) || defined(__clang__)) && !defined(_LIBCPP_HAS_MUSL_LIBC) + #define MBEDTLS_AESNI_HAVE_INTRINSICS + #endif + /* For 32-bit, we only support intrinsics */ diff --git a/.patch/spirv-tools/0002-openorbis.patch b/.patch/spirv-tools/0002-openorbis.patch new file mode 100644 index 0000000000..f2c19d893f --- /dev/null +++ b/.patch/spirv-tools/0002-openorbis.patch @@ -0,0 +1,25 @@ +diff --git a/source/opt/loop_dependence.cpp b/source/opt/loop_dependence.cpp +index e41c044..a51b53b 100644 +--- a/source/opt/loop_dependence.cpp ++++ b/source/opt/loop_dependence.cpp +@@ -12,6 +12,12 @@ + // See the License for the specific language governing permissions and + // limitations under the License. + ++// PS4: issue? ++#ifdef __PS4__ ++#pragma clang diagnostic ignored "-Wabsolute-value" ++#pragma clang diagnostic ignored "-Wshorten-64-to-32" ++#endif ++ + #include "source/opt/loop_dependence.h" + + #include +@@ -19,6 +25,7 @@ + #include + #include + #include ++#include + + #include "source/opt/instruction.h" + #include "source/opt/scalar_analysis_nodes.h" diff --git a/cpmfile.json b/cpmfile.json index d4bf2a5b20..22814bd762 100644 --- a/cpmfile.json +++ b/cpmfile.json @@ -19,7 +19,8 @@ "patches": [ "0001-clang-cl.patch", "0002-use-marmasm.patch", - "0003-armasm-options.patch" + "0003-armasm-options.patch", + "0004-openorbis.patch" ] }, "fmt": { diff --git a/externals/cpmfile.json b/externals/cpmfile.json index 0a059cdaef..6bb140fc4e 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -113,7 +113,10 @@ "hash": "a0d2fa8c957704dd49e00a726284ac5ca034b50b00d2b20a94fa1bbfbb80841467834bfdc84aa0ed0d6aab894608fd6c86c3b94eee46343f0e6d9c22e391dbf9", "version": "1.3", "git_version": "1.3.18", - "find_args": "MODULE" + "find_args": "MODULE", + "patches": [ + "0001-openorbis.patch" + ] }, "vulkan-utility-headers": { "package": "VulkanUtilityLibraries", @@ -134,7 +137,8 @@ "SPIRV_SKIP_EXECUTABLES ON" ], "patches": [ - "0001-netbsd-fix.patch" + "0001-netbsd-fix.patch", + "0002-openorbis.patch" ] }, "spirv-headers": { diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt index c36269272a..d1d5175983 100644 --- a/externals/ffmpeg/CMakeLists.txt +++ b/externals/ffmpeg/CMakeLists.txt @@ -243,7 +243,10 @@ else() --enable-pic --cc="${FFmpeg_CC}" --cxx="${FFmpeg_CXX}" - ${FFmpeg_CROSS_COMPILE_FLAG} + --ld="${CMAKE_LINKER}" + --ldflags="${CMAKE_C_LINK_FLAGS}" + --cflags="${CMAKE_C_FLAGS}" + --cxxflags="${CMAKE_CXX_FLAGS}" ${FFmpeg_HWACCEL_FLAGS} ${FFmpeg_CROSS_COMPILE_FLAGS} WORKING_DIRECTORY diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index 86a3abcc6d..a8e43a1e4b 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -8,7 +8,7 @@ // clang-format on #else #include -#if defined(__APPLE__) || defined(__FreeBSD__) +#if defined(__APPLE__) || (defined(__FreeBSD__) && !defined(_LIBCPP_HAS_MUSL_LIBC)) #include #elif defined(__linux__) #include @@ -43,7 +43,7 @@ static MemoryInfo Detect() { sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, nullptr, 0); mem_info.TotalPhysicalMemory = ramsize; mem_info.TotalSwapMemory = vmusage.xsu_total; -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) && !defined(_LIBCPP_HAS_MUSL_LIBC) u_long physmem, swap_total; std::size_t sizeof_u_long = sizeof(u_long); // sysctlbyname(const char *, void *, size_t *, const void *, size_t);