Skip to content

docker/riscv64: fix cross-compiler availability for generate-dockerfile#9589

Open
igorpecovnik wants to merge 3 commits intomainfrom
fix/docker-riscv64-cross-compilers
Open

docker/riscv64: fix cross-compiler availability for generate-dockerfile#9589
igorpecovnik wants to merge 3 commits intomainfrom
fix/docker-riscv64-cross-compilers

Conversation

@igorpecovnik
Copy link
Copy Markdown
Member

@igorpecovnik igorpecovnik commented Mar 25, 2026

Summary

Fix ./compile.sh generate-dockerfile failures on native RISC-V hosts by properly detecting host architecture and skipping cross-compiler packages that don't exist in RISC-V package repositories.

Bugs

Loop devices problem (has been reported upstream):
https://github.com/armbian/os/actions/runs/23560017249/job/68609709451

Referremce

armbian/docker-armbian-build#13

Problem

When running generate-dockerfile on RISC-V hosts, the build fails with errors like:

E: Package 'gcc-x86-64-linux-gnu' has no installation candidate
E: Package 'gcc-aarch64-linux-gnu' has no installation candidate
E: Package 'gcc-arm-linux-gnueabi' has no installation candidate

This occurs because:

  1. Cross-compiler packages for x86-64, ARM64, and ARMHF don't exist in Debian/Ubuntu RISC-V repositories
  2. The host architecture wasn't being detected or passed to dependency resolution
  3. Extensions were unconditionally adding cross-compilers without checking host architecture

Solution

  • docker.sh: Detect host architecture using dpkg --print-architecture and pass it to dependency resolution functions
  • prepare-host.sh: Check host_arch and skip cross-compilers unavailable on RISC-V (x86-64, ARM64, ARMHF)
  • Extensions (c-plus-plus-compiler, arm64-compat-vdso, sunxi-tools): Check host_arch and skip unavailable cross-compilers on RISC-V

Why This Matters

This fix enables Armbian to build properly on RISC-V hardware, which is important for:

  1. RISE RISC-V Runners - Free GitHub Actions runner service providing bare-metal RISC-V CI (Scaleway EM-RV1)

  2. Native RISC-V Development - Developers can now build Armbian images natively on RISC-V workstations

  3. Multi-Arch CI/CD - Enables testing on real RISC-V hardware instead of QEMU emulation

Test plan

  • Run ./compile.sh generate-dockerfile on native RISC-V host
  • Verify Dockerfile builds without cross-compiler errors
  • Test with RISE RISC-V Runners (ubuntu-24.04-riscv)
  • Verify Armbian builds succeed on RISC-V hardware

Files changed

  • lib/functions/host/docker.sh - Detect and pass host architecture
  • lib/functions/host/prepare-host.sh - Skip unavailable cross-compilers
  • extensions/c-plus-plus-compiler.sh - Architecture-aware dependency addition
  • extensions/arm64-compat-vdso.sh - Architecture-aware dependency addition
  • extensions/sunxi-tools.sh - Architecture-aware dependency addition

Summary by CodeRabbit

  • New Features

    • Added support for RISC-V 64-bit host systems with improved architecture detection.
  • Chores

    • Optimized build dependencies to conditionally exclude unnecessary cross-compiler packages on RISC-V 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 <igor@armbian.com>
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 <igor@armbian.com>
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 <igor@armbian.com>
@igorpecovnik igorpecovnik requested a review from a team as a code owner March 25, 2026 21:25
@igorpecovnik igorpecovnik requested review from catalinii and martinayotte and removed request for a team March 25, 2026 21:25
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

The changes add RISC-V64 host architecture awareness to build dependency functions. Multiple scripts now detect when the host architecture is riscv64 and conditionally skip adding incompatible ARM and x86_64 cross-compiler packages. The docker.sh file captures the host system's Debian architecture and passes it to dependency preparation functions.

Changes

Cohort / File(s) Summary
ARM/x86_64 Cross-Compiler Gating
extensions/arm64-compat-vdso.sh, extensions/c-plus-plus-compiler.sh, extensions/sunxi-tools.sh
Added conditional checks to skip cross-compiler dependency additions when host_arch == "riscv64". Each function emits a warning alert and returns early without modifying EXTRA_BUILD_DEPS on RISC-V64 hosts.
Host Architecture Detection and Propagation
lib/functions/host/docker.sh
Enhanced to capture host system's Debian architecture via dpkg --print-architecture into host_arch variable and pass it to early_prepare_host_dependencies(). Updated status message to include resolved architecture value.
Conditional Cross-Compiler Dependencies
lib/functions/host/prepare-host.sh
Extended adaptative_prepare_host_dependencies() to conditionally append x86_64 and ARM cross-compiler packages only when host_arch is not riscv64. Expanded libc6-amd64-cross inclusion condition to exclude RISC-V64 hosts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through builds with glee,
Now RISC-V64 runs cross-compiler free!
When hosts are RISC, we skip the ARM,
Architecture-aware keeps the system calm. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: fixing cross-compiler availability for generate-dockerfile on RISC-V hosts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/docker-riscv64-cross-compilers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added 05 Milestone: Second quarter release size/medium PR with more then 50 and less then 250 lines Needs review Seeking for review Framework Framework components labels Mar 25, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@extensions/c-plus-plus-compiler.sh`:
- Around line 7-13: Add a host_dependencies_ready hook that fails fast when the
arm64 C++ cross-compiler is declared but missing: in the new
host_dependencies_ready function (use the same hook name as
arm64-compat-vdso.sh) check if host_arch != "riscv64" and then verify
availability of the cross-compiler binary (check for either
"g++-aarch64-linux-gnu" or "aarch64-linux-gnu-g++" with command -v); if not
found, emit an error and return non-zero so the dependency phase fails early.
Update the script to reference host_arch and the existing EXTRA_BUILD_DEPS logic
so the check matches when the cross-compiler was appended.

In `@extensions/sunxi-tools.sh`:
- Around line 6-10: Add a readiness-phase check that ensures the 32-bit
cross-compiler exists before allowing the dependency phase to pass: implement a
hook named host_dependencies_ready__sunxi_add_32_bit_c_compiler() (following the
pattern in arm64-compat-vdso.sh) that verifies the presence of
gcc-arm-linux-gnueabi (e.g., command -v or which) and fails readiness if it is
missing; keep the existing riscv64 early-return behavior in the current file but
ensure build_host_tools__compile_sunxi_tools() will not run later when the
compiler is absent by making the readiness hook enforce that requirement.

In `@lib/functions/host/prepare-host.sh`:
- Around line 233-249: The code currently silently skips adding cross-compiler
packages when host_arch == "riscv64", which hides unsupported host/target
combinations during late prep; update adaptative_prepare_host_dependencies() to
detect late-prep concrete targets (when wanted_arch != "all") and if host_arch
== "riscv64" and wanted_arch is not "riscv64" immediately print a clear error
referencing host_arch and wanted_arch and exit non-zero (fail fast) instead of
silently continuing; keep the existing silent-skip behavior only for
Dockerfile-generation cases where wanted_arch == "all". Ensure you reference the
variables host_arch, wanted_arch and the host_dependencies array in your change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0b55f0ab-8e0e-47ca-a2d2-c516c0651ece

📥 Commits

Reviewing files that changed from the base of the PR and between f15f594 and c617c39.

📒 Files selected for processing (5)
  • extensions/arm64-compat-vdso.sh
  • extensions/c-plus-plus-compiler.sh
  • extensions/sunxi-tools.sh
  • lib/functions/host/docker.sh
  • lib/functions/host/prepare-host.sh

Comment on lines +7 to +13
# 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, check if the file exists and examine its full content
fd "c-plus-plus-compiler.sh" -t f

Repository: armbian/build

Length of output: 91


🏁 Script executed:

# Check the full content of the extension
cat "extensions/c-plus-plus-compiler.sh"

Repository: armbian/build

Length of output: 743


🏁 Script executed:

# Compare with arm64-compat-vdso.sh to see if it has the claimed hook
cat "extensions/arm64-compat-vdso.sh"

Repository: armbian/build

Length of output: 2307


🏁 Script executed:

# Search for other host_dependencies_ready hooks in extensions
rg "host_dependencies_ready" extensions/ -A 3

Repository: armbian/build

Length of output: 1336


🏁 Script executed:

# Check how other extensions handle architecture-specific dependencies
rg "host_arch.*riscv64" extensions/ -B 2 -A 5

Repository: armbian/build

Length of output: 1976


Add a host_dependencies_ready hook to fail fast when arm64 C++ compiler is unavailable.

This extension silently skips g++-aarch64-linux-gnu on riscv64 hosts but lacks the host_dependencies_ready hook that arm64-compat-vdso.sh uses to catch missing cross-compiler toolchains. Without this check, dependency phase succeeds and the error defers to first aarch64-linux-gnu-g++ invocation. Add an explicit runtime check following the arm64-compat-vdso.sh pattern:

Suggested implementation
 function add_host_dependencies__add_arm64_c_plus_plus_compiler() {
 	display_alert "Extension: ${EXTENSION}: Adding arm64 c++ compiler to host dependencies" "g++" "debug"
 
 	# 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
 }
+
+function host_dependencies_ready__add_arm64_c_plus_plus_compiler() {
+	if ! command -v aarch64-linux-gnu-g++ >/dev/null 2>&1; then
+		exit_with_error "Missing arm64 C++ compiler 'aarch64-linux-gnu-g++'; install g++-aarch64-linux-gnu or disable this extension"
+	fi
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/c-plus-plus-compiler.sh` around lines 7 - 13, Add a
host_dependencies_ready hook that fails fast when the arm64 C++ cross-compiler
is declared but missing: in the new host_dependencies_ready function (use the
same hook name as arm64-compat-vdso.sh) check if host_arch != "riscv64" and then
verify availability of the cross-compiler binary (check for either
"g++-aarch64-linux-gnu" or "aarch64-linux-gnu-g++" with command -v); if not
found, emit an error and return non-zero so the dependency phase fails early.
Update the script to reference host_arch and the existing EXTRA_BUILD_DEPS logic
so the check matches when the cross-compiler was appended.

Comment on lines +6 to +10
# 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check if the file exists and examine the relevant section
find . -name "sunxi-tools.sh" -type f | head -5

Repository: armbian/build

Length of output: 84


🏁 Script executed:

# Look for the file in extensions directory
git ls-files | grep -i sunxi

Repository: armbian/build

Length of output: 50370


🏁 Script executed:

# Check the structure and search for host_dependencies_ready patterns
rg "host_dependencies_ready" --type sh | head -20

Repository: armbian/build

Length of output: 600


🏁 Script executed:

# Search for how other extensions handle architecture-specific dependencies
rg "if.*host_arch.*riscv64" --type sh -A 5 | head -30

Repository: armbian/build

Length of output: 2148


🏁 Script executed:

# Check the adaptative_prepare_host_dependencies pattern
rg "adaptative_prepare_host_dependencies" --type sh -B 2 -A 10 | head -50

Repository: armbian/build

Length of output: 2148


🏁 Script executed:

cat -n extensions/sunxi-tools.sh

Repository: armbian/build

Length of output: 2115


🏁 Script executed:

cat -n extensions/arm64-compat-vdso.sh

Repository: armbian/build

Length of output: 2727


🏁 Script executed:

# Check if arm64-compat-vdso has a readiness hook despite the riscv64 skip
grep -n "host_dependencies_ready" extensions/arm64-compat-vdso.sh

Repository: armbian/build

Length of output: 115


🏁 Script executed:

# Check if sunxi-tools source or makefile references arm-linux-gnueabi
rg "arm-linux-gnueabi|gcc-arm|32" extensions/sunxi-tools.sh

Repository: armbian/build

Length of output: 405


🏁 Script executed:

# Check the sunxi-tools repository to understand what gets compiled
# The fetch_sources_tools__sunxi_tools function fetches from github
# Let's check the comments and other extensions to understand the 32-bit requirement
rg "sunxi.*32|32.*sunxi" --type sh extensions/ lib/ -B 2 -A 2 | head -40

Repository: armbian/build

Length of output: 858


🏁 Script executed:

# Look at how the sunxi-tools make is called
rg "make.*tools|compile.*sunxi" extensions/sunxi-tools.sh -A 5 -B 2

Repository: armbian/build

Length of output: 1311


Add an explicit readiness check for the required 32-bit compiler.

On riscv64, this now skips adding gcc-arm-linux-gnueabi and returns success. The dependency phase passes, but the first call to build_host_tools__compile_sunxi_tools() that invokes make -s tools will fail much later. Following the pattern used in arm64-compat-vdso.sh, add a host_dependencies_ready__sunxi_add_32_bit_c_compiler() hook to validate the compiler exists at the readiness phase:

Add readiness check
 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
 }
+
+function host_dependencies_ready__sunxi_add_32_bit_c_compiler() {
+	if ! command -v arm-linux-gnueabi-gcc >/dev/null 2>&1; then
+		exit_with_error "Missing 32-bit compiler 'arm-linux-gnueabi-gcc' for sunxi bootloader compile"
+	fi
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# 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
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
}
function host_dependencies_ready__sunxi_add_32_bit_c_compiler() {
if ! command -v arm-linux-gnueabi-gcc >/dev/null 2>&1; then
exit_with_error "Missing 32-bit compiler 'arm-linux-gnueabi-gcc' for sunxi bootloader compile"
fi
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/sunxi-tools.sh` around lines 6 - 10, Add a readiness-phase check
that ensures the 32-bit cross-compiler exists before allowing the dependency
phase to pass: implement a hook named
host_dependencies_ready__sunxi_add_32_bit_c_compiler() (following the pattern in
arm64-compat-vdso.sh) that verifies the presence of gcc-arm-linux-gnueabi (e.g.,
command -v or which) and fails readiness if it is missing; keep the existing
riscv64 early-return behavior in the current file but ensure
build_host_tools__compile_sunxi_tools() will not run later when the compiler is
absent by making the readiness hook enforce that requirement.

Comment on lines +233 to 249
# 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the specific lines mentioned in the review
sed -n '230,265p' lib/functions/host/prepare-host.sh | cat -n

Repository: armbian/build

Length of output: 1952


🏁 Script executed:

# Check if adaptative_prepare_host_dependencies is used in early and late prep
rg -A 3 -B 3 "early_prepare_host_dependencies|late_prepare_host_dependencies" lib/functions/host/prepare-host.sh | head -40

Repository: armbian/build

Length of output: 1953


🏁 Script executed:

# Search for the function definition to see full context
rg "^adaptative_prepare_host_dependencies" -A 100 lib/functions/host/prepare-host.sh | head -150

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Check for x86-specific helpers or execution paths
rg "x86|amd64" lib/functions/ -l | head -10

Repository: armbian/build

Length of output: 412


🏁 Script executed:

# Check if there's documentation or CI config about riscv64 as build host
rg "riscv64" lib/functions/host/prepare-host.sh -B 5 -A 5

Repository: armbian/build

Length of output: 1558


🏁 Script executed:

# Look for actual error handling when dependencies are missing
rg "exit_with_error.*toolchain|exit_with_error.*gcc|exit_with_error.*dependency" lib/functions/host/

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Check if install_host_dependencies validates or fails on missing packages
rg "install_host_dependencies|install_host_side_packages" -A 10 lib/functions/host/prepare-host.sh | head -50

Repository: armbian/build

Length of output: 1560


🏁 Script executed:

# Search for any x86-specific execution in the codebase that would fail on riscv64
rg "x86|x86_64|amd64" lib/functions/compilation/ -l

Repository: armbian/build

Length of output: 148


🏁 Script executed:

# Check what install_host_side_packages does
rg "^install_host_side_packages" -A 30 lib/functions/host/

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Check if there's CI/test config that shows riscv64 as a build host
fd -t f "\.yml|\.yaml|Jenkinsfile|\.github" | xargs grep -l "riscv64" 2>/dev/null | head -5

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Check git history/comments for context on this riscv64 code
git log -p --all -S "riscv64, only riscv64 cross-compilers" -- lib/functions/host/prepare-host.sh 2>/dev/null | head -80

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Look for the full adaptative_prepare_host_dependencies function
rg "^function adaptative_prepare_host_dependencies" -A 200 lib/functions/host/prepare-host.sh | head -250

Repository: armbian/build

Length of output: 9168


🏁 Script executed:

# Check if there's any validation that packages actually exist
rg "install_host_side_packages" -A 50 lib/functions/host/prepare-host.sh | grep -A 30 "^function install_host_side_packages"

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Search for any PR/issue discussion about riscv64 support
git log --all --oneline --grep="riscv64" 2>/dev/null | head -20

Repository: armbian/build

Length of output: 522


🏁 Script executed:

# Check recent commits to prepare-host.sh to understand context
git log --oneline lib/functions/host/prepare-host.sh 2>/dev/null | head -20

Repository: armbian/build

Length of output: 120


🏁 Script executed:

# Look at the specific commit that fixed this
git show c617c393 --stat

Repository: armbian/build

Length of output: 50370


🏁 Script executed:

# Get more detail on that commit
git show c617c393

Repository: armbian/build

Length of output: 50377


🏁 Script executed:

# Check if install_host_side_packages validates packages exist
rg "install_host_side_packages" lib/functions/ -A 30

Repository: armbian/build

Length of output: 4818


🏁 Script executed:

# Verify if there's a way to distinguish between early (wanted_arch="all") and late prep scenarios
rg "ARCH|target_arch|HOSTARCH" lib/functions/general/main.sh | head -20

Repository: armbian/build

Length of output: 126


🏁 Script executed:

# Check if there are any riscv64 boards to understand real-world usage
fd -e conf -e csc "riscv64" config/boards/ | head -10

Repository: armbian/build

Length of output: 87


Clarify late prep semantics: fail fast for unsupported host/target combinations.

adaptative_prepare_host_dependencies() is called by both early prep (Dockerfile generation, wanted_arch="all") and late prep (real builds, wanted_arch=concrete). The current conditional silently skips toolchain packages if host_arch == "riscv64", allowing builds with unsupported host/target pairs to proceed with incomplete dependencies—violating Armbian's fail-fast principle.

For Dockerfile generation, the silent skip is benign. For late prep with a concrete target, it creates a silent failure scenario where a non-riscv64 target on a riscv64 host produces unclear compilation errors instead of a clear diagnostic.

Once wanted_arch is concrete and different from the host architecture, validate the combination and fail explicitly:

Reject unsupported host/target matrices during late prep
 	declare wanted_arch="${target_arch:-"all"}"
 
+	# Fail fast on unsupported host/target combinations once target is concrete
+	if [[ "${wanted_arch}" != "all" ]] && [[ "${host_arch}" == "riscv64" ]]; then
+		if [[ "${wanted_arch}" != "riscv64" ]]; then
+			exit_with_error "Target architecture '${wanted_arch}' requires toolchains unavailable on riscv64 hosts"
+		fi
+	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
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/functions/host/prepare-host.sh` around lines 233 - 249, The code
currently silently skips adding cross-compiler packages when host_arch ==
"riscv64", which hides unsupported host/target combinations during late prep;
update adaptative_prepare_host_dependencies() to detect late-prep concrete
targets (when wanted_arch != "all") and if host_arch == "riscv64" and
wanted_arch is not "riscv64" immediately print a clear error referencing
host_arch and wanted_arch and exit non-zero (fail fast) instead of silently
continuing; keep the existing silent-skip behavior only for
Dockerfile-generation cases where wanted_arch == "all". Ensure you reference the
variables host_arch, wanted_arch and the host_dependencies array in your change.

@igorpecovnik igorpecovnik added Work in progress Unfinished / work in progress and removed Needs review Seeking for review labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Framework Framework components size/medium PR with more then 50 and less then 250 lines Work in progress Unfinished / work in progress

Development

Successfully merging this pull request may close these issues.

1 participant