File shadPS4.spec of Package shadPS4
#
# spec file for package shadPS4
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global use_lto 1
%global use_avx2 0
%define __builder ninja
Name: shadPS4
Version: 20250313.5691046d
Release: 0
Summary: PlayStation 4 emulator
License: GPL-2.0-only
Group: System/Emulators/Other
URL: https://github.com/shadps4-emu/shadPS4
Source0: %{name}-%{version}.tar.zst
Patch0: shadPS4-dep_search.patch
# PRs to main
Patch10: shadPS4-PR1451.patch
# hacks / workarounds / forks
Patch100: shadPS4-issue1873.patch
# rejected but may help Gravity Rush: https://github.com/shadps4-emu/shadps4-game-compatibility/issues/1476#issuecomment-2585774354
#Patch111: shadPS4-PR2032.patch
BuildRequires: git
#BuildRequires: gcc-c++
BuildRequires: llvm-gold
BuildRequires: clang-devel
BuildRequires: lld
BuildRequires: cmake
BuildRequires: cmake(toml11)
%if "%{__builder}" == "ninja"
BuildRequires: ninja
%endif
BuildRequires: pkgconfig
BuildRequires: fdupes
BuildRequires: hicolor-icon-theme
BuildRequires: update-desktop-files
BuildRequires: robin-map-devel
BuildRequires: boost-devel
BuildRequires: renderdoc-devel
BuildRequires: zstd
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(libpng16)
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(openal)
BuildRequires: pkgconfig(jack)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(libevdev)
BuildRequires: pkgconfig(libedit)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(sdl3)
BuildRequires: pkgconfig(SPIRV-Headers)
BuildRequires: pkgconfig(SPIRV-Tools)
BuildRequires: pkgconfig(spirv-cross-c-shared)
BuildRequires: glslang-devel
BuildRequires: pkgconfig(vulkan)
BuildRequires: pkgconfig(Qt6Core)
BuildRequires: pkgconfig(Qt6Multimedia)
BuildRequires: pkgconfig(Qt6Svg)
BuildRequires: pkgconfig(Qt6Linguist)
BuildRequires: pkgconfig(Qt6Gui)
BuildRequires: pkgconfig(Qt6Concurrent)
BuildRequires: pkgconfig(fmt)
BuildRequires: pkgconfig(libavcodec)
BuildRequires: pkgconfig(libavfilter)
BuildRequires: pkgconfig(libavformat)
BuildRequires: pkgconfig(libavutil)
BuildRequires: pkgconfig(libswresample)
BuildRequires: pkgconfig(libswscale)
BuildRequires: pkgconfig(libunwind)
BuildRequires: pkgconfig(libxxhash)
BuildRequires: pkgconfig(pugixml)
BuildRequires: pkgconfig(cryptopp)
BuildRequires: pkgconfig(sndio)
BuildRequires: pkgconfig(stb)
BuildRequires: pkgconfig(zlib-ng)
Requires: hicolor-icon-theme
Provides: shadps4 = %{version}
%description
shadPS4 is a PlayStation 4 emulator written in C++.
The emulator is early in development, don't expect a flawless experience.
CPU with BMI1 and AVX2 instructions is REQUIRED!
Meaning that only x86-64-v3 (starting with Haswell and Zen) or above
is properly supported (AVX2-less Bulldozer/v2 may also work).
Otherwise startup errors like these will happen:
`[Core] <Error> cpu_patches.cpp:1124 TryExecuteIllegalInstruction: Unhandled illegal instruction at code address…: andn`
https://software.intel.com/content/www/us/en/develop/articles/intel-software-development-emulator.html may allow bypassing AVX2.
%prep
%autosetup -p1
sed -i -e '/-pedantic-errors/d' -e '/-Wfatal-errors/d' -e 's:-Werror::g' \
externals/sirit/CMakeLists.txt
%build
%if !0%{?use_lto}
%global _lto_cflags %nil
%global _lto_ldlags %nil
%else
%global _lto_cflags -flto=thin -foffload-lto=thin -ffat-lto-objects -fwhole-program-vtables
%global _lto_ldlags -flto=thin -foffload-lto=thin -ffat-lto-objects -fwhole-program-vtables -Wl,--lto-O3 -Wl,--plugin-opt=O3 -Wl,--fat-lto-objects
%endif
export CC=%{_bindir}/clang
export CXX=%{_bindir}/clang++
export CPP='%{_bindir}/clang -E' AR=%{_bindir}/llvm-ar AS=%{_bindir}/llvm-as NM=%{_bindir}/llvm-nm OBJCOPY=%{_bindir}/llvm-objcopy OBJDUMP=%{_bindir}/llvm-objdump OBJSIZE=%{_bindir}/llvm-size STRIP=%{_bindir}/llvm-strip RANLIB=%{_bindir}/llvm-ranlib
# '-fPIC -w -fexceptions -faligned-allocation'
export CFLAGS="%{optflags} -O3 -fPIC"
# https://github.com/shadps4-emu/shadPS4/issues/1202#issuecomment-2391241599
# '-march=x86-64-v3 -mavx -mavx2 -mbmi -mf16c'
%ifarch x86_64
%if 0%{?use_avx2}
export CFLAGS="${CFLAGS} -march=x86-64-v3 -mtune=generic -mavx -mavx2 -mbmi -mf16c -maes -mpclmul"
%else
export CFLAGS="${CFLAGS} -march=x86-64-v2 -mtune=generic -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul"
%endif
%endif
# '-fcxx-exceptions -fpermissive'
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="${LDFLAGS} -Wl,-O1"
export LDFLAGS="${LDFLAGS} -Wl,--gc-sections -Wl,--icf=safe"
export LDFLAGS="${LDFLAGS} -fuse-ld=lld %{_lto_ldlags}"
export LD=lld
alias ld=ld.lld
%cmake \
%if "%{__builder}" == "ninja"
-DCMAKE_MAKE_PROGRAM="ninja" \
%endif
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DUSE_PCH=OFF -DENABLE_PCH=OFF \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-DSKIP_PRECOMPILE_HEADERS=ON \
-DUSE_PRECOMPILED_HEADERS=OFF \
-DCMAKE_SKIP_RPATH=OFF \
-DCMAKE_INSTALL_RPATH="" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=OFF \
-DCMAKE_SKIP_INSTALL_RPATH=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="%{_prefix}" \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_LINKER="${LD}" \
-DCMAKE_AR="${AR}" \
-DCMAKE_RANLIB="${RANLIB}" \
-DCMAKE_C_COMPILER_AR="${AR}" \
-DCMAKE_C_COMPILER_RANLIB="${RANLIB}" \
-DCMAKE_CXX_COMPILER_AR="${AR}" \
-DCMAKE_CXX_COMPILER_RANLIB="${RANLIB}" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_MODULE_LINKER_FLAGS="${CFLAGS} ${LDFLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS="${CFLAGS} ${LDFLAGS}" \
-DCMAKE_STATIC_LINKER_FLAGS="" \
%if !0%{?use_lto}
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=OFF \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO=OFF \
%else
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO=ON \
-DZYAN_WHOLE_PROGRAM_OPTIMIZATION=ON \
%endif
-DSIRIT_USE_SYSTEM_SPIRV_HEADERS=ON \
%if !0%{?use_avx2}
-DCRYPTOPP_DISABLE_AVX2=ON \
-DSDL_DISABLE_AVX2=ON \
%endif
-DENABLE_QT_GUI=ON \
-DENABLE_DISCORD_RPC=OFF \
-DENABLE_UPDATER=OFF
%cmake_build
%install
%cmake_install
%fdupes -s %{buildroot}
%post
%desktop_database_post
%icon_theme_cache_post
%postun
%desktop_database_postun
%icon_theme_cache_postun
%files
%defattr(0644,root,root,-)
%license LICENSE
%doc README.md
%attr(0755,root,root) %{_bindir}/*
%{_datadir}/icons/hicolor/*/apps/*.*
%{_datadir}/applications/*.desktop
%{_datadir}/metainfo/*.xml
%check
%changelog