From d5cd33d4fbad303425a41be119e8d8f8455675af Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 31 Jan 2026 23:53:41 +1100 Subject: [PATCH] fix(build): use Docker for cross-arch Linux compilation When building Linux binaries with a different target architecture than the host (e.g., arm64 on x86_64), use Docker-based cross-compilation instead of native build. The native GCC cannot compile ARM64 assembly on an x86_64 host. Adds a third condition to the build task selection: target architecture must match host architecture to use native build. Co-Authored-By: Claude Opus 4.5 --- v3/internal/commands/build_assets/linux/Taskfile.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/v3/internal/commands/build_assets/linux/Taskfile.yml b/v3/internal/commands/build_assets/linux/Taskfile.yml index e6a3d22cc..1fbde97dd 100644 --- a/v3/internal/commands/build_assets/linux/Taskfile.yml +++ b/v3/internal/commands/build_assets/linux/Taskfile.yml @@ -17,8 +17,11 @@ tasks: build: summary: Builds the application for Linux cmds: - # Linux requires CGO - use Docker when cross-compiling from non-Linux OR when no C compiler is available - - task: '{{if and (eq OS "linux") (eq .HAS_CC "true")}}build:native{{else}}build:docker{{end}}' + # Linux requires CGO - use Docker when: + # 1. Cross-compiling from non-Linux, OR + # 2. No C compiler is available, OR + # 3. Target architecture differs from host architecture (cross-arch compilation) + - task: '{{if and (eq OS "linux") (eq .HAS_CC "true") (eq .TARGET_ARCH ARCH)}}build:native{{else}}build:docker{{end}}' vars: ARCH: '{{.ARCH}}' DEV: '{{.DEV}}' @@ -26,6 +29,8 @@ tasks: vars: DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' + # Determine target architecture (defaults to host ARCH if not specified) + TARGET_ARCH: '{{.ARCH | default ARCH}}' # Check if a C compiler is available (gcc or clang) HAS_CC: sh: '(command -v gcc >/dev/null 2>&1 || command -v clang >/dev/null 2>&1) && echo "true" || echo "false"'