From e17de9426dfac5eff589caa554c8b9264315087b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:47:40 +0000 Subject: [PATCH 01/14] Initial plan From 1e50b8e1ae415872518e8d91c0e0d4071294e6f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:55:16 +0000 Subject: [PATCH 02/14] Add cross-compilation support to Docker images and linux_build.sh Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- docker/debian-trixie.dockerfile | 107 ++++++++++++++++++-- docker/ubuntu-22.04.dockerfile | 107 ++++++++++++++++++-- docker/ubuntu-24.04.dockerfile | 107 ++++++++++++++++++-- scripts/linux_build.sh | 170 ++++++++++++++++++++++++++------ 4 files changed, 444 insertions(+), 47 deletions(-) diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index 78d8637e9bb..e7bc020040e 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # artifacts: true # platforms: linux/amd64,linux/arm64/v8 -# platforms_pr: linux/amd64 +# platforms_pr: linux/amd64,linux/arm64/v8 # no-cache-filters: sunshine-base,artifacts,sunshine ARG BASE=debian ARG TAG=trixie @@ -11,6 +11,9 @@ ENV DEBIAN_FRONTEND=noninteractive FROM sunshine-base AS sunshine-deps +ARG BUILDPLATFORM +ARG TARGETPLATFORM + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script and necessary files first for better layer caching @@ -23,16 +26,53 @@ RUN <<_DEPS #!/bin/bash set -e chmod +x ./scripts/linux_build.sh + +# Set up cross-compilation variables if building for different platform +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + cross_compile="--cross-compile" + case "${TARGETPLATFORM}" in + linux/amd64) + target_arch="amd64" + target_tuple="x86_64-linux-gnu" + ;; + linux/arm64) + target_arch="arm64" + target_tuple="aarch64-linux-gnu" + ;; + *) + echo "Unsupported target platform: ${TARGETPLATFORM}" + exit 1 + ;; + esac + + # Enable multiarch support for cross-compilation + dpkg --add-architecture ${target_arch} + apt-get update + + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" + echo "Target arch: ${target_arch}, Target triple: ${target_tuple}" +else + cross_compile="" + target_arch=$(dpkg --print-architecture) + target_tuple="" + echo "Native compilation for ${TARGETPLATFORM}" +fi + ./scripts/linux_build.sh \ --step=deps \ --cuda-patches \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} apt-get clean rm -rf /var/lib/apt/lists/* _DEPS FROM sunshine-deps AS sunshine-build +ARG BUILDPLATFORM +ARG TARGETPLATFORM ARG BRANCH ARG BUILD_VERSION ARG COMMIT @@ -49,24 +89,62 @@ COPY --link .. . RUN <<_BUILD #!/bin/bash set -e + +# Set up cross-compilation variables if building for different platform +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + cross_compile="--cross-compile" + case "${TARGETPLATFORM}" in + linux/amd64) + target_arch="amd64" + target_tuple="x86_64-linux-gnu" + ;; + linux/arm64) + target_arch="arm64" + target_tuple="aarch64-linux-gnu" + ;; + *) + echo "Unsupported target platform: ${TARGETPLATFORM}" + exit 1 + ;; + esac + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" +else + cross_compile="" + target_arch="" + target_tuple="" + echo "Native compilation for ${TARGETPLATFORM}" +fi + ./scripts/linux_build.sh \ --step=cmake \ --publisher-name='LizardByte' \ --publisher-website='https://app.lizardbyte.dev' \ --publisher-issue-url='https://app.lizardbyte.dev/support' \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=validation \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=build \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=package \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} _BUILD # run tests @@ -74,6 +152,23 @@ WORKDIR /build/sunshine/build/tests RUN <<_TEST #!/bin/bash set -e + +# For cross-compilation, we need qemu to run the tests +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + case "${TARGETPLATFORM}" in + linux/arm64) + apt-get update + apt-get install -y qemu-user-static + export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu + ;; + linux/amd64) + apt-get update + apt-get install -y qemu-user-static + export QEMU_LD_PREFIX=/usr/x86_64-linux-gnu + ;; + esac +fi + export DISPLAY=:1 Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 1693367c329..9fa529c925d 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # artifacts: true # platforms: linux/amd64,linux/arm64/v8 -# platforms_pr: linux/amd64 +# platforms_pr: linux/amd64,linux/arm64/v8 # no-cache-filters: sunshine-base,artifacts,sunshine ARG BASE=ubuntu ARG TAG=22.04 @@ -11,6 +11,9 @@ ENV DEBIAN_FRONTEND=noninteractive FROM sunshine-base AS sunshine-deps +ARG BUILDPLATFORM +ARG TARGETPLATFORM + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script first for better layer caching @@ -22,16 +25,53 @@ RUN <<_DEPS #!/bin/bash set -e chmod +x ./scripts/linux_build.sh + +# Set up cross-compilation variables if building for different platform +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + cross_compile="--cross-compile" + case "${TARGETPLATFORM}" in + linux/amd64) + target_arch="amd64" + target_tuple="x86_64-linux-gnu" + ;; + linux/arm64) + target_arch="arm64" + target_tuple="aarch64-linux-gnu" + ;; + *) + echo "Unsupported target platform: ${TARGETPLATFORM}" + exit 1 + ;; + esac + + # Enable multiarch support for cross-compilation + dpkg --add-architecture ${target_arch} + apt-get update + + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" + echo "Target arch: ${target_arch}, Target triple: ${target_tuple}" +else + cross_compile="" + target_arch=$(dpkg --print-architecture) + target_tuple="" + echo "Native compilation for ${TARGETPLATFORM}" +fi + ./scripts/linux_build.sh \ --step=deps \ --ubuntu-test-repo \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} apt-get clean rm -rf /var/lib/apt/lists/* _DEPS FROM sunshine-deps AS sunshine-build +ARG BUILDPLATFORM +ARG TARGETPLATFORM ARG BRANCH ARG BUILD_VERSION ARG COMMIT @@ -48,24 +88,62 @@ COPY --link .. . RUN <<_BUILD #!/bin/bash set -e + +# Set up cross-compilation variables if building for different platform +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + cross_compile="--cross-compile" + case "${TARGETPLATFORM}" in + linux/amd64) + target_arch="amd64" + target_tuple="x86_64-linux-gnu" + ;; + linux/arm64) + target_arch="arm64" + target_tuple="aarch64-linux-gnu" + ;; + *) + echo "Unsupported target platform: ${TARGETPLATFORM}" + exit 1 + ;; + esac + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" +else + cross_compile="" + target_arch="" + target_tuple="" + echo "Native compilation for ${TARGETPLATFORM}" +fi + ./scripts/linux_build.sh \ --step=cmake \ --publisher-name='LizardByte' \ --publisher-website='https://app.lizardbyte.dev' \ --publisher-issue-url='https://app.lizardbyte.dev/support' \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=validation \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=build \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=package \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} _BUILD # run tests @@ -73,6 +151,23 @@ WORKDIR /build/sunshine/build/tests RUN <<_TEST #!/bin/bash set -e + +# For cross-compilation, we need qemu to run the tests +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + case "${TARGETPLATFORM}" in + linux/arm64) + apt-get update + apt-get install -y qemu-user-static + export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu + ;; + linux/amd64) + apt-get update + apt-get install -y qemu-user-static + export QEMU_LD_PREFIX=/usr/x86_64-linux-gnu + ;; + esac +fi + export DISPLAY=:1 Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 6c0f82fcbb1..a22b52c6402 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # artifacts: true # platforms: linux/amd64,linux/arm64/v8 -# platforms_pr: linux/amd64 +# platforms_pr: linux/amd64,linux/arm64/v8 # no-cache-filters: sunshine-base,artifacts,sunshine ARG BASE=ubuntu ARG TAG=24.04 @@ -11,6 +11,9 @@ ENV DEBIAN_FRONTEND=noninteractive FROM sunshine-base AS sunshine-deps +ARG BUILDPLATFORM +ARG TARGETPLATFORM + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script first for better layer caching @@ -22,15 +25,52 @@ RUN <<_DEPS #!/bin/bash set -e chmod +x ./scripts/linux_build.sh + +# Set up cross-compilation variables if building for different platform +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + cross_compile="--cross-compile" + case "${TARGETPLATFORM}" in + linux/amd64) + target_arch="amd64" + target_tuple="x86_64-linux-gnu" + ;; + linux/arm64) + target_arch="arm64" + target_tuple="aarch64-linux-gnu" + ;; + *) + echo "Unsupported target platform: ${TARGETPLATFORM}" + exit 1 + ;; + esac + + # Enable multiarch support for cross-compilation + dpkg --add-architecture ${target_arch} + apt-get update + + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" + echo "Target arch: ${target_arch}, Target triple: ${target_tuple}" +else + cross_compile="" + target_arch=$(dpkg --print-architecture) + target_tuple="" + echo "Native compilation for ${TARGETPLATFORM}" +fi + ./scripts/linux_build.sh \ --step=deps \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} apt-get clean rm -rf /var/lib/apt/lists/* _DEPS FROM sunshine-deps AS sunshine-build +ARG BUILDPLATFORM +ARG TARGETPLATFORM ARG BRANCH ARG BUILD_VERSION ARG COMMIT @@ -47,24 +87,62 @@ COPY --link .. . RUN <<_BUILD #!/bin/bash set -e + +# Set up cross-compilation variables if building for different platform +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + cross_compile="--cross-compile" + case "${TARGETPLATFORM}" in + linux/amd64) + target_arch="amd64" + target_tuple="x86_64-linux-gnu" + ;; + linux/arm64) + target_arch="arm64" + target_tuple="aarch64-linux-gnu" + ;; + *) + echo "Unsupported target platform: ${TARGETPLATFORM}" + exit 1 + ;; + esac + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" +else + cross_compile="" + target_arch="" + target_tuple="" + echo "Native compilation for ${TARGETPLATFORM}" +fi + ./scripts/linux_build.sh \ --step=cmake \ --publisher-name='LizardByte' \ --publisher-website='https://app.lizardbyte.dev' \ --publisher-issue-url='https://app.lizardbyte.dev/support' \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=validation \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=build \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} ./scripts/linux_build.sh \ --step=package \ - --sudo-off + --sudo-off \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} _BUILD # run tests @@ -72,6 +150,23 @@ WORKDIR /build/sunshine/build/tests RUN <<_TEST #!/bin/bash set -e + +# For cross-compilation, we need qemu to run the tests +if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then + case "${TARGETPLATFORM}" in + linux/arm64) + apt-get update + apt-get install -y qemu-user-static + export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu + ;; + linux/amd64) + apt-get update + apt-get install -y qemu-user-static + export QEMU_LD_PREFIX=/usr/x86_64-linux-gnu + ;; + esac +fi + export DISPLAY=:1 Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index cc1be275dd0..0a68ef6d383 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -10,6 +10,7 @@ doxygen_max="1.12.0" # Default value for arguments appimage_build=0 +cross_compile=0 cuda_patches=0 num_processors=$(nproc) publisher_name="Third Party Publisher" @@ -20,6 +21,8 @@ skip_cuda=0 skip_libva=0 skip_package=0 sudo_cmd="sudo" +target_arch="" +target_tuple="" ubuntu_test_repo=0 step="all" @@ -85,6 +88,7 @@ Options: -h, --help Display this help message. -s, --sudo-off Disable sudo command. --appimage-build Compile for AppImage, this will not create the AppImage, just the executable. + --cross-compile Enable cross compilation. --cuda-patches Apply cuda patches. --num-processors The number of processors to use for compilation. Default is the value of 'nproc'. --publisher-name The name of the publisher (not developer) of the application. @@ -95,6 +99,8 @@ Options: --skip-cuda Skip CUDA installation. --skip-libva Skip libva installation. This will automatically be enabled if passing --appimage-build. --skip-package Skip creating DEB, or RPM package. + --target-arch Target architecture for cross compilation (e.g., arm64, amd64). + --target-tuple Target tuple for cross compilation (e.g., aarch64-linux-gnu, x86_64-linux-gnu). --ubuntu-test-repo Install ppa:ubuntu-toolchain-r/test repo on Ubuntu. --step Which step(s) to run: deps, cmake, validation, build, package, cleanup, or all (default: all) @@ -123,6 +129,7 @@ while getopts ":hs-:" opt; do appimage_build=1 skip_libva=1 ;; + cross-compile) cross_compile=1 ;; cuda-patches) cuda_patches=1 ;; @@ -143,6 +150,12 @@ while getopts ":hs-:" opt; do skip-libva) skip_libva=1 ;; skip-package) skip_package=1 ;; sudo-off) sudo_cmd="" ;; + target-arch=*) + target_arch="${OPTARG#*=}" + ;; + target-tuple=*) + target_tuple="${OPTARG#*=}" + ;; ubuntu-test-repo) ubuntu_test_repo=1 ;; step=*) step="${OPTARG#*=}" @@ -213,6 +226,13 @@ function add_arch_deps() { } function add_debian_based_deps() { + # If cross-compiling, we need the cross toolchain + if [ "$cross_compile" == 1 ] && [ -n "$target_arch" ]; then + dependencies+=( + "crossbuild-essential-${target_arch}" + ) + fi + dependencies+=( "appstream" "appstream-util" @@ -222,29 +242,8 @@ function add_debian_based_deps() { "desktop-file-utils" "doxygen" "flex" # required if we need to compile doxygen - "gcc-${gcc_version}" - "g++-${gcc_version}" "git" "graphviz" - "libcap-dev" # KMS - "libcurl4-openssl-dev" - "libdrm-dev" # KMS - "libevdev-dev" - "libgbm-dev" - "libminiupnpc-dev" - "libnotify-dev" - "libnuma-dev" - "libopus-dev" - "libpulse-dev" - "libssl-dev" - "libwayland-dev" # Wayland - "libx11-dev" # X11 - "libxcb-shm0-dev" # X11 - "libxcb-xfixes0-dev" # X11 - "libxcb1-dev" # X11 - "libxfixes-dev" # X11 - "libxrandr-dev" # X11 - "libxtst-dev" # X11 "ninja-build" "npm" # web-ui "udev" @@ -252,11 +251,70 @@ function add_debian_based_deps() { "xvfb" # necessary for headless unit testing ) - if [ "$skip_libva" == 0 ]; then + # Add GCC for the target architecture + if [ "$cross_compile" == 1 ] && [ -n "$target_arch" ]; then + dependencies+=("gcc-${gcc_version}") + dependencies+=("g++-${gcc_version}") + # Cross-compile specific library packages with architecture suffix + dependencies+=( + "libcap-dev:${target_arch}" # KMS + "libcurl4-openssl-dev:${target_arch}" + "libdrm-dev:${target_arch}" # KMS + "libevdev-dev:${target_arch}" + "libgbm-dev:${target_arch}" + "libminiupnpc-dev:${target_arch}" + "libnotify-dev:${target_arch}" + "libnuma-dev:${target_arch}" + "libopus-dev:${target_arch}" + "libpulse-dev:${target_arch}" + "libssl-dev:${target_arch}" + "libwayland-dev:${target_arch}" # Wayland + "libx11-dev:${target_arch}" # X11 + "libxcb-shm0-dev:${target_arch}" # X11 + "libxcb-xfixes0-dev:${target_arch}" # X11 + "libxcb1-dev:${target_arch}" # X11 + "libxfixes-dev:${target_arch}" # X11 + "libxrandr-dev:${target_arch}" # X11 + "libxtst-dev:${target_arch}" # X11 + ) + else + # Native build dependencies+=( - "libva-dev" # VA-API + "gcc-${gcc_version}" + "g++-${gcc_version}" + "libcap-dev" # KMS + "libcurl4-openssl-dev" + "libdrm-dev" # KMS + "libevdev-dev" + "libgbm-dev" + "libminiupnpc-dev" + "libnotify-dev" + "libnuma-dev" + "libopus-dev" + "libpulse-dev" + "libssl-dev" + "libwayland-dev" # Wayland + "libx11-dev" # X11 + "libxcb-shm0-dev" # X11 + "libxcb-xfixes0-dev" # X11 + "libxcb1-dev" # X11 + "libxfixes-dev" # X11 + "libxrandr-dev" # X11 + "libxtst-dev" # X11 ) fi + + if [ "$skip_libva" == 0 ]; then + if [ "$cross_compile" == 1 ] && [ -n "$target_arch" ]; then + dependencies+=( + "libva-dev:${target_arch}" # VA-API + ) + else + dependencies+=( + "libva-dev" # VA-API + ) + fi + fi } function add_test_ppa() { @@ -269,17 +327,29 @@ function add_test_ppa() { function add_debian_deps() { add_test_ppa add_debian_based_deps - dependencies+=( - "libayatana-appindicator3-dev" - ) + if [ "$cross_compile" == 1 ] && [ -n "$target_arch" ]; then + dependencies+=( + "libayatana-appindicator3-dev:${target_arch}" + ) + else + dependencies+=( + "libayatana-appindicator3-dev" + ) + fi } function add_ubuntu_deps() { add_test_ppa add_debian_based_deps - dependencies+=( - "libappindicator3-dev" - ) + if [ "$cross_compile" == 1 ] && [ -n "$target_arch" ]; then + dependencies+=( + "libappindicator3-dev:${target_arch}" + ) + else + dependencies+=( + "libappindicator3-dev" + ) + fi } function add_fedora_deps() { @@ -547,6 +617,31 @@ function run_step_cmake() { "-DSUNSHINE_ENABLE_DRM=ON" ) + # Add cross-compilation settings if enabled + if [ "$cross_compile" == 1 ] && [ -n "$target_tuple" ]; then + cmake_args+=("-DCMAKE_C_COMPILER=${target_tuple}-gcc") + cmake_args+=("-DCMAKE_CXX_COMPILER=${target_tuple}-g++") + + # Set PKG_CONFIG_PATH for cross-compilation + if [ -n "$target_arch" ]; then + case "$target_arch" in + arm64) + cmake_args+=("-DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu") + cmake_args+=("-DPKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig") + ;; + amd64) + cmake_args+=("-DCMAKE_FIND_ROOT_PATH=/usr/x86_64-linux-gnu") + cmake_args+=("-DPKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig") + ;; + esac + + # Set cross-compilation mode + cmake_args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER") + cmake_args+=("-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY") + cmake_args+=("-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY") + fi + fi + if [ "$appimage_build" == 1 ]; then cmake_args+=("-DSUNSHINE_BUILD_APPIMAGE=ON") fi @@ -761,6 +856,23 @@ fi architecture=$(uname -m) +# Override architecture for cross-compilation +if [ "$cross_compile" == 1 ] && [ -n "$target_arch" ]; then + case "$target_arch" in + arm64) + architecture="aarch64" + ;; + amd64) + architecture="x86_64" + ;; + *) + echo "Unknown target architecture: $target_arch" + exit 1 + ;; + esac + echo "Cross-compiling for architecture: $architecture (from target_arch: $target_arch)" +fi + echo "Detected Distro: $distro" echo "Detected Version: $version" echo "Detected Architecture: $architecture" From d3416b958c025775b9d22327c333e55f13a2b8f0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:57:30 +0000 Subject: [PATCH 03/14] Fix Docker ARG declarations for cross-compilation stages Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- docker/debian-trixie.dockerfile | 4 ++++ docker/ubuntu-22.04.dockerfile | 4 ++++ docker/ubuntu-24.04.dockerfile | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index e7bc020040e..c9c7eeb34b6 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -149,6 +149,10 @@ _BUILD # run tests WORKDIR /build/sunshine/build/tests + +ARG BUILDPLATFORM +ARG TARGETPLATFORM + RUN <<_TEST #!/bin/bash set -e diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 9fa529c925d..f7e7ae01f4e 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -148,6 +148,10 @@ _BUILD # run tests WORKDIR /build/sunshine/build/tests + +ARG BUILDPLATFORM +ARG TARGETPLATFORM + RUN <<_TEST #!/bin/bash set -e diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index a22b52c6402..6939cd2c2a9 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -147,6 +147,10 @@ _BUILD # run tests WORKDIR /build/sunshine/build/tests + +ARG BUILDPLATFORM +ARG TARGETPLATFORM + RUN <<_TEST #!/bin/bash set -e From e49cfac7b829a93f1ba36d53a55ab85419902eb9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Sep 2025 00:18:48 +0000 Subject: [PATCH 04/14] Fix cross-compilation with CMake toolchain files and resolve hadolint warnings Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- cmake/toolchains/aarch64-linux-gnu.cmake | 32 ++++++++++++++++++++++++ cmake/toolchains/x86_64-linux-gnu.cmake | 28 +++++++++++++++++++++ docker/debian-trixie.dockerfile | 28 +++++---------------- docker/ubuntu-22.04.dockerfile | 28 +++++---------------- docker/ubuntu-24.04.dockerfile | 28 +++++---------------- scripts/linux_build.sh | 30 ++++++++-------------- 6 files changed, 88 insertions(+), 86 deletions(-) create mode 100644 cmake/toolchains/aarch64-linux-gnu.cmake create mode 100644 cmake/toolchains/x86_64-linux-gnu.cmake diff --git a/cmake/toolchains/aarch64-linux-gnu.cmake b/cmake/toolchains/aarch64-linux-gnu.cmake new file mode 100644 index 00000000000..75dd98b9798 --- /dev/null +++ b/cmake/toolchains/aarch64-linux-gnu.cmake @@ -0,0 +1,32 @@ +# CMake toolchain file for cross-compiling to ARM64 (aarch64) on Debian/Ubuntu +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/aarch64-linux-gnu.cmake + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +# Specify the cross-compiler +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) + +# Set sysroot path +set(CMAKE_SYSROOT /usr/aarch64-linux-gnu) + +# Adjust the default behavior of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# Set the target environment paths +set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) + +# Set pkg-config environment for cross-compilation +set(ENV{PKG_CONFIG_PATH} "/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/aarch64-linux-gnu") + +# Set compiler flags for cross-compilation +set(CMAKE_C_FLAGS_INIT "-march=armv8-a") +set(CMAKE_CXX_FLAGS_INIT "-march=armv8-a") \ No newline at end of file diff --git a/cmake/toolchains/x86_64-linux-gnu.cmake b/cmake/toolchains/x86_64-linux-gnu.cmake new file mode 100644 index 00000000000..0248c2d8d16 --- /dev/null +++ b/cmake/toolchains/x86_64-linux-gnu.cmake @@ -0,0 +1,28 @@ +# CMake toolchain file for cross-compiling to x86_64 on Debian/Ubuntu +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/x86_64-linux-gnu.cmake + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +# Specify the cross-compiler +set(CMAKE_C_COMPILER x86_64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++) + +# Set sysroot path +set(CMAKE_SYSROOT /usr/x86_64-linux-gnu) + +# Adjust the default behavior of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# Set the target environment paths +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-linux-gnu) + +# Set pkg-config environment for cross-compilation +set(ENV{PKG_CONFIG_PATH} "/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/x86_64-linux-gnu") \ No newline at end of file diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index c9c7eeb34b6..9bf64986c34 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -28,7 +28,7 @@ set -e chmod +x ./scripts/linux_build.sh # Set up cross-compilation variables if building for different platform -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then +if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in linux/amd64) @@ -91,7 +91,7 @@ RUN <<_BUILD set -e # Set up cross-compilation variables if building for different platform -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then +if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in linux/amd64) @@ -147,32 +147,16 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -# run tests -WORKDIR /build/sunshine/build/tests +FROM sunshine-build AS sunshine-test -ARG BUILDPLATFORM +# This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM +WORKDIR /build/sunshine/build/tests + RUN <<_TEST #!/bin/bash set -e - -# For cross-compilation, we need qemu to run the tests -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then - case "${TARGETPLATFORM}" in - linux/arm64) - apt-get update - apt-get install -y qemu-user-static - export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu - ;; - linux/amd64) - apt-get update - apt-get install -y qemu-user-static - export QEMU_LD_PREFIX=/usr/x86_64-linux-gnu - ;; - esac -fi - export DISPLAY=:1 Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index f7e7ae01f4e..635e24ee513 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -27,7 +27,7 @@ set -e chmod +x ./scripts/linux_build.sh # Set up cross-compilation variables if building for different platform -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then +if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in linux/amd64) @@ -90,7 +90,7 @@ RUN <<_BUILD set -e # Set up cross-compilation variables if building for different platform -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then +if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in linux/amd64) @@ -146,32 +146,16 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -# run tests -WORKDIR /build/sunshine/build/tests +FROM sunshine-build AS sunshine-test -ARG BUILDPLATFORM +# This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM +WORKDIR /build/sunshine/build/tests + RUN <<_TEST #!/bin/bash set -e - -# For cross-compilation, we need qemu to run the tests -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then - case "${TARGETPLATFORM}" in - linux/arm64) - apt-get update - apt-get install -y qemu-user-static - export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu - ;; - linux/amd64) - apt-get update - apt-get install -y qemu-user-static - export QEMU_LD_PREFIX=/usr/x86_64-linux-gnu - ;; - esac -fi - export DISPLAY=:1 Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 6939cd2c2a9..0408c70d1c9 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -27,7 +27,7 @@ set -e chmod +x ./scripts/linux_build.sh # Set up cross-compilation variables if building for different platform -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then +if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in linux/amd64) @@ -89,7 +89,7 @@ RUN <<_BUILD set -e # Set up cross-compilation variables if building for different platform -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then +if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in linux/amd64) @@ -145,32 +145,16 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -# run tests -WORKDIR /build/sunshine/build/tests +FROM sunshine-build AS sunshine-test -ARG BUILDPLATFORM +# This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM +WORKDIR /build/sunshine/build/tests + RUN <<_TEST #!/bin/bash set -e - -# For cross-compilation, we need qemu to run the tests -if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then - case "${TARGETPLATFORM}" in - linux/arm64) - apt-get update - apt-get install -y qemu-user-static - export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu - ;; - linux/amd64) - apt-get update - apt-get install -y qemu-user-static - export QEMU_LD_PREFIX=/usr/x86_64-linux-gnu - ;; - esac -fi - export DISPLAY=:1 Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index 0a68ef6d383..49d8a0f65c4 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -619,26 +619,16 @@ function run_step_cmake() { # Add cross-compilation settings if enabled if [ "$cross_compile" == 1 ] && [ -n "$target_tuple" ]; then - cmake_args+=("-DCMAKE_C_COMPILER=${target_tuple}-gcc") - cmake_args+=("-DCMAKE_CXX_COMPILER=${target_tuple}-g++") - - # Set PKG_CONFIG_PATH for cross-compilation - if [ -n "$target_arch" ]; then - case "$target_arch" in - arm64) - cmake_args+=("-DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu") - cmake_args+=("-DPKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig") - ;; - amd64) - cmake_args+=("-DCMAKE_FIND_ROOT_PATH=/usr/x86_64-linux-gnu") - cmake_args+=("-DPKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig") - ;; - esac - - # Set cross-compilation mode - cmake_args+=("-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER") - cmake_args+=("-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY") - cmake_args+=("-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY") + # Use CMake toolchain file for cross-compilation + toolchain_file="${script_dir}/../cmake/toolchains/${target_tuple}.cmake" + if [ -f "$toolchain_file" ]; then + cmake_args+=("-DCMAKE_TOOLCHAIN_FILE=${toolchain_file}") + echo "Using toolchain file: $toolchain_file" + else + echo "Warning: Toolchain file not found: $toolchain_file" + # Fallback to manual configuration + cmake_args+=("-DCMAKE_C_COMPILER=${target_tuple}-gcc") + cmake_args+=("-DCMAKE_CXX_COMPILER=${target_tuple}-g++") fi fi From 75820f1a1bf79d6f0da33d12aecb053f80adaa9a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Sep 2025 01:17:30 +0000 Subject: [PATCH 05/14] Fix Docker platform directives and add explicit OpenSSL paths to toolchain Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- cmake/toolchains/aarch64-linux-gnu.cmake | 12 +++++++++++- docker/debian-trixie.dockerfile | 11 ++++++++--- docker/ubuntu-22.04.dockerfile | 11 ++++++++--- docker/ubuntu-24.04.dockerfile | 11 ++++++++--- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/cmake/toolchains/aarch64-linux-gnu.cmake b/cmake/toolchains/aarch64-linux-gnu.cmake index 75dd98b9798..1d7a49ac340 100644 --- a/cmake/toolchains/aarch64-linux-gnu.cmake +++ b/cmake/toolchains/aarch64-linux-gnu.cmake @@ -29,4 +29,14 @@ set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/aarch64-linux-gnu") # Set compiler flags for cross-compilation set(CMAKE_C_FLAGS_INIT "-march=armv8-a") -set(CMAKE_CXX_FLAGS_INIT "-march=armv8-a") \ No newline at end of file +set(CMAKE_CXX_FLAGS_INIT "-march=armv8-a") + +# Explicitly set OpenSSL paths for cross-compilation +set(OPENSSL_ROOT_DIR "/usr/aarch64-linux-gnu") +set(OPENSSL_INCLUDE_DIR "/usr/aarch64-linux-gnu/include") +set(OPENSSL_CRYPTO_LIBRARY "/usr/aarch64-linux-gnu/lib/libcrypto.so") +set(OPENSSL_SSL_LIBRARY "/usr/aarch64-linux-gnu/lib/libssl.so") + +# Additional library paths +set(CMAKE_LIBRARY_PATH "/usr/aarch64-linux-gnu/lib" ${CMAKE_LIBRARY_PATH}) +set(CMAKE_INCLUDE_PATH "/usr/aarch64-linux-gnu/include" ${CMAKE_INCLUDE_PATH}) \ No newline at end of file diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index 9bf64986c34..01049a6f7c6 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -14,6 +14,11 @@ FROM sunshine-base AS sunshine-deps ARG BUILDPLATFORM ARG TARGETPLATFORM +# Force this stage to run on the build platform for cross-compilation setup +FROM --platform=$BUILDPLATFORM debian:trixie AS sunshine-deps-native + +ENV DEBIAN_FRONTEND=noninteractive + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script and necessary files first for better layer caching @@ -69,7 +74,7 @@ apt-get clean rm -rf /var/lib/apt/lists/* _DEPS -FROM sunshine-deps AS sunshine-build +FROM --platform=$BUILDPLATFORM sunshine-deps-native AS sunshine-build ARG BUILDPLATFORM ARG TARGETPLATFORM @@ -147,7 +152,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -FROM sunshine-build AS sunshine-test +FROM --platform=$TARGETPLATFORM sunshine-build AS sunshine-test # This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM @@ -162,7 +167,7 @@ Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes _TEST -FROM sunshine-base AS sunshine +FROM --platform=$TARGETPLATFORM sunshine-base AS sunshine ARG BASE ARG TAG diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 635e24ee513..adacf4f3636 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -14,6 +14,11 @@ FROM sunshine-base AS sunshine-deps ARG BUILDPLATFORM ARG TARGETPLATFORM +# Force this stage to run on the build platform for cross-compilation setup +FROM --platform=$BUILDPLATFORM ubuntu:22.04 AS sunshine-deps-native + +ENV DEBIAN_FRONTEND=noninteractive + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script first for better layer caching @@ -68,7 +73,7 @@ apt-get clean rm -rf /var/lib/apt/lists/* _DEPS -FROM sunshine-deps AS sunshine-build +FROM --platform=$BUILDPLATFORM sunshine-deps-native AS sunshine-build ARG BUILDPLATFORM ARG TARGETPLATFORM @@ -146,7 +151,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -FROM sunshine-build AS sunshine-test +FROM --platform=$TARGETPLATFORM sunshine-build AS sunshine-test # This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM @@ -161,7 +166,7 @@ Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes _TEST -FROM sunshine-base AS sunshine +FROM --platform=$TARGETPLATFORM sunshine-base AS sunshine ARG BASE ARG TAG diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 0408c70d1c9..6dee24044dd 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -14,6 +14,11 @@ FROM sunshine-base AS sunshine-deps ARG BUILDPLATFORM ARG TARGETPLATFORM +# Force this stage to run on the build platform for cross-compilation setup +FROM --platform=$BUILDPLATFORM ubuntu:24.04 AS sunshine-deps-native + +ENV DEBIAN_FRONTEND=noninteractive + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script first for better layer caching @@ -67,7 +72,7 @@ apt-get clean rm -rf /var/lib/apt/lists/* _DEPS -FROM sunshine-deps AS sunshine-build +FROM --platform=$BUILDPLATFORM sunshine-deps-native AS sunshine-build ARG BUILDPLATFORM ARG TARGETPLATFORM @@ -145,7 +150,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -FROM sunshine-build AS sunshine-test +FROM --platform=$TARGETPLATFORM sunshine-build AS sunshine-test # This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM @@ -160,7 +165,7 @@ Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes _TEST -FROM sunshine-base AS sunshine +FROM --platform=$TARGETPLATFORM sunshine-base AS sunshine ARG BASE ARG TAG From b49d9cc69320962178daa86692eff68266296333 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 27 Sep 2025 09:39:49 -0400 Subject: [PATCH 06/14] Refactor Dockerfiles and update .dockerignore Simplifies multi-stage Dockerfiles for Debian Trixie and Ubuntu by removing redundant native dependency stages and unifying build logic. Updates .dockerignore to remove exceptions for .rstcheck.cfg, add ignores for node_modules and non-Linux third-party dependencies, and deletes the unused .rstcheck.cfg config file. --- .dockerignore | 13 ++++++++++--- .rstcheck.cfg | 10 ---------- docker/debian-trixie.dockerfile | 21 ++++++++------------- docker/ubuntu-22.04.dockerfile | 21 ++++++++------------- docker/ubuntu-24.04.dockerfile | 21 ++++++++------------- 5 files changed, 34 insertions(+), 52 deletions(-) delete mode 100644 .rstcheck.cfg diff --git a/.dockerignore b/.dockerignore index 641742725e4..d848043e2dc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,9 +4,6 @@ # do not ignore .git, needed for versioning !/.git -# do not ignore .rstcheck.cfg, needed to test building docs -!/.rstcheck.cfg - # ignore repo directories and files docker/ gh-pages-template/ @@ -20,7 +17,17 @@ crowdin.yml # ignore dev directories build/ cmake-*/ +node_modules/ venv/ +# ignore pre-built deps for other platforms +third-party/build-deps/dist/Darwin* +third-party/build-deps/dist/FreeBSD* +third-party/build-deps/dist/Windows* + +# ignore non Linux third-party submodules +third-party/libdisplaydevice +third-party/TPCircularBuffer + # ignore artifacts artifacts/ diff --git a/.rstcheck.cfg b/.rstcheck.cfg deleted file mode 100644 index ca6beba81ae..00000000000 --- a/.rstcheck.cfg +++ /dev/null @@ -1,10 +0,0 @@ -# configuration file for rstcheck, an rst linting tool -# https://rstcheck.readthedocs.io/en/latest/usage/config - -[rstcheck] -ignore_directives = - doxygenfile, - include, - mdinclude, - tab, - todo, diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index 01049a6f7c6..c034e7dca98 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -9,13 +9,8 @@ FROM ${BASE}:${TAG} AS sunshine-base ENV DEBIAN_FRONTEND=noninteractive -FROM sunshine-base AS sunshine-deps - -ARG BUILDPLATFORM -ARG TARGETPLATFORM - # Force this stage to run on the build platform for cross-compilation setup -FROM --platform=$BUILDPLATFORM debian:trixie AS sunshine-deps-native +FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-deps ENV DEBIAN_FRONTEND=noninteractive @@ -41,7 +36,7 @@ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then target_tuple="x86_64-linux-gnu" ;; linux/arm64) - target_arch="arm64" + target_arch="arm64" target_tuple="aarch64-linux-gnu" ;; *) @@ -49,11 +44,11 @@ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then exit 1 ;; esac - + # Enable multiarch support for cross-compilation dpkg --add-architecture ${target_arch} apt-get update - + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" echo "Target arch: ${target_arch}, Target triple: ${target_tuple}" else @@ -74,7 +69,7 @@ apt-get clean rm -rf /var/lib/apt/lists/* _DEPS -FROM --platform=$BUILDPLATFORM sunshine-deps-native AS sunshine-build +FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build ARG BUILDPLATFORM ARG TARGETPLATFORM @@ -95,7 +90,7 @@ RUN <<_BUILD #!/bin/bash set -e -# Set up cross-compilation variables if building for different platform +# Set up cross-compilation variables if building for different platform if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in @@ -152,7 +147,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -FROM --platform=$TARGETPLATFORM sunshine-build AS sunshine-test +FROM sunshine-build AS sunshine-test # This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM @@ -167,7 +162,7 @@ Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes _TEST -FROM --platform=$TARGETPLATFORM sunshine-base AS sunshine +FROM sunshine-base AS sunshine ARG BASE ARG TAG diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index adacf4f3636..04c14bae66f 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -9,13 +9,8 @@ FROM ${BASE}:${TAG} AS sunshine-base ENV DEBIAN_FRONTEND=noninteractive -FROM sunshine-base AS sunshine-deps - -ARG BUILDPLATFORM -ARG TARGETPLATFORM - # Force this stage to run on the build platform for cross-compilation setup -FROM --platform=$BUILDPLATFORM ubuntu:22.04 AS sunshine-deps-native +FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-deps ENV DEBIAN_FRONTEND=noninteractive @@ -40,7 +35,7 @@ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then target_tuple="x86_64-linux-gnu" ;; linux/arm64) - target_arch="arm64" + target_arch="arm64" target_tuple="aarch64-linux-gnu" ;; *) @@ -48,11 +43,11 @@ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then exit 1 ;; esac - + # Enable multiarch support for cross-compilation dpkg --add-architecture ${target_arch} apt-get update - + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" echo "Target arch: ${target_arch}, Target triple: ${target_tuple}" else @@ -73,7 +68,7 @@ apt-get clean rm -rf /var/lib/apt/lists/* _DEPS -FROM --platform=$BUILDPLATFORM sunshine-deps-native AS sunshine-build +FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build ARG BUILDPLATFORM ARG TARGETPLATFORM @@ -94,7 +89,7 @@ RUN <<_BUILD #!/bin/bash set -e -# Set up cross-compilation variables if building for different platform +# Set up cross-compilation variables if building for different platform if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in @@ -151,7 +146,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -FROM --platform=$TARGETPLATFORM sunshine-build AS sunshine-test +FROM sunshine-build AS sunshine-test # This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM @@ -166,7 +161,7 @@ Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes _TEST -FROM --platform=$TARGETPLATFORM sunshine-base AS sunshine +FROM sunshine-base AS sunshine ARG BASE ARG TAG diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 6dee24044dd..2d0422fc7ad 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -9,13 +9,8 @@ FROM ${BASE}:${TAG} AS sunshine-base ENV DEBIAN_FRONTEND=noninteractive -FROM sunshine-base AS sunshine-deps - -ARG BUILDPLATFORM -ARG TARGETPLATFORM - # Force this stage to run on the build platform for cross-compilation setup -FROM --platform=$BUILDPLATFORM ubuntu:24.04 AS sunshine-deps-native +FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-deps ENV DEBIAN_FRONTEND=noninteractive @@ -40,7 +35,7 @@ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then target_tuple="x86_64-linux-gnu" ;; linux/arm64) - target_arch="arm64" + target_arch="arm64" target_tuple="aarch64-linux-gnu" ;; *) @@ -48,11 +43,11 @@ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then exit 1 ;; esac - + # Enable multiarch support for cross-compilation dpkg --add-architecture ${target_arch} apt-get update - + echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" echo "Target arch: ${target_arch}, Target triple: ${target_tuple}" else @@ -72,7 +67,7 @@ apt-get clean rm -rf /var/lib/apt/lists/* _DEPS -FROM --platform=$BUILDPLATFORM sunshine-deps-native AS sunshine-build +FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build ARG BUILDPLATFORM ARG TARGETPLATFORM @@ -93,7 +88,7 @@ RUN <<_BUILD #!/bin/bash set -e -# Set up cross-compilation variables if building for different platform +# Set up cross-compilation variables if building for different platform if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" case "${TARGETPLATFORM}" in @@ -150,7 +145,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} _BUILD -FROM --platform=$TARGETPLATFORM sunshine-build AS sunshine-test +FROM sunshine-build AS sunshine-test # This stage runs on the target architecture to avoid qemu overhead for tests ARG TARGETPLATFORM @@ -165,7 +160,7 @@ Xvfb ${DISPLAY} -screen 0 1024x768x24 & ./test_sunshine --gtest_color=yes _TEST -FROM --platform=$TARGETPLATFORM sunshine-base AS sunshine +FROM sunshine-base AS sunshine ARG BASE ARG TAG From b7fc5805606eda8d581b70abbb0e470d4a34fe00 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 27 Sep 2025 17:37:28 -0400 Subject: [PATCH 07/14] Refactor toolchain files to use COMPILER_PREFIX variable Updated aarch64 and x86_64 CMake toolchain files to use a COMPILER_PREFIX variable for consistency and maintainability. Paths for compilers, sysroots, pkg-config, OpenSSL, and library/include directories are now constructed using this variable. Also added CPACK_DEBIAN_PACKAGE_ARCHITECTURE for packaging support. --- cmake/toolchains/aarch64-linux-gnu.cmake | 41 ++++++++++++++---------- cmake/toolchains/x86_64-linux-gnu.cmake | 39 +++++++++++++++------- 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/cmake/toolchains/aarch64-linux-gnu.cmake b/cmake/toolchains/aarch64-linux-gnu.cmake index 1d7a49ac340..9c62cc4791b 100644 --- a/cmake/toolchains/aarch64-linux-gnu.cmake +++ b/cmake/toolchains/aarch64-linux-gnu.cmake @@ -1,15 +1,22 @@ # CMake toolchain file for cross-compiling to ARM64 (aarch64) on Debian/Ubuntu # Usage: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/aarch64-linux-gnu.cmake +# The name of the target operating system set(CMAKE_SYSTEM_NAME Linux) + +# Set processor type set(CMAKE_SYSTEM_PROCESSOR aarch64) -# Specify the cross-compiler -set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) +# Set compiler prefix +set(COMPILER_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) + +# Which compilers to use for C and C++ +set(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++) +set(CMAKE_ASM_COMPILER ${COMPILER_PREFIX}-gcc) -# Set sysroot path -set(CMAKE_SYSROOT /usr/aarch64-linux-gnu) +# Here is the target environment located +set(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) # Adjust the default behavior of the FIND_XXX() commands: # search headers and libraries in the target environment, search @@ -19,24 +26,24 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -# Set the target environment paths -set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) - # Set pkg-config environment for cross-compilation -set(ENV{PKG_CONFIG_PATH} "/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig") -set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig") -set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/aarch64-linux-gnu") +set(ENV{PKG_CONFIG_PATH} "/usr/lib/${COMPILER_PREFIX}/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${COMPILER_PREFIX}/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/${COMPILER_PREFIX}") # Set compiler flags for cross-compilation set(CMAKE_C_FLAGS_INIT "-march=armv8-a") set(CMAKE_CXX_FLAGS_INIT "-march=armv8-a") # Explicitly set OpenSSL paths for cross-compilation -set(OPENSSL_ROOT_DIR "/usr/aarch64-linux-gnu") -set(OPENSSL_INCLUDE_DIR "/usr/aarch64-linux-gnu/include") -set(OPENSSL_CRYPTO_LIBRARY "/usr/aarch64-linux-gnu/lib/libcrypto.so") -set(OPENSSL_SSL_LIBRARY "/usr/aarch64-linux-gnu/lib/libssl.so") +set(OPENSSL_ROOT_DIR "/usr/${COMPILER_PREFIX}") +set(OPENSSL_INCLUDE_DIR "/usr/${COMPILER_PREFIX}/include") +set(OPENSSL_CRYPTO_LIBRARY "/usr/${COMPILER_PREFIX}/lib/libcrypto.so") +set(OPENSSL_SSL_LIBRARY "/usr/${COMPILER_PREFIX}/lib/libssl.so") # Additional library paths -set(CMAKE_LIBRARY_PATH "/usr/aarch64-linux-gnu/lib" ${CMAKE_LIBRARY_PATH}) -set(CMAKE_INCLUDE_PATH "/usr/aarch64-linux-gnu/include" ${CMAKE_INCLUDE_PATH}) \ No newline at end of file +set(CMAKE_LIBRARY_PATH "/usr/${COMPILER_PREFIX}/lib" ${CMAKE_LIBRARY_PATH}) +set(CMAKE_INCLUDE_PATH "/usr/${COMPILER_PREFIX}/include" ${CMAKE_INCLUDE_PATH}) + +# Packaging +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") diff --git a/cmake/toolchains/x86_64-linux-gnu.cmake b/cmake/toolchains/x86_64-linux-gnu.cmake index 0248c2d8d16..7e8ab1a99c1 100644 --- a/cmake/toolchains/x86_64-linux-gnu.cmake +++ b/cmake/toolchains/x86_64-linux-gnu.cmake @@ -1,15 +1,22 @@ # CMake toolchain file for cross-compiling to x86_64 on Debian/Ubuntu # Usage: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/x86_64-linux-gnu.cmake +# The name of the target operating system set(CMAKE_SYSTEM_NAME Linux) + +# Set processor type set(CMAKE_SYSTEM_PROCESSOR x86_64) -# Specify the cross-compiler -set(CMAKE_C_COMPILER x86_64-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++) +# Set compiler prefix +set(COMPILER_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) + +# Which compilers to use for C and C++ +set(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++) +set(CMAKE_ASM_COMPILER ${COMPILER_PREFIX}-gcc) -# Set sysroot path -set(CMAKE_SYSROOT /usr/x86_64-linux-gnu) +# Here is the target environment located +set(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) # Adjust the default behavior of the FIND_XXX() commands: # search headers and libraries in the target environment, search @@ -19,10 +26,20 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -# Set the target environment paths -set(CMAKE_FIND_ROOT_PATH /usr/x86_64-linux-gnu) - # Set pkg-config environment for cross-compilation -set(ENV{PKG_CONFIG_PATH} "/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig") -set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig") -set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/x86_64-linux-gnu") \ No newline at end of file +set(ENV{PKG_CONFIG_PATH} "/usr/lib/${COMPILER_PREFIX}/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${COMPILER_PREFIX}/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/${COMPILER_PREFIX}") + +# Explicitly set OpenSSL paths for cross-compilation +set(OPENSSL_ROOT_DIR "/usr/${COMPILER_PREFIX}") +set(OPENSSL_INCLUDE_DIR "/usr/${COMPILER_PREFIX}/include") +set(OPENSSL_CRYPTO_LIBRARY "/usr/${COMPILER_PREFIX}/lib/libcrypto.so") +set(OPENSSL_SSL_LIBRARY "/usr/${COMPILER_PREFIX}/lib/libssl.so") + +# Additional library paths +set(CMAKE_LIBRARY_PATH "/usr/${COMPILER_PREFIX}/lib" ${CMAKE_LIBRARY_PATH}) +set(CMAKE_INCLUDE_PATH "/usr/${COMPILER_PREFIX}/include" ${CMAKE_INCLUDE_PATH}) + +# Packaging +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") From b1a66bbd66100b21c69b496bbfbcdccd4c842459 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 27 Sep 2025 18:13:28 -0400 Subject: [PATCH 08/14] Refactor toolchains to support GCC version via env var Updated aarch64 and x86_64 CMake toolchain files to select GCC version using the LINUX_GCC_VERSION environment variable, simplifying and unifying compiler selection. Modified linux_build.sh to export LINUX_GCC_VERSION for both native and cross-compilation, and to only update alternatives for native builds. This improves cross-compilation flexibility and reduces manual configuration. --- cmake/toolchains/aarch64-linux-gnu.cmake | 50 +++++++----------------- cmake/toolchains/x86_64-linux-gnu.cmake | 46 +++++++--------------- docker/debian-trixie.dockerfile | 4 +- docker/ubuntu-22.04.dockerfile | 4 +- docker/ubuntu-24.04.dockerfile | 4 +- scripts/linux_build.sh | 36 +++++++++++------ 6 files changed, 61 insertions(+), 83 deletions(-) diff --git a/cmake/toolchains/aarch64-linux-gnu.cmake b/cmake/toolchains/aarch64-linux-gnu.cmake index 9c62cc4791b..2a1aca880ba 100644 --- a/cmake/toolchains/aarch64-linux-gnu.cmake +++ b/cmake/toolchains/aarch64-linux-gnu.cmake @@ -1,49 +1,27 @@ # CMake toolchain file for cross-compiling to ARM64 (aarch64) on Debian/Ubuntu # Usage: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/aarch64-linux-gnu.cmake -# The name of the target operating system set(CMAKE_SYSTEM_NAME Linux) - -# Set processor type set(CMAKE_SYSTEM_PROCESSOR aarch64) -# Set compiler prefix -set(COMPILER_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) +# Use GCC version from environment variable if available +if(DEFINED ENV{LINUX_GCC_VERSION}) # cmake-lint: disable=W0106 + set(LINUX_GCC_VERSION "-$ENV{LINUX_GCC_VERSION}") +else() + set(LINUX_GCC_VERSION "") # default to no version suffix +endif() + +# Set compiler prefix and target +set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) +set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET}) # Which compilers to use for C and C++ -set(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) -set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++) -set(CMAKE_ASM_COMPILER ${COMPILER_PREFIX}-gcc) +set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION}) +set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++${LINUX_GCC_VERSION}) +set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION}) # Here is the target environment located -set(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) - -# Adjust the default behavior of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -# Set pkg-config environment for cross-compilation -set(ENV{PKG_CONFIG_PATH} "/usr/lib/${COMPILER_PREFIX}/pkgconfig:/usr/share/pkgconfig") -set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${COMPILER_PREFIX}/pkgconfig:/usr/share/pkgconfig") -set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/${COMPILER_PREFIX}") - -# Set compiler flags for cross-compilation -set(CMAKE_C_FLAGS_INIT "-march=armv8-a") -set(CMAKE_CXX_FLAGS_INIT "-march=armv8-a") - -# Explicitly set OpenSSL paths for cross-compilation -set(OPENSSL_ROOT_DIR "/usr/${COMPILER_PREFIX}") -set(OPENSSL_INCLUDE_DIR "/usr/${COMPILER_PREFIX}/include") -set(OPENSSL_CRYPTO_LIBRARY "/usr/${COMPILER_PREFIX}/lib/libcrypto.so") -set(OPENSSL_SSL_LIBRARY "/usr/${COMPILER_PREFIX}/lib/libssl.so") - -# Additional library paths -set(CMAKE_LIBRARY_PATH "/usr/${COMPILER_PREFIX}/lib" ${CMAKE_LIBRARY_PATH}) -set(CMAKE_INCLUDE_PATH "/usr/${COMPILER_PREFIX}/include" ${CMAKE_INCLUDE_PATH}) +set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET}) # Packaging set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") diff --git a/cmake/toolchains/x86_64-linux-gnu.cmake b/cmake/toolchains/x86_64-linux-gnu.cmake index 7e8ab1a99c1..41acf16888f 100644 --- a/cmake/toolchains/x86_64-linux-gnu.cmake +++ b/cmake/toolchains/x86_64-linux-gnu.cmake @@ -1,45 +1,27 @@ # CMake toolchain file for cross-compiling to x86_64 on Debian/Ubuntu # Usage: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/x86_64-linux-gnu.cmake -# The name of the target operating system set(CMAKE_SYSTEM_NAME Linux) - -# Set processor type set(CMAKE_SYSTEM_PROCESSOR x86_64) -# Set compiler prefix -set(COMPILER_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) +# Use GCC version from environment variable if available +if(DEFINED ENV{LINUX_GCC_VERSION}) # cmake-lint: disable=W0106 + set(LINUX_GCC_VERSION "-$ENV{LINUX_GCC_VERSION}") +else() + set(LINUX_GCC_VERSION "") # default to no version suffix +endif() + +# Set compiler prefix and target +set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) +set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET}) # Which compilers to use for C and C++ -set(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) -set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++) -set(CMAKE_ASM_COMPILER ${COMPILER_PREFIX}-gcc) +set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION}) +set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++${LINUX_GCC_VERSION}) +set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION}) # Here is the target environment located -set(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) - -# Adjust the default behavior of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -# Set pkg-config environment for cross-compilation -set(ENV{PKG_CONFIG_PATH} "/usr/lib/${COMPILER_PREFIX}/pkgconfig:/usr/share/pkgconfig") -set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${COMPILER_PREFIX}/pkgconfig:/usr/share/pkgconfig") -set(ENV{PKG_CONFIG_SYSROOT_DIR} "/usr/${COMPILER_PREFIX}") - -# Explicitly set OpenSSL paths for cross-compilation -set(OPENSSL_ROOT_DIR "/usr/${COMPILER_PREFIX}") -set(OPENSSL_INCLUDE_DIR "/usr/${COMPILER_PREFIX}/include") -set(OPENSSL_CRYPTO_LIBRARY "/usr/${COMPILER_PREFIX}/lib/libcrypto.so") -set(OPENSSL_SSL_LIBRARY "/usr/${COMPILER_PREFIX}/lib/libssl.so") - -# Additional library paths -set(CMAKE_LIBRARY_PATH "/usr/${COMPILER_PREFIX}/lib" ${CMAKE_LIBRARY_PATH}) -set(CMAKE_INCLUDE_PATH "/usr/${COMPILER_PREFIX}/include" ${CMAKE_INCLUDE_PATH}) +set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET}) # Packaging set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index c034e7dca98..54ebea4516c 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -2,7 +2,7 @@ # artifacts: true # platforms: linux/amd64,linux/arm64/v8 # platforms_pr: linux/amd64,linux/arm64/v8 -# no-cache-filters: sunshine-base,artifacts,sunshine +# no-cache-filters: sunshine-base,sunshine-deps,artifacts,sunshine ARG BASE=debian ARG TAG=trixie FROM ${BASE}:${TAG} AS sunshine-base @@ -58,6 +58,7 @@ else echo "Native compilation for ${TARGETPLATFORM}" fi +echo "Running dependency installation step..." ./scripts/linux_build.sh \ --step=deps \ --cuda-patches \ @@ -67,6 +68,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} apt-get clean rm -rf /var/lib/apt/lists/* +echo "Dependency installation completed." _DEPS FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 04c14bae66f..800e43df624 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -2,7 +2,7 @@ # artifacts: true # platforms: linux/amd64,linux/arm64/v8 # platforms_pr: linux/amd64,linux/arm64/v8 -# no-cache-filters: sunshine-base,artifacts,sunshine +# no-cache-filters: sunshine-base,sunshine-deps,artifacts,sunshine ARG BASE=ubuntu ARG TAG=22.04 FROM ${BASE}:${TAG} AS sunshine-base @@ -57,6 +57,7 @@ else echo "Native compilation for ${TARGETPLATFORM}" fi +echo "Running dependency installation step..." ./scripts/linux_build.sh \ --step=deps \ --ubuntu-test-repo \ @@ -66,6 +67,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} apt-get clean rm -rf /var/lib/apt/lists/* +echo "Dependency installation completed." _DEPS FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 2d0422fc7ad..3afa9115945 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -2,7 +2,7 @@ # artifacts: true # platforms: linux/amd64,linux/arm64/v8 # platforms_pr: linux/amd64,linux/arm64/v8 -# no-cache-filters: sunshine-base,artifacts,sunshine +# no-cache-filters: sunshine-base,sunshine-deps,artifacts,sunshine ARG BASE=ubuntu ARG TAG=24.04 FROM ${BASE}:${TAG} AS sunshine-base @@ -57,6 +57,7 @@ else echo "Native compilation for ${TARGETPLATFORM}" fi +echo "Running dependency installation step..." ./scripts/linux_build.sh \ --step=deps \ --sudo-off \ @@ -65,6 +66,7 @@ fi ${target_tuple:+--target-tuple=${target_tuple}} apt-get clean rm -rf /var/lib/apt/lists/* +echo "Dependency installation completed." _DEPS FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index 49d8a0f65c4..37cfa70a85d 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -521,19 +521,26 @@ function run_step_deps() { export CC=gcc-14 export CXX=g++-14 elif [ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]; then - for file in "${gcc_alternative_files[@]}"; do - file_path="/etc/alternatives/$file" - if [ -e "$file_path" ]; then - ${sudo_cmd} mv "$file_path" "$file_path.bak" - fi - done + # Export GCC version for toolchain files + export LINUX_GCC_VERSION="$gcc_version" - ${sudo_cmd} update-alternatives --install \ - /usr/bin/gcc gcc /usr/bin/gcc-${gcc_version} 100 \ - --slave /usr/bin/g++ g++ /usr/bin/g++-${gcc_version} \ - --slave /usr/bin/gcov gcov /usr/bin/gcov-${gcc_version} \ - --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-${gcc_version} \ - --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-${gcc_version} + # Only set up alternatives for native compilation + # For cross-compilation, the toolchain files will handle compiler selection + if [ "$cross_compile" == 0 ]; then + for file in "${gcc_alternative_files[@]}"; do + file_path="/etc/alternatives/$file" + if [ -e "$file_path" ]; then + ${sudo_cmd} mv "$file_path" "$file_path.bak" + fi + done + + ${sudo_cmd} update-alternatives --install \ + /usr/bin/gcc gcc /usr/bin/gcc-${gcc_version} 100 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-${gcc_version} \ + --slave /usr/bin/gcov gcov /usr/bin/gcov-${gcc_version} \ + --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-${gcc_version} \ + --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-${gcc_version} + fi fi # compile cmake if the version is too low @@ -596,6 +603,11 @@ function run_step_cmake() { # Setup NVM environment if needed (for web UI builds) setup_nvm_environment + # Export GCC version for toolchain files (in case it wasn't set in deps step) + if [ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]; then + export LINUX_GCC_VERSION="$gcc_version" + fi + # Detect CUDA path using the reusable function nvcc_path="" if [ "$skip_cuda" == 0 ]; then From bf05ac5255ec9eaab4ebd868437860fbd54d0353 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 27 Sep 2025 19:11:13 -0400 Subject: [PATCH 09/14] Improve multi-platform support in Dockerfiles Update Debian Trixie and Ubuntu Dockerfiles to better support cross-compilation by passing BUILDPLATFORM and TARGETPLATFORM as build arguments, improving log output, and ensuring dependency installation and cache cleanup are specific to the target platform. This enhances build reproducibility and clarity for multi-architecture builds. --- docker/debian-trixie.dockerfile | 17 +++++++++++++---- docker/ubuntu-22.04.dockerfile | 17 +++++++++++++---- docker/ubuntu-24.04.dockerfile | 17 +++++++++++++---- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index 54ebea4516c..681a533469a 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -9,11 +9,15 @@ FROM ${BASE}:${TAG} AS sunshine-base ENV DEBIAN_FRONTEND=noninteractive -# Force this stage to run on the build platform for cross-compilation setup +# Dependencies stage - runs on build platform but installs deps for target platform FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-deps ENV DEBIAN_FRONTEND=noninteractive +# Pass through build arguments +ARG BUILDPLATFORM +ARG TARGETPLATFORM + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script and necessary files first for better layer caching @@ -21,12 +25,15 @@ WORKDIR /build/sunshine/ COPY --link scripts/linux_build.sh ./scripts/linux_build.sh COPY --link packaging/linux/patches/ ./packaging/linux/patches/ -# Install dependencies first - this layer will be cached +# Install dependencies first - this layer will be cached per target platform RUN <<_DEPS #!/bin/bash set -e chmod +x ./scripts/linux_build.sh +echo "BUILDPLATFORM: ${BUILDPLATFORM}" +echo "TARGETPLATFORM: ${TARGETPLATFORM}" + # Set up cross-compilation variables if building for different platform if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" @@ -58,7 +65,7 @@ else echo "Native compilation for ${TARGETPLATFORM}" fi -echo "Running dependency installation step..." +echo "Running dependency installation step for ${TARGETPLATFORM}..." ./scripts/linux_build.sh \ --step=deps \ --cuda-patches \ @@ -66,9 +73,11 @@ echo "Running dependency installation step..." ${cross_compile} \ ${target_arch:+--target-arch=${target_arch}} \ ${target_tuple:+--target-tuple=${target_tuple}} + +echo "Cleaning up package cache..." apt-get clean rm -rf /var/lib/apt/lists/* -echo "Dependency installation completed." +echo "Dependency installation completed for ${TARGETPLATFORM}." _DEPS FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 800e43df624..ee5ad90f70e 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -9,23 +9,30 @@ FROM ${BASE}:${TAG} AS sunshine-base ENV DEBIAN_FRONTEND=noninteractive -# Force this stage to run on the build platform for cross-compilation setup +# Dependencies stage - runs on build platform but installs deps for target platform FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-deps ENV DEBIAN_FRONTEND=noninteractive +# Pass through build arguments +ARG BUILDPLATFORM +ARG TARGETPLATFORM + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script first for better layer caching WORKDIR /build/sunshine/ COPY --link scripts/linux_build.sh ./scripts/linux_build.sh -# Install dependencies first - this layer will be cached +# Install dependencies first - this layer will be cached per target platform RUN <<_DEPS #!/bin/bash set -e chmod +x ./scripts/linux_build.sh +echo "BUILDPLATFORM: ${BUILDPLATFORM}" +echo "TARGETPLATFORM: ${TARGETPLATFORM}" + # Set up cross-compilation variables if building for different platform if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" @@ -57,7 +64,7 @@ else echo "Native compilation for ${TARGETPLATFORM}" fi -echo "Running dependency installation step..." +echo "Running dependency installation step for ${TARGETPLATFORM}..." ./scripts/linux_build.sh \ --step=deps \ --ubuntu-test-repo \ @@ -65,9 +72,11 @@ echo "Running dependency installation step..." ${cross_compile} \ ${target_arch:+--target-arch=${target_arch}} \ ${target_tuple:+--target-tuple=${target_tuple}} + +echo "Cleaning up package cache..." apt-get clean rm -rf /var/lib/apt/lists/* -echo "Dependency installation completed." +echo "Dependency installation completed for ${TARGETPLATFORM}." _DEPS FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 3afa9115945..b9017453ef6 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -9,23 +9,30 @@ FROM ${BASE}:${TAG} AS sunshine-base ENV DEBIAN_FRONTEND=noninteractive -# Force this stage to run on the build platform for cross-compilation setup +# Dependencies stage - runs on build platform but installs deps for target platform FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-deps ENV DEBIAN_FRONTEND=noninteractive +# Pass through build arguments +ARG BUILDPLATFORM +ARG TARGETPLATFORM + SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy only the build script first for better layer caching WORKDIR /build/sunshine/ COPY --link scripts/linux_build.sh ./scripts/linux_build.sh -# Install dependencies first - this layer will be cached +# Install dependencies first - this layer will be cached per target platform RUN <<_DEPS #!/bin/bash set -e chmod +x ./scripts/linux_build.sh +echo "BUILDPLATFORM: ${BUILDPLATFORM}" +echo "TARGETPLATFORM: ${TARGETPLATFORM}" + # Set up cross-compilation variables if building for different platform if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then cross_compile="--cross-compile" @@ -57,16 +64,18 @@ else echo "Native compilation for ${TARGETPLATFORM}" fi -echo "Running dependency installation step..." +echo "Running dependency installation step for ${TARGETPLATFORM}..." ./scripts/linux_build.sh \ --step=deps \ --sudo-off \ ${cross_compile} \ ${target_arch:+--target-arch=${target_arch}} \ ${target_tuple:+--target-tuple=${target_tuple}} + +echo "Cleaning up package cache..." apt-get clean rm -rf /var/lib/apt/lists/* -echo "Dependency installation completed." +echo "Dependency installation completed for ${TARGETPLATFORM}." _DEPS FROM --platform=$BUILDPLATFORM sunshine-deps AS sunshine-build From a14098ef1e755fa1b838897177b5306463b19a9e Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 27 Sep 2025 20:01:19 -0400 Subject: [PATCH 10/14] Add --use-aptitude option for package management Introduces a --use-aptitude flag to scripts/linux_build.sh and updates Dockerfiles to support using aptitude instead of apt for package management on Debian/Ubuntu systems. This provides an alternative package manager for improved dependency resolution. --- docker/debian-trixie.dockerfile | 1 + docker/ubuntu-22.04.dockerfile | 1 + docker/ubuntu-24.04.dockerfile | 1 + scripts/linux_build.sh | 30 ++++++++++++++++++++++++++++-- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index 681a533469a..321eba92220 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -70,6 +70,7 @@ echo "Running dependency installation step for ${TARGETPLATFORM}..." --step=deps \ --cuda-patches \ --sudo-off \ + --use-aptitude \ ${cross_compile} \ ${target_arch:+--target-arch=${target_arch}} \ ${target_tuple:+--target-tuple=${target_tuple}} diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index ee5ad90f70e..1bc4d6ce34f 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -69,6 +69,7 @@ echo "Running dependency installation step for ${TARGETPLATFORM}..." --step=deps \ --ubuntu-test-repo \ --sudo-off \ + --use-aptitude \ ${cross_compile} \ ${target_arch:+--target-arch=${target_arch}} \ ${target_tuple:+--target-tuple=${target_tuple}} diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index b9017453ef6..780f8b5beb6 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -68,6 +68,7 @@ echo "Running dependency installation step for ${TARGETPLATFORM}..." ./scripts/linux_build.sh \ --step=deps \ --sudo-off \ + --use-aptitude \ ${cross_compile} \ ${target_arch:+--target-arch=${target_arch}} \ ${target_tuple:+--target-tuple=${target_tuple}} diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index 37cfa70a85d..34a7ce871ef 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -24,6 +24,7 @@ sudo_cmd="sudo" target_arch="" target_tuple="" ubuntu_test_repo=0 +use_aptitude=0 step="all" # common variables @@ -102,6 +103,7 @@ Options: --target-arch Target architecture for cross compilation (e.g., arm64, amd64). --target-tuple Target tuple for cross compilation (e.g., aarch64-linux-gnu, x86_64-linux-gnu). --ubuntu-test-repo Install ppa:ubuntu-toolchain-r/test repo on Ubuntu. + --use-aptitude Use aptitude instead of apt for package management on Debian/Ubuntu systems. --step Which step(s) to run: deps, cmake, validation, build, package, cleanup, or all (default: all) Steps: @@ -157,6 +159,7 @@ while getopts ":hs-:" opt; do target_tuple="${OPTARG#*=}" ;; ubuntu-test-repo) ubuntu_test_repo=1 ;; + use-aptitude) use_aptitude=1 ;; step=*) step="${OPTARG#*=}" ;; @@ -495,8 +498,24 @@ if [[ "$(printf '%s\n' "$installed_version" "$min_version" | sort -V | head -n1) function run_step_deps() { echo "Running step: Install dependencies" - # Update the package list - $package_update_command + # Update the package list using apt-get first (even if aptitude is requested) + if [ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]; then + ${sudo_cmd} apt-get update + else + # For non-Debian systems, use their standard update command + $package_update_command + fi + + # Install aptitude first if requested for Debian/Ubuntu systems + if [ "$use_aptitude" == 1 ] && ([ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]); then + echo "Installing aptitude package manager..." + ${sudo_cmd} apt-get install -y aptitude + echo "Aptitude installed successfully" + + # Now update with aptitude + echo "Updating package lists with aptitude..." + ${sudo_cmd} aptitude update + fi if [ "$distro" == "arch" ]; then add_arch_deps @@ -856,6 +875,13 @@ else exit 1 fi +# Override package commands if aptitude is requested for Debian/Ubuntu systems +if [ "$use_aptitude" == 1 ] && ([ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]); then + echo "Using aptitude for package management" + package_update_command="${sudo_cmd} aptitude update" + package_install_command="${sudo_cmd} aptitude install -y" +fi + architecture=$(uname -m) # Override architecture for cross-compilation From 4f4f061797b708c888dcf5b73289a0d2c73673ce Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 27 Sep 2025 20:35:00 -0400 Subject: [PATCH 11/14] Add option to update Ubuntu sources for cross-compilation Introduces the --update-sources flag to update Ubuntu sources.list for cross-compilation scenarios. Adds the update_ubuntu_sources function, which configures the appropriate sources based on Ubuntu version and target architecture, and integrates this step into the dependency installation process when requested. --- docker/debian-trixie.dockerfile | 2 +- docker/ubuntu-22.04.dockerfile | 3 +- docker/ubuntu-24.04.dockerfile | 3 +- scripts/linux_build.sh | 115 ++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 3 deletions(-) diff --git a/docker/debian-trixie.dockerfile b/docker/debian-trixie.dockerfile index 321eba92220..fbf7900f1da 100644 --- a/docker/debian-trixie.dockerfile +++ b/docker/debian-trixie.dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # artifacts: true # platforms: linux/amd64,linux/arm64/v8 -# platforms_pr: linux/amd64,linux/arm64/v8 +# platforms_pr: linux/arm64/v8 # no-cache-filters: sunshine-base,sunshine-deps,artifacts,sunshine ARG BASE=debian ARG TAG=trixie diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 1bc4d6ce34f..60d8520daa6 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # artifacts: true # platforms: linux/amd64,linux/arm64/v8 -# platforms_pr: linux/amd64,linux/arm64/v8 +# platforms_pr: linux/arm64/v8 # no-cache-filters: sunshine-base,sunshine-deps,artifacts,sunshine ARG BASE=ubuntu ARG TAG=22.04 @@ -69,6 +69,7 @@ echo "Running dependency installation step for ${TARGETPLATFORM}..." --step=deps \ --ubuntu-test-repo \ --sudo-off \ + --update-sources \ --use-aptitude \ ${cross_compile} \ ${target_arch:+--target-arch=${target_arch}} \ diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 780f8b5beb6..6fbad281c90 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # artifacts: true # platforms: linux/amd64,linux/arm64/v8 -# platforms_pr: linux/amd64,linux/arm64/v8 +# platforms_pr: linux/arm64/v8 # no-cache-filters: sunshine-base,sunshine-deps,artifacts,sunshine ARG BASE=ubuntu ARG TAG=24.04 @@ -68,6 +68,7 @@ echo "Running dependency installation step for ${TARGETPLATFORM}..." ./scripts/linux_build.sh \ --step=deps \ --sudo-off \ + --update-sources \ --use-aptitude \ ${cross_compile} \ ${target_arch:+--target-arch=${target_arch}} \ diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index 34a7ce871ef..d5a8111ce01 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -25,6 +25,7 @@ target_arch="" target_tuple="" ubuntu_test_repo=0 use_aptitude=0 +update_sources=0 step="all" # common variables @@ -104,6 +105,7 @@ Options: --target-tuple Target tuple for cross compilation (e.g., aarch64-linux-gnu, x86_64-linux-gnu). --ubuntu-test-repo Install ppa:ubuntu-toolchain-r/test repo on Ubuntu. --use-aptitude Use aptitude instead of apt for package management on Debian/Ubuntu systems. + --update-sources Update Ubuntu sources.list for cross-compilation (Ubuntu only, off by default). --step Which step(s) to run: deps, cmake, validation, build, package, cleanup, or all (default: all) Steps: @@ -160,6 +162,7 @@ while getopts ":hs-:" opt; do ;; ubuntu-test-repo) ubuntu_test_repo=1 ;; use-aptitude) use_aptitude=1 ;; + update-sources) update_sources=1 ;; step=*) step="${OPTARG#*=}" ;; @@ -495,9 +498,121 @@ if [[ "$(printf '%s\n' "$installed_version" "$min_version" | sort -V | head -n1) fi } +function update_ubuntu_sources() { + echo "Updating Ubuntu sources for cross-compilation..." + + if [ "$distro" != "ubuntu" ]; then + echo "Sources update only supported on Ubuntu, skipping..." + return + fi + + if [ "$cross_compile" != 1 ] || [ -z "$target_arch" ]; then + echo "Not cross-compiling, skipping sources update..." + return + fi + + # Use existing distribution detection variables + local dist_name + local ubuntu_version + local ubuntu_major_version + + # Extract codename from /etc/os-release + dist_name=$(grep '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2 | tr -d '"') + + # Use the version variable already set by main detection logic + ubuntu_version="$version" + ubuntu_major_version=${ubuntu_version%%.*} + + echo "Detected Ubuntu distribution: $dist_name" + echo "Detected Ubuntu version: $ubuntu_version" + echo "Detected Ubuntu major version: $ubuntu_major_version" + + # Determine mirror URL + local mirror="https://ports.ubuntu.com/ubuntu-ports" + + # Add target architecture + echo "Adding architecture: $target_arch" + ${sudo_cmd} dpkg --add-architecture "$target_arch" + + # Determine source file location based on Ubuntu version + local source_file + if [[ $ubuntu_major_version -ge 24 ]]; then + source_file="/etc/apt/sources.list.d/ubuntu.sources" + else + source_file="/etc/apt/sources.list" + fi + + echo "Using sources file: $source_file" + + # Backup original sources + echo "Backing up original sources file..." + ${sudo_cmd} cp "$source_file" "${source_file}.bak" + + # Print original sources for debugging + echo "Original sources:" + ${sudo_cmd} cat "$source_file" + echo "----" + + # Update sources based on Ubuntu version + if [[ $ubuntu_major_version -ge 24 ]]; then + # Ubuntu 24.04+ uses the new .sources format + local extra_sources + extra_sources=$(cat < /dev/null + else + # Ubuntu 22.04 and earlier use the traditional sources.list format + # Fix original sources to specify amd64 architecture + ${sudo_cmd} sed -i -e "s#deb mirror#deb [arch=$(dpkg --print-architecture)] mirror#g" "$source_file" + + # Add cross-compilation sources + local extra_sources + extra_sources=$(cat < /dev/null + fi + + echo "----" + echo "Updated sources:" + ${sudo_cmd} cat "$source_file" + echo "----" + + echo "Ubuntu sources updated successfully for cross-compilation" +} + function run_step_deps() { echo "Running step: Install dependencies" + # Update Ubuntu sources for cross-compilation if requested + if [ "$update_sources" == 1 ]; then + update_ubuntu_sources + fi + # Update the package list using apt-get first (even if aptitude is requested) if [ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]; then ${sudo_cmd} apt-get update From 1cb6b6bc1e680a425b7e4afb6d093cc2b7444a1a Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 27 Sep 2025 21:10:33 -0400 Subject: [PATCH 12/14] Refactor cross-compilation setup in Ubuntu Dockerfiles Reorders and updates the dependency installation steps for cross-compilation in ubuntu-22.04 and ubuntu-24.04 Dockerfiles. Now updates sources for cross-compilation before adding architecture, and removes redundant dpkg and apt-get update commands. This improves reliability and consistency of the build process. --- docker/ubuntu-22.04.dockerfile | 38 ++++++++++++++++++++-------------- docker/ubuntu-24.04.dockerfile | 35 ++++++++++++++++++------------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 60d8520daa6..5b318e98493 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -51,29 +51,37 @@ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then ;; esac - # Enable multiarch support for cross-compilation - dpkg --add-architecture ${target_arch} - apt-get update - echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" echo "Target arch: ${target_arch}, Target triple: ${target_tuple}" + + # First update sources for cross-compilation BEFORE adding architecture + echo "Updating sources for cross-compilation..." + ./scripts/linux_build.sh \ + --step=deps \ + --ubuntu-test-repo \ + --sudo-off \ + --update-sources \ + --use-aptitude \ + --skip-package \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} else cross_compile="" target_arch=$(dpkg --print-architecture) target_tuple="" echo "Native compilation for ${TARGETPLATFORM}" -fi -echo "Running dependency installation step for ${TARGETPLATFORM}..." -./scripts/linux_build.sh \ - --step=deps \ - --ubuntu-test-repo \ - --sudo-off \ - --update-sources \ - --use-aptitude \ - ${cross_compile} \ - ${target_arch:+--target-arch=${target_arch}} \ - ${target_tuple:+--target-tuple=${target_tuple}} + echo "Running dependency installation step for ${TARGETPLATFORM}..." + ./scripts/linux_build.sh \ + --step=deps \ + --ubuntu-test-repo \ + --sudo-off \ + --use-aptitude \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} +fi echo "Cleaning up package cache..." apt-get clean diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 6fbad281c90..1a77c1357c8 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -51,28 +51,35 @@ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then ;; esac - # Enable multiarch support for cross-compilation - dpkg --add-architecture ${target_arch} - apt-get update - echo "Cross-compiling from ${BUILDPLATFORM} to ${TARGETPLATFORM}" echo "Target arch: ${target_arch}, Target triple: ${target_tuple}" + + # First update sources for cross-compilation BEFORE adding architecture + echo "Updating sources for cross-compilation..." + ./scripts/linux_build.sh \ + --step=deps \ + --sudo-off \ + --update-sources \ + --use-aptitude \ + --skip-package \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} else cross_compile="" target_arch=$(dpkg --print-architecture) target_tuple="" echo "Native compilation for ${TARGETPLATFORM}" -fi -echo "Running dependency installation step for ${TARGETPLATFORM}..." -./scripts/linux_build.sh \ - --step=deps \ - --sudo-off \ - --update-sources \ - --use-aptitude \ - ${cross_compile} \ - ${target_arch:+--target-arch=${target_arch}} \ - ${target_tuple:+--target-tuple=${target_tuple}} + echo "Running dependency installation step for ${TARGETPLATFORM}..." + ./scripts/linux_build.sh \ + --step=deps \ + --sudo-off \ + --use-aptitude \ + ${cross_compile} \ + ${target_arch:+--target-arch=${target_arch}} \ + ${target_tuple:+--target-tuple=${target_tuple}} +fi echo "Cleaning up package cache..." apt-get clean From 6dbc352e154e35b648e2fa976c185c3542ba8a73 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 27 Sep 2025 23:22:39 -0400 Subject: [PATCH 13/14] Improve cross-compilation support for Linux builds Enhanced CMake toolchain files for aarch64 and x86_64 to better support cross-compilation, including improved root paths, pkg-config configuration, and OpenSSL hints. Updated linux_build.sh to refine dependency installation for cross-compiling, ensure ca-certificates are installed early, and improve handling of Ubuntu sources for both native and cross architectures, supporting new and old sources formats. --- .dockerignore | 1 - cmake/toolchains/aarch64-linux-gnu.cmake | 30 ++++++++++- cmake/toolchains/x86_64-linux-gnu.cmake | 24 ++++++++- scripts/linux_build.sh | 67 ++++++++++++++---------- 4 files changed, 91 insertions(+), 31 deletions(-) diff --git a/.dockerignore b/.dockerignore index d848043e2dc..4d1a6fc1069 100644 --- a/.dockerignore +++ b/.dockerignore @@ -26,7 +26,6 @@ third-party/build-deps/dist/FreeBSD* third-party/build-deps/dist/Windows* # ignore non Linux third-party submodules -third-party/libdisplaydevice third-party/TPCircularBuffer # ignore artifacts diff --git a/cmake/toolchains/aarch64-linux-gnu.cmake b/cmake/toolchains/aarch64-linux-gnu.cmake index 2a1aca880ba..a9f34ef10ad 100644 --- a/cmake/toolchains/aarch64-linux-gnu.cmake +++ b/cmake/toolchains/aarch64-linux-gnu.cmake @@ -21,7 +21,35 @@ set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++${LINUX_GCC_VERSION}) set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION}) # Here is the target environment located -set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET}) +set(CMAKE_FIND_ROOT_PATH + /usr/${CMAKE_C_COMPILER_TARGET} + /usr/lib/${CMAKE_C_COMPILER_TARGET} + /usr/include/${CMAKE_C_COMPILER_TARGET} +) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# OpenSSL hints for cross-compilation +set(OPENSSL_ROOT_DIR /usr/${CMAKE_C_COMPILER_TARGET}) +set(OPENSSL_INCLUDE_DIR /usr/include/${CMAKE_C_COMPILER_TARGET}) +set(OPENSSL_CRYPTO_LIBRARY /usr/lib/${CMAKE_C_COMPILER_TARGET}/libcrypto.so) +set(OPENSSL_SSL_LIBRARY /usr/lib/${CMAKE_C_COMPILER_TARGET}/libssl.so) + +# Configure pkg-config for cross-compilation +set(ENV{PKG_CONFIG_PATH} "/usr/lib/${CMAKE_C_COMPILER_TARGET}/pkgconfig") +set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${CMAKE_C_COMPILER_TARGET}/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_SYSROOT_DIR} "/") + +# Use the cross-compilation pkg-config if available +find_program(PKG_CONFIG_EXECUTABLE NAMES ${CMAKE_C_COMPILER_TARGET}-pkg-config pkg-config) +if(PKG_CONFIG_EXECUTABLE) + set(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_EXECUTABLE}) +endif() # Packaging set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") diff --git a/cmake/toolchains/x86_64-linux-gnu.cmake b/cmake/toolchains/x86_64-linux-gnu.cmake index 41acf16888f..7dc24e33251 100644 --- a/cmake/toolchains/x86_64-linux-gnu.cmake +++ b/cmake/toolchains/x86_64-linux-gnu.cmake @@ -21,7 +21,29 @@ set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++${LINUX_GCC_VERSION}) set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc${LINUX_GCC_VERSION}) # Here is the target environment located -set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET}) +set(CMAKE_FIND_ROOT_PATH + /usr/${CMAKE_C_COMPILER_TARGET} + /usr/lib/${CMAKE_C_COMPILER_TARGET} + /usr/include/${CMAKE_C_COMPILER_TARGET} +) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# Configure pkg-config for cross-compilation +set(ENV{PKG_CONFIG_PATH} "/usr/lib/${CMAKE_C_COMPILER_TARGET}/pkgconfig") +set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${CMAKE_C_COMPILER_TARGET}/pkgconfig:/usr/share/pkgconfig") +set(ENV{PKG_CONFIG_SYSROOT_DIR} "/") + +# Use the cross-compilation pkg-config if available +find_program(PKG_CONFIG_EXECUTABLE NAMES ${CMAKE_C_COMPILER_TARGET}-pkg-config pkg-config) +if(PKG_CONFIG_EXECUTABLE) + set(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_EXECUTABLE}) +endif() # Packaging set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index d5a8111ce01..ef12e8e6ae7 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -232,13 +232,6 @@ function add_arch_deps() { } function add_debian_based_deps() { - # If cross-compiling, we need the cross toolchain - if [ "$cross_compile" == 1 ] && [ -n "$target_arch" ]; then - dependencies+=( - "crossbuild-essential-${target_arch}" - ) - fi - dependencies+=( "appstream" "appstream-util" @@ -257,12 +250,13 @@ function add_debian_based_deps() { "xvfb" # necessary for headless unit testing ) - # Add GCC for the target architecture + if [ "$cross_compile" == 1 ] && [ -n "$target_arch" ]; then - dependencies+=("gcc-${gcc_version}") - dependencies+=("g++-${gcc_version}") # Cross-compile specific library packages with architecture suffix dependencies+=( + "crossbuild-essential-${target_arch}" + "gcc-${gcc_version}-aarch64-linux-gnu" + "g++-${gcc_version}-aarch64-linux-gnu" "libcap-dev:${target_arch}" # KMS "libcurl4-openssl-dev:${target_arch}" "libdrm-dev:${target_arch}" # KMS @@ -511,6 +505,11 @@ function update_ubuntu_sources() { return fi + # Install ca-certificates first to avoid SSL issues + echo "Installing ca-certificates for HTTPS repositories..." + ${sudo_cmd} apt-get update || true # Allow this to fail initially + ${sudo_cmd} apt-get install -y ca-certificates || true + # Use existing distribution detection variables local dist_name local ubuntu_version @@ -527,8 +526,10 @@ function update_ubuntu_sources() { echo "Detected Ubuntu version: $ubuntu_version" echo "Detected Ubuntu major version: $ubuntu_major_version" - # Determine mirror URL - local mirror="https://ports.ubuntu.com/ubuntu-ports" + # Determine mirror URLs + local main_mirror="http://archive.ubuntu.com/ubuntu" + local ports_mirror="http://ports.ubuntu.com/ubuntu-ports" + local security_mirror="http://security.ubuntu.com/ubuntu" # Add target architecture echo "Adding architecture: $target_arch" @@ -556,24 +557,34 @@ function update_ubuntu_sources() { # Update sources based on Ubuntu version if [[ $ubuntu_major_version -ge 24 ]]; then # Ubuntu 24.04+ uses the new .sources format - local extra_sources - extra_sources=$(cat < /dev/null + echo "$new_sources" | ${sudo_cmd} tee "$source_file" > /dev/null else # Ubuntu 22.04 and earlier use the traditional sources.list format # Fix original sources to specify amd64 architecture @@ -582,16 +593,16 @@ VAREOF # Add cross-compilation sources local extra_sources extra_sources=$(cat < /dev/null From 502c265d1bece41a581aba0adc612be90bd8fd99 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:02:05 -0400 Subject: [PATCH 14/14] Add CUDA cross-compilation support for ARM64 Enhances the linux_build.sh script to support cross-compiling CUDA for ARM64 (SBSA) targets. Adds logic to install CUDA cross packages and handle patching for cross-compilation scenarios. Also updates package installation commands to use --no-install-recommends for improved reproducibility and smaller installs. --- scripts/linux_build.sh | 52 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index ef12e8e6ae7..07ceba2cf45 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -411,6 +411,22 @@ function install_cuda() { local cuda_suffix="_sbsa" fi + # if cross compiling for aarch64 + if [ "$cross_compile" == 1 ] && [ "$target_arch" == "arm64" ] && [ -n "$cuda_cross_deb" ]; then + echo "Installing CUDA cross SBSA packages for ARM64 target..." + wget "${cuda_prefix}/repos/${cuda_cross_deb}" --progress=bar:force:noscroll -q --show-progress -O "cuda_cross.deb" + ${sudo_cmd} dpkg -i "cuda_cross.deb" + $package_update_command + $package_install_command "${cuda_cross_package}" + + # Now install the host x86_64 CUDA toolkit using the existing logic + # Temporarily override architecture to get x86_64 .run file + echo "Installing host x86_64 CUDA toolkit for cross-compilation build tools..." + local saved_architecture="$architecture" + architecture="x86_64" + cuda_suffix="" # x86_64 doesn't use _sbsa suffix + fi + if [ "$architecture" == "aarch64" ]; then # we need to patch the math-vector.h file for aarch64 fedora # back up /usr/include/bits/math-vector.h @@ -442,7 +458,12 @@ function install_cuda() { # run cuda patches if [ "$cuda_patches" == 1 ]; then echo "Applying CUDA patches" - local patch_dir="${script_dir}/../packaging/linux/patches/${architecture}" + # For cross-compilation, use x86_64 patches since we're installing the host toolkit + local patch_arch="$architecture" + if [ "$cross_compile" == 1 ] && [ "$target_arch" == "arm64" ]; then + patch_arch="x86_64" + fi + local patch_dir="${script_dir}/../packaging/linux/patches/${patch_arch}" if [ -d "$patch_dir" ]; then for patch in "$patch_dir"/*.patch; do echo "Applying patch: $patch" @@ -453,9 +474,14 @@ function install_cuda() { < "$patch" done else - echo "No patches found for architecture: $architecture" + echo "No patches found for architecture: $patch_arch" fi fi + + # Restore original architecture if we temporarily changed it for cross-compilation + if [ "$cross_compile" == 1 ] && [ "$target_arch" == "arm64" ] && [ -n "$saved_architecture" ]; then + architecture="$saved_architecture" + fi } function check_version() { @@ -508,7 +534,7 @@ function update_ubuntu_sources() { # Install ca-certificates first to avoid SSL issues echo "Installing ca-certificates for HTTPS repositories..." ${sudo_cmd} apt-get update || true # Allow this to fail initially - ${sudo_cmd} apt-get install -y ca-certificates || true + ${sudo_cmd} apt-get install -y --no-install-recommends ca-certificates || true # Use existing distribution detection variables local dist_name @@ -635,7 +661,7 @@ function run_step_deps() { # Install aptitude first if requested for Debian/Ubuntu systems if [ "$use_aptitude" == 1 ] && ([ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]); then echo "Installing aptitude package manager..." - ${sudo_cmd} apt-get install -y aptitude + ${sudo_cmd} apt-get install -y --no-install-recommends aptitude echo "Aptitude installed successfully" # Now update with aptitude @@ -935,18 +961,22 @@ elif grep -q "Debian GNU/Linux 12 (bookworm)" /etc/os-release; then distro="debian" version="12" package_update_command="${sudo_cmd} apt-get update" - package_install_command="${sudo_cmd} apt-get install -y" + package_install_command="${sudo_cmd} apt-get install -y --no-install-recommends" cuda_version="12.9.1" cuda_build="575.57.08" + cuda_cross_deb="debian12/cross-linux-sbsa/cuda-keyring_1.1-1_all.deb" + cuda_cross_package="cuda-cross-sbsa-12-9" gcc_version="13" nvm_node=0 elif grep -q "Debian GNU/Linux 13 (trixie)" /etc/os-release; then distro="debian" version="13" package_update_command="${sudo_cmd} apt-get update" - package_install_command="${sudo_cmd} apt-get install -y" + package_install_command="${sudo_cmd} apt-get install -y --no-install-recommends" cuda_version="12.9.1" cuda_build="575.57.08" + cuda_cross_deb="debian12/cross-linux-sbsa/cuda-keyring_1.1-1_all.deb" + cuda_cross_package="cuda-cross-sbsa-12-9" gcc_version="14" nvm_node=0 elif grep -q "PLATFORM_ID=\"platform:f41\"" /etc/os-release; then @@ -973,25 +1003,29 @@ elif grep -q "Ubuntu 22.04" /etc/os-release; then distro="ubuntu" version="22.04" package_update_command="${sudo_cmd} apt-get update" - package_install_command="${sudo_cmd} apt-get install -y" + package_install_command="${sudo_cmd} apt-get install -y --no-install-recommends" cuda_version="12.9.1" cuda_build="575.57.08" + cuda_cross_deb="ubuntu2204/cross-linux-sbsa/cuda-keyring_1.1-1_all.deb" + cuda_cross_package="cuda-cross-sbsa-12-9" gcc_version="13" nvm_node=1 elif grep -q "Ubuntu 24.04" /etc/os-release; then distro="ubuntu" version="24.04" package_update_command="${sudo_cmd} apt-get update" - package_install_command="${sudo_cmd} apt-get install -y" + package_install_command="${sudo_cmd} apt-get install -y --no-install-recommends" cuda_version="12.9.1" cuda_build="575.57.08" + cuda_cross_deb="ubuntu2404/cross-linux-sbsa/cuda-keyring_1.1-1_all.deb" + cuda_cross_package="cuda-cross-sbsa-12-9" gcc_version="14" nvm_node=1 elif grep -q "Ubuntu 25.04" /etc/os-release; then distro="ubuntu" version="25.04" package_update_command="${sudo_cmd} apt-get update" - package_install_command="${sudo_cmd} apt-get install -y" + package_install_command="${sudo_cmd} apt-get install -y --no-install-recommends" cuda_version="12.9.1" cuda_build="575.57.08" gcc_version="14"