diff --git a/extensions/arm64-compat-vdso.sh b/extensions/arm64-compat-vdso.sh index 69857fce4a9a..af5480c2767c 100644 --- a/extensions/arm64-compat-vdso.sh +++ b/extensions/arm64-compat-vdso.sh @@ -12,6 +12,12 @@ function extension_prepare_config__arm64_compat_vdso() { } function add_host_dependencies__arm64_compat_vdso() { + # Skip cross-compilers that don't exist on non-standard host architectures (e.g., riscv64) + if [[ "${host_arch}" == "riscv64" ]]; then + display_alert "Skipping arm64-compat-vdso extension" "gcc-arm-linux-gnueabi not available on ${host_arch}" "warn" + return 0 + fi + if [[ "${KERNEL_COMPILER}" == "clang" ]]; then EXTRA_BUILD_DEPS+=" clang " else diff --git a/extensions/c-plus-plus-compiler.sh b/extensions/c-plus-plus-compiler.sh index 91e20758ea41..984e209bbeef 100644 --- a/extensions/c-plus-plus-compiler.sh +++ b/extensions/c-plus-plus-compiler.sh @@ -3,5 +3,12 @@ function add_host_dependencies__add_arm64_c_plus_plus_compiler() { display_alert "Extension: ${EXTENSION}: Adding arm64 c++ compiler to host dependencies" "g++" "debug" - declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} g++-aarch64-linux-gnu g++" # @TODO: convert to array later + + # Skip cross-compilers that don't exist on non-standard host architectures (e.g., riscv64) + if [[ "${host_arch}" != "riscv64" ]]; then + declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} g++-aarch64-linux-gnu" # @TODO: convert to array later + fi + + # Always add the native g++ compiler + declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} g++" # @TODO: convert to array later } diff --git a/extensions/sunxi-tools.sh b/extensions/sunxi-tools.sh index 93f04fbb9b60..d5576b72dfb7 100644 --- a/extensions/sunxi-tools.sh +++ b/extensions/sunxi-tools.sh @@ -3,6 +3,12 @@ # Most sunxi stuff, even if 64-bit, requires 32-bit compiler, add it. # This is only used for non-Docker, since the Docker image already has it, since it includes compilers for all architectures. function add_host_dependencies__sunxi_add_32_bit_c_compiler() { + # Skip cross-compilers that don't exist on non-standard host architectures (e.g., riscv64) + if [[ "${host_arch}" == "riscv64" ]]; then + display_alert "Skipping sunxi 32-bit compiler" "gcc-arm-linux-gnueabi not available on ${host_arch}" "warn" + return 0 + fi + display_alert "Adding armhf C compiler to host dependencies" "for sunxi bootloader compile" "debug" declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} gcc-arm-linux-gnueabi" # @TODO: convert to array later } diff --git a/lib/functions/host/docker.sh b/lib/functions/host/docker.sh index 0fabf92b879e..621e5fdf8a7a 100644 --- a/lib/functions/host/docker.sh +++ b/lib/functions/host/docker.sh @@ -268,8 +268,10 @@ function docker_cli_prepare_dockerfile() { fi declare -a -g host_dependencies=() - host_release="${DOCKER_WANTED_RELEASE}" early_prepare_host_dependencies # hooks: add_host_dependencies // host_dependencies_known - display_alert "Pre-game host dependencies for host_release '${DOCKER_WANTED_RELEASE}'" "${host_dependencies[*]}" "debug" + # Get the actual host architecture for proper cross-compiler selection + declare host_arch="$(dpkg --print-architecture)" + host_release="${DOCKER_WANTED_RELEASE}" host_arch="${host_arch}" early_prepare_host_dependencies # hooks: add_host_dependencies // host_dependencies_known + display_alert "Pre-game host dependencies for host_release '${DOCKER_WANTED_RELEASE}' host_arch '${host_arch}'" "${host_dependencies[*]}" "debug" # This includes apt install equivalent to install_host_dependencies() display_alert "Creating" "Dockerfile; FROM ${DOCKER_ARMBIAN_BASE_IMAGE}" "info" diff --git a/lib/functions/host/prepare-host.sh b/lib/functions/host/prepare-host.sh index 944398ef24e5..8a498bf548c1 100644 --- a/lib/functions/host/prepare-host.sh +++ b/lib/functions/host/prepare-host.sh @@ -230,18 +230,22 @@ function adaptative_prepare_host_dependencies() { ### ARCH declare wanted_arch="${target_arch:-"all"}" - if [[ "${wanted_arch}" == "amd64" || "${wanted_arch}" == "all" ]]; then - host_dependencies+=("gcc-x86-64-linux-gnu") # from crossbuild-essential-amd64 - fi + # Skip cross-compilers that don't exist on non-standard host architectures (e.g., riscv64) + # On riscv64, only riscv64 cross-compilers are available in the repositories + if [[ "${host_arch}" != "riscv64" ]]; then + if [[ "${wanted_arch}" == "amd64" || "${wanted_arch}" == "all" ]]; then + host_dependencies+=("gcc-x86-64-linux-gnu") # from crossbuild-essential-amd64 + fi - if [[ "${wanted_arch}" == "arm64" || "${wanted_arch}" == "all" ]]; then - # gcc-aarch64-linux-gnu: from crossbuild-essential-arm64 - # gcc-arm-linux-gnueabi: necessary for rockchip64 (and maybe other too) ATF compilation - host_dependencies+=("gcc-aarch64-linux-gnu" "gcc-arm-linux-gnueabi") - fi + if [[ "${wanted_arch}" == "arm64" || "${wanted_arch}" == "all" ]]; then + # gcc-aarch64-linux-gnu: from crossbuild-essential-arm64 + # gcc-arm-linux-gnueabi: necessary for rockchip64 (and maybe other too) ATF compilation + host_dependencies+=("gcc-aarch64-linux-gnu" "gcc-arm-linux-gnueabi") + fi - if [[ "${wanted_arch}" == "armhf" || "${wanted_arch}" == "all" ]]; then - host_dependencies+=("gcc-arm-linux-gnueabihf") # from crossbuild-essential-armhf crossbuild-essential-armel + if [[ "${wanted_arch}" == "armhf" || "${wanted_arch}" == "all" ]]; then + host_dependencies+=("gcc-arm-linux-gnueabihf") # from crossbuild-essential-armhf crossbuild-essential-armel + fi fi if [[ "${wanted_arch}" == "riscv64" || "${wanted_arch}" == "all" ]]; then @@ -254,7 +258,8 @@ function adaptative_prepare_host_dependencies() { host_dependencies+=("debian-ports-archive-keyring") fi - if [[ "${wanted_arch}" != "amd64" ]]; then + # libc6-amd64-cross is not available on riscv64 hosts + if [[ "${wanted_arch}" != "amd64" ]] && [[ "${host_arch}" != "riscv64" ]]; then host_dependencies+=("libc6-amd64-cross") # Support for running x86 binaries (under qemu on other arches) fi