diff --git a/scripts/deps/build-dependencies-linux-cross.sh b/scripts/deps/build-dependencies-linux-cross.sh index 5be278d81..e52556787 100755 --- a/scripts/deps/build-dependencies-linux-cross.sh +++ b/scripts/deps/build-dependencies-linux-cross.sh @@ -355,6 +355,7 @@ tar xf "SDL3-$SDL3.tar.gz" cd "SDL3-$SDL3" # needed because -Isystem with chroot/usr/include breaks patch -p1 < "$SCRIPTDIR/sdl2-disable-isystem.patch" +patch -p1 < "$SCRIPTDIR/sdl3-joystick-crash.patch" cmake -B build "${CMAKE_COMMON[@]}" -DBUILD_SHARED_LIBS=ON -DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TESTS=OFF -G Ninja cmake --build build --parallel ninja -C build install diff --git a/scripts/deps/build-dependencies-linux.sh b/scripts/deps/build-dependencies-linux.sh index 92037cfa5..adb26a547 100755 --- a/scripts/deps/build-dependencies-linux.sh +++ b/scripts/deps/build-dependencies-linux.sh @@ -301,6 +301,7 @@ echo "Building SDL..." rm -fr "SDL3-$SDL3" tar xf "SDL3-$SDL3.tar.gz" cd "SDL3-$SDL3" +patch -p1 < "$SCRIPTDIR/sdl3-joystick-crash.patch" cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$INSTALLDIR" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DBUILD_SHARED_LIBS=ON -DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TESTS=OFF -G Ninja cmake --build build --parallel ninja -C build install diff --git a/scripts/deps/build-dependencies-mac.sh b/scripts/deps/build-dependencies-mac.sh index 62ddf2477..fd7586993 100755 --- a/scripts/deps/build-dependencies-mac.sh +++ b/scripts/deps/build-dependencies-mac.sh @@ -226,6 +226,7 @@ echo "Installing SDL..." rm -fr "SDL3-$SDL3" tar xf "SDL3-$SDL3.tar.gz" cd "SDL3-$SDL3" +patch -p1 < "$SCRIPTDIR/sdl3-joystick-crash.patch" cmake -B build "${CMAKE_COMMON[@]}" "$CMAKE_ARCH_UNIVERSAL" -DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TESTS=OFF -DSDL_X11=OFF -DBUILD_SHARED_LIBS=ON make -C build "-j$NPROCS" make -C build install diff --git a/scripts/deps/build-dependencies-windows-arm64.bat b/scripts/deps/build-dependencies-windows-arm64.bat index e799eb5da..cdccfd911 100644 --- a/scripts/deps/build-dependencies-windows-arm64.bat +++ b/scripts/deps/build-dependencies-windows-arm64.bat @@ -190,6 +190,7 @@ echo Building SDL... rmdir /S /Q "SDL3-%SDL3%" %SEVENZIP% x "SDL3-%SDL3%.zip" || goto error cd "SDL3-%SDL3%" || goto error +%PATCH% -p1 < "%SCRIPTDIR%\sdl3-joystick-crash.patch" || goto error cmake -B build %ARM64TOOLCHAIN% -DCMAKE_BUILD_TYPE=Release %FORCEPDB% -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TESTS=OFF -G Ninja || goto error cmake --build build --parallel || goto error ninja -C build install || goto error diff --git a/scripts/deps/build-dependencies-windows-x64.bat b/scripts/deps/build-dependencies-windows-x64.bat index 841cb3924..928723b90 100644 --- a/scripts/deps/build-dependencies-windows-x64.bat +++ b/scripts/deps/build-dependencies-windows-x64.bat @@ -187,6 +187,7 @@ echo Building SDL... rmdir /S /Q "SDL3-%SDL3%" %SEVENZIP% x "SDL3-%SDL3%.zip" || goto error cd "SDL3-%SDL3%" || goto error +%PATCH% -p1 < "%SCRIPTDIR%\sdl3-joystick-crash.patch" || goto error cmake -B build -DCMAKE_BUILD_TYPE=Release %FORCEPDB% -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TESTS=OFF -G Ninja || goto error cmake --build build --parallel || goto error ninja -C build install || goto error diff --git a/scripts/deps/sdl3-joystick-crash.patch b/scripts/deps/sdl3-joystick-crash.patch new file mode 100644 index 000000000..2cb329b03 --- /dev/null +++ b/scripts/deps/sdl3-joystick-crash.patch @@ -0,0 +1,28 @@ +From d90c0e7fefbbf9aa7061884dba02d8c809a30a10 Mon Sep 17 00:00:00 2001 +From: Stenzek +Date: Mon, 10 Feb 2025 22:52:50 +1000 +Subject: [PATCH] joystick: Fix PS5 player LED hint change callback name + +The LED hint was getting registered for SDL_HINT_JOYSTICK_ENHANCED_REPORTS +instead of SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, which results in a +use-after-free followed by a crash. +--- + src/joystick/hidapi/SDL_hidapi_ps5.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c +index 94b720d42..abf59a87f 100644 +--- a/src/joystick/hidapi/SDL_hidapi_ps5.c ++++ b/src/joystick/hidapi/SDL_hidapi_ps5.c +@@ -952,7 +952,7 @@ static bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystic + + SDL_AddHintCallback(SDL_HINT_JOYSTICK_ENHANCED_REPORTS, + SDL_PS5EnhancedReportsChanged, ctx); +- SDL_AddHintCallback(SDL_HINT_JOYSTICK_ENHANCED_REPORTS, ++ SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, + SDL_PS5PlayerLEDHintChanged, ctx); + + return true; +-- +2.48.1 + diff --git a/scripts/packaging/flatpak/modules/21-shaderc.yaml b/scripts/packaging/flatpak/modules/20-shaderc.yaml similarity index 100% rename from scripts/packaging/flatpak/modules/21-shaderc.yaml rename to scripts/packaging/flatpak/modules/20-shaderc.yaml diff --git a/scripts/packaging/flatpak/modules/22-spirv-cross.yaml b/scripts/packaging/flatpak/modules/21-spirv-cross.yaml similarity index 100% rename from scripts/packaging/flatpak/modules/22-spirv-cross.yaml rename to scripts/packaging/flatpak/modules/21-spirv-cross.yaml diff --git a/scripts/packaging/flatpak/modules/23-cpuinfo.yaml b/scripts/packaging/flatpak/modules/22-cpuinfo.yaml similarity index 100% rename from scripts/packaging/flatpak/modules/23-cpuinfo.yaml rename to scripts/packaging/flatpak/modules/22-cpuinfo.yaml diff --git a/scripts/packaging/flatpak/modules/24-discord-rpc.yaml b/scripts/packaging/flatpak/modules/23-discord-rpc.yaml similarity index 100% rename from scripts/packaging/flatpak/modules/24-discord-rpc.yaml rename to scripts/packaging/flatpak/modules/23-discord-rpc.yaml diff --git a/scripts/packaging/flatpak/modules/25-soundtouch.yaml b/scripts/packaging/flatpak/modules/24-soundtouch.yaml similarity index 100% rename from scripts/packaging/flatpak/modules/25-soundtouch.yaml rename to scripts/packaging/flatpak/modules/24-soundtouch.yaml diff --git a/scripts/packaging/flatpak/modules/26-lunasvg.yaml b/scripts/packaging/flatpak/modules/25-lunasvg.yaml similarity index 100% rename from scripts/packaging/flatpak/modules/26-lunasvg.yaml rename to scripts/packaging/flatpak/modules/25-lunasvg.yaml diff --git a/scripts/packaging/flatpak/modules/20-sdl3.yaml b/scripts/packaging/flatpak/modules/30-sdl3.yaml similarity index 88% rename from scripts/packaging/flatpak/modules/20-sdl3.yaml rename to scripts/packaging/flatpak/modules/30-sdl3.yaml index 8908e519f..d6088e150 100644 --- a/scripts/packaging/flatpak/modules/20-sdl3.yaml +++ b/scripts/packaging/flatpak/modules/30-sdl3.yaml @@ -12,10 +12,13 @@ config-opts: - "-DSDL_TESTS=OFF" build-options: strip: false + no-debuginfo: true sources: - type: archive url: "https://github.com/libsdl-org/SDL/releases/download/release-3.2.4/SDL3-3.2.4.tar.gz" sha256: "2938328317301dfbe30176d79c251733aa5e7ec5c436c800b99ed4da7adcb0f0" + - type: patch + path: "../../../deps/sdl3-joystick-crash.patch" cleanup: - /bin - /include diff --git a/scripts/packaging/flatpak/org.duckstation.DuckStation.yaml b/scripts/packaging/flatpak/org.duckstation.DuckStation.yaml index 3fec53a54..487b402be 100644 --- a/scripts/packaging/flatpak/org.duckstation.DuckStation.yaml +++ b/scripts/packaging/flatpak/org.duckstation.DuckStation.yaml @@ -32,13 +32,13 @@ modules: # Dependencies. - "modules/10-libbacktrace.yaml" - "modules/11-libzip.yaml" - - "modules/20-sdl3.yaml" - - "modules/21-shaderc.yaml" - - "modules/22-spirv-cross.yaml" - - "modules/23-cpuinfo.yaml" - - "modules/24-discord-rpc.yaml" - - "modules/25-soundtouch.yaml" - - "modules/26-lunasvg.yaml" + - "modules/20-shaderc.yaml" + - "modules/21-spirv-cross.yaml" + - "modules/22-cpuinfo.yaml" + - "modules/23-discord-rpc.yaml" + - "modules/24-soundtouch.yaml" + - "modules/25-lunasvg.yaml" + - "modules/30-sdl3.yaml" # Main module. - name: duckstation