-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
docker/riscv64: fix cross-compiler availability for generate-dockerfile #9589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+6
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check if the file exists and examine the relevant section
find . -name "sunxi-tools.sh" -type f | head -5Repository: armbian/build Length of output: 84 🏁 Script executed: # Look for the file in extensions directory
git ls-files | grep -i sunxiRepository: 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 -20Repository: 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 -30Repository: 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 -50Repository: armbian/build Length of output: 2148 🏁 Script executed: cat -n extensions/sunxi-tools.shRepository: armbian/build Length of output: 2115 🏁 Script executed: cat -n extensions/arm64-compat-vdso.shRepository: 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.shRepository: 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.shRepository: 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 -40Repository: 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 2Repository: armbian/build Length of output: 1311 Add an explicit readiness check for the required 32-bit compiler. On riscv64, this now skips adding 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Comment on lines
+233
to
249
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 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 -nRepository: 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 -40Repository: 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 -150Repository: armbian/build Length of output: 39 🏁 Script executed: # Check for x86-specific helpers or execution paths
rg "x86|amd64" lib/functions/ -l | head -10Repository: 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 5Repository: 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 -50Repository: 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/ -lRepository: 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 -5Repository: 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 -80Repository: 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 -250Repository: 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 -20Repository: 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 -20Repository: armbian/build Length of output: 120 🏁 Script executed: # Look at the specific commit that fixed this
git show c617c393 --statRepository: armbian/build Length of output: 50370 🏁 Script executed: # Get more detail on that commit
git show c617c393Repository: 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 30Repository: 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 -20Repository: 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 -10Repository: armbian/build Length of output: 87 Clarify late prep semantics: fail fast for unsupported host/target combinations.
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 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 |
||
|
|
||
| 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 | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: armbian/build
Length of output: 91
🏁 Script executed:
Repository: armbian/build
Length of output: 743
🏁 Script executed:
Repository: armbian/build
Length of output: 2307
🏁 Script executed:
Repository: armbian/build
Length of output: 1336
🏁 Script executed:
Repository: armbian/build
Length of output: 1976
Add a
host_dependencies_readyhook to fail fast when arm64 C++ compiler is unavailable.This extension silently skips
g++-aarch64-linux-gnuon riscv64 hosts but lacks thehost_dependencies_readyhook thatarm64-compat-vdso.shuses to catch missing cross-compiler toolchains. Without this check, dependency phase succeeds and the error defers to firstaarch64-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