From 33f55102d2739df3d04a6dc1177b9dc12f8febb3 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 3 Apr 2025 20:49:18 -0400 Subject: [PATCH 1/3] build(linux): enable fedora 42 Co-Authored-By: Johnny Arcitec <38923130+arcitec@users.noreply.github.com> --- packaging/linux/fedora/Sunshine.spec | 84 +++++++++++-------- .../f42/aarch64/01-math_functions.patch | 39 +++++++++ .../f42/x86_64/01-math_functions.patch | 39 +++++++++ 3 files changed, 128 insertions(+), 34 deletions(-) create mode 100644 packaging/linux/fedora/patches/f42/aarch64/01-math_functions.patch create mode 100644 packaging/linux/fedora/patches/f42/x86_64/01-math_functions.patch diff --git a/packaging/linux/fedora/Sunshine.spec b/packaging/linux/fedora/Sunshine.spec index ca08f480909..3cd46eb48ff 100644 --- a/packaging/linux/fedora/Sunshine.spec +++ b/packaging/linux/fedora/Sunshine.spec @@ -17,8 +17,6 @@ Source0: tarball.tar.gz # BuildRequires: boost-devel >= 1.86.0 BuildRequires: cmake >= 3.25.0 -BuildRequires: gcc -BuildRequires: gcc-c++ BuildRequires: libayatana-appindicator3-devel BuildRequires: libcap-devel BuildRequires: libcurl-devel @@ -54,11 +52,24 @@ BuildRequires: which BuildRequires: xorg-x11-server-Xvfb # Conditional BuildRequires for cuda-gcc based on Fedora version -%if 0%{?fedora} >= 40 -# this package conflicts with gcc on f39 -BuildRequires: cuda-gcc-c++ +%if 0%{?fedora} >= 40 && 0%{?fedora} <= 41 +# this package conflicts with gcc on f39, and doesn't work on f42 +# BuildRequires: cuda-gcc-c++ +BuildRequires: gcc13 +BuildRequires: gcc13-c++ +%global gcc_version 13 +%global cuda_version 12.6.3 +%global cuda_build 560.35.05 +%elif %{?fedora} >= 42 +BuildRequires: gcc14 +BuildRequires: gcc14-c++ +%global gcc_version 14 +%global cuda_version 12.8.1 +%global cuda_build 570.124.06 %endif +%global cuda_dir %{_builddir}/cuda + Requires: libcap >= 2.22 Requires: libcurl >= 7.0 Requires: libdrm > 2.4.97 @@ -88,20 +99,14 @@ ls -a %{_builddir}/Sunshine %autopatch -p1 %build +# exit on error +set -e + # Detect the architecture and Fedora version architecture=$(uname -m) -fedora_version=%{fedora} cuda_supported_architectures=("x86_64" "aarch64") -# set cuda_version based on Fedora version -case "$fedora_version" in - *) - cuda_version="12.6.3" - cuda_build="560.35.05" - ;; -esac - # prepare CMAKE args cmake_args=( "-B=%{_builddir}/Sunshine/build" @@ -121,27 +126,23 @@ cmake_args=( "-DSUNSHINE_PUBLISHER_ISSUE_URL=https://app.lizardbyte.dev/support" ) +export CC=gcc-%{gcc_version} +export CXX=g++-%{gcc_version} + function install_cuda() { # check if we need to install cuda - if [ -f "%{_builddir}/cuda/bin/nvcc" ]; then + if [ -f "%{cuda_dir}/bin/nvcc" ]; then echo "cuda already installed" return fi - if [ "$fedora_version" -ge 40 ]; then - # update environment variables for CUDA, necessary when using cuda-gcc-c++ - export NVCC_PREPEND_FLAGS='-ccbin /usr/bin/g++-13' - export PATH=/usr/bin/cuda:"%{_builddir}/cuda/bin:${PATH}" - export LD_LIBRARY_PATH="%{_builddir}/cuda/lib64:${LD_LIBRARY_PATH}" - fi - local cuda_prefix="https://developer.download.nvidia.com/compute/cuda/" local cuda_suffix="" if [ "$architecture" == "aarch64" ]; then local cuda_suffix="_sbsa" fi - local url="${cuda_prefix}${cuda_version}/local_installers/cuda_${cuda_version}_${cuda_build}_linux${cuda_suffix}.run" + local url="${cuda_prefix}%{cuda_version}/local_installers/cuda_%{cuda_version}_%{cuda_build}_linux${cuda_suffix}.run" echo "cuda url: ${url}" wget \ "$url" \ @@ -157,23 +158,38 @@ function install_cuda() { --override \ --silent \ --toolkit \ - --toolkitpath="%{_builddir}/cuda" + --toolkitpath="%{cuda_dir}" rm "%{_builddir}/cuda.run" + + # we need to patch math_functions.h on fedora 42 + # see https://forums.developer.nvidia.com/t/error-exception-specification-is-incompatible-for-cospi-sinpi-cospif-sinpif-with-glibc-2-41/323591/3 + if [ "%{?fedora}" -eq 42 ]; then + echo "Original math_functions.h:" + find "%{cuda_dir}" -name math_functions.h -exec cat {} \; + + # Apply the patch + patch -p2 \ + --backup \ + --directory="%{cuda_dir}" \ + --verbose \ + < "%{_builddir}/Sunshine/packaging/linux/fedora/patches/f42/${architecture}/01-math_functions.patch" + fi } -# we need to clear these flags to avoid linkage errors with cuda-gcc-c++ -export CFLAGS="" -export CXXFLAGS="" -export FFLAGS="" -export FCFLAGS="" -export LDFLAGS="" -export CC=gcc-13 -export CXX=g++-13 +if [ -n "%{cuda_version}" ] && [[ " ${cuda_supported_architectures[@]} " =~ " ${architecture} " ]]; then + # we need to clear these flags to avoid linkage errors with cuda-gcc-c++ + export CFLAGS="" + export CXXFLAGS="" + export FFLAGS="" + export FCFLAGS="" + export LDFLAGS="" -if [ -n "$cuda_version" ] && [[ " ${cuda_supported_architectures[@]} " =~ " ${architecture} " ]]; then install_cuda cmake_args+=("-DSUNSHINE_ENABLE_CUDA=ON") - cmake_args+=("-DCMAKE_CUDA_COMPILER:PATH=%{_builddir}/cuda/bin/nvcc") + cmake_args+=("-DCMAKE_CUDA_COMPILER:PATH=%{cuda_dir}/bin/nvcc") + cmake_args+=("-DCMAKE_CUDA_HOST_COMPILER=gcc-%{gcc_version}") +else + cmake_args+=("-DSUNSHINE_ENABLE_CUDA=OFF") fi # setup the version diff --git a/packaging/linux/fedora/patches/f42/aarch64/01-math_functions.patch b/packaging/linux/fedora/patches/f42/aarch64/01-math_functions.patch new file mode 100644 index 00000000000..322fef1c90d --- /dev/null +++ b/packaging/linux/fedora/patches/f42/aarch64/01-math_functions.patch @@ -0,0 +1,39 @@ +diff '--color=auto' -ur a/cuda/targets/sbsa-linux/include/crt/math_functions.h b/cuda/targets/sbsa-linux/include/crt/math_functions.h +--- a/cuda/targets/sbsa-linux/include/crt/math_functions.h 2024-08-23 00:25:39.000000000 +0200 ++++ b/cuda/targets/sbsa-linux/include/crt/math_functions.h 2025-02-17 01:19:44.270292640 +0100 +@@ -2553,7 +2553,7 @@ + * + * \note_accuracy_double + */ +-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double sinpi(double x); ++extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double sinpi(double x) noexcept (true); + /** + * \ingroup CUDA_MATH_SINGLE + * \brief Calculate the sine of the input argument +@@ -2576,7 +2576,7 @@ + * + * \note_accuracy_single + */ +-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float sinpif(float x); ++extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float sinpif(float x) noexcept (true); + /** + * \ingroup CUDA_MATH_DOUBLE + * \brief Calculate the cosine of the input argument +@@ -2598,7 +2598,7 @@ + * + * \note_accuracy_double + */ +-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double cospi(double x); ++extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double cospi(double x) noexcept (true); + /** + * \ingroup CUDA_MATH_SINGLE + * \brief Calculate the cosine of the input argument +@@ -2620,7 +2620,7 @@ + * + * \note_accuracy_single + */ +-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float cospif(float x); ++extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float cospif(float x) noexcept (true); + /** + * \ingroup CUDA_MATH_DOUBLE + * \brief Calculate the sine and cosine of the first input argument diff --git a/packaging/linux/fedora/patches/f42/x86_64/01-math_functions.patch b/packaging/linux/fedora/patches/f42/x86_64/01-math_functions.patch new file mode 100644 index 00000000000..5e522eb141a --- /dev/null +++ b/packaging/linux/fedora/patches/f42/x86_64/01-math_functions.patch @@ -0,0 +1,39 @@ +diff '--color=auto' -ur a/cuda/targets/x86_64-linux/include/crt/math_functions.h b/cuda/targets/x86_64-linux/include/crt/math_functions.h +--- a/cuda/targets/x86_64-linux/include/crt/math_functions.h 2024-08-23 00:25:39.000000000 +0200 ++++ b/cuda/targets/x86_64-linux/include/crt/math_functions.h 2025-02-17 01:19:44.270292640 +0100 +@@ -2553,7 +2553,7 @@ + * + * \note_accuracy_double + */ +-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double sinpi(double x); ++extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double sinpi(double x) noexcept (true); + /** + * \ingroup CUDA_MATH_SINGLE + * \brief Calculate the sine of the input argument +@@ -2576,7 +2576,7 @@ + * + * \note_accuracy_single + */ +-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float sinpif(float x); ++extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float sinpif(float x) noexcept (true); + /** + * \ingroup CUDA_MATH_DOUBLE + * \brief Calculate the cosine of the input argument +@@ -2598,7 +2598,7 @@ + * + * \note_accuracy_double + */ +-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double cospi(double x); ++extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double cospi(double x) noexcept (true); + /** + * \ingroup CUDA_MATH_SINGLE + * \brief Calculate the cosine of the input argument +@@ -2620,7 +2620,7 @@ + * + * \note_accuracy_single + */ +-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float cospif(float x); ++extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float cospif(float x) noexcept (true); + /** + * \ingroup CUDA_MATH_DOUBLE + * \brief Calculate the sine and cosine of the first input argument From d051ce2c6c78389dbf44820804d0df61b003b1b0 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 12 Apr 2025 13:57:20 -0400 Subject: [PATCH 2/3] remove cuda-gcc-c++ --- packaging/linux/fedora/Sunshine.spec | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packaging/linux/fedora/Sunshine.spec b/packaging/linux/fedora/Sunshine.spec index 3cd46eb48ff..910c4fce746 100644 --- a/packaging/linux/fedora/Sunshine.spec +++ b/packaging/linux/fedora/Sunshine.spec @@ -53,8 +53,6 @@ BuildRequires: xorg-x11-server-Xvfb # Conditional BuildRequires for cuda-gcc based on Fedora version %if 0%{?fedora} >= 40 && 0%{?fedora} <= 41 -# this package conflicts with gcc on f39, and doesn't work on f42 -# BuildRequires: cuda-gcc-c++ BuildRequires: gcc13 BuildRequires: gcc13-c++ %global gcc_version 13 @@ -177,13 +175,6 @@ function install_cuda() { } if [ -n "%{cuda_version}" ] && [[ " ${cuda_supported_architectures[@]} " =~ " ${architecture} " ]]; then - # we need to clear these flags to avoid linkage errors with cuda-gcc-c++ - export CFLAGS="" - export CXXFLAGS="" - export FFLAGS="" - export FCFLAGS="" - export LDFLAGS="" - install_cuda cmake_args+=("-DSUNSHINE_ENABLE_CUDA=ON") cmake_args+=("-DCMAKE_CUDA_COMPILER:PATH=%{cuda_dir}/bin/nvcc") From d2eb747ebf3737eae30c0988a9391037eed64633 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 12 Apr 2025 16:35:12 -0400 Subject: [PATCH 3/3] update docs --- docs/getting_started.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/getting_started.md b/docs/getting_started.md index 554db9db65a..adc7a171200 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -30,7 +30,9 @@ See [Docker](../DOCKER_README.md) for more information. CUDA is used for NVFBC capture. -@tip{See [CUDA GPUS](https://developer.nvidia.com/cuda-gpus) to cross-reference Compute Capability to your GPU.} +@tip{See [CUDA GPUS](https://developer.nvidia.com/cuda-gpus) to cross-reference Compute Capability to your GPU. +The table below applies to packages provided by LizardByte. If you use an official LizardByte package then you do not +need to install CUDA.}
| 12.0.0 | 525.60.13 | -50;52;60;61;62;70;72;75;80;86;87;89;90 | +50;52;60;61;62;70;72;75;80;86;87;89;90 | sunshine-debian-bookworm-{arch}.deb |
| sunshine_{arch}.flatpak | ||||
| Sunshine (copr) | +Sunshine (copr - Fedora 40/41) | +|||
| 12.8.1 | +570.124.06 | +Sunshine (copr - Fedora 42) |