From e444cbd992a57a4ce968915e1d12e65b93789ef5 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 25 Mar 2026 21:17:30 +0100 Subject: [PATCH 1/3] docker: skip unavailable cross-compilers on riscv64 hosts When generating Dockerfiles on native riscv64 hosts, skip cross-compiler packages (gcc-x86-64-linux-gnu, gcc-aarch64-linux-gnu, gcc-arm-linux-*) that don't exist in riscv64 package repositories. This fixes generate-dockerfile failures on riscv64 hosts that tried to install non-existent cross-compilation toolchains. Signed-off-by: Igor Pecovnik --- lib/functions/host/prepare-host.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) 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 From 89b9d37e0ac84a443723e28908df9709bf212334 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 25 Mar 2026 21:24:16 +0100 Subject: [PATCH 2/3] docker: detect host architecture for cross-compiler selection When generating Dockerfiles, detect the actual host architecture using dpkg --print-architecture and pass it to early_prepare_host_dependencies. This ensures that cross-compiler packages that don't exist on certain architectures (e.g., riscv64) are properly skipped during Dockerfile generation. Signed-off-by: Igor Pecovnik --- lib/functions/host/docker.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/functions/host/docker.sh b/lib/functions/host/docker.sh index 0fabf92b879e..9c303c0f1004 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=() + # Get the actual host architecture for proper cross-compiler selection + declare host_arch="$(dpkg --print-architecture)" 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" + 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" From c617c3938ebc2fa81c5c019e30c1a7eef40664a2 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 25 Mar 2026 21:31:28 +0100 Subject: [PATCH 3/3] docker/riscv64: fix cross-compiler availability checks Fix cross-compiler package selection for riscv64 hosts in both Docker generation and extensions: - docker.sh: Detect host architecture and pass it to dependency resolution functions - extensions: Check host_arch and skip cross-compilers unavailable on riscv64 (g++-aarch64-linux-gnu, gcc-arm-linux-gnueabi) This fixes generate-dockerfile failures on native riscv64 hosts where cross-compilation toolchains for other architectures don't exist in the package repositories. Signed-off-by: Igor Pecovnik --- extensions/arm64-compat-vdso.sh | 6 ++++++ extensions/c-plus-plus-compiler.sh | 9 ++++++++- extensions/sunxi-tools.sh | 6 ++++++ lib/functions/host/docker.sh | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) 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 9c303c0f1004..621e5fdf8a7a 100644 --- a/lib/functions/host/docker.sh +++ b/lib/functions/host/docker.sh @@ -270,7 +270,7 @@ function docker_cli_prepare_dockerfile() { # Get the actual host architecture for proper cross-compiler selection declare host_arch="$(dpkg --print-architecture)" - host_release="${DOCKER_WANTED_RELEASE}" early_prepare_host_dependencies # hooks: add_host_dependencies // host_dependencies_known + 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()