Skip to content

docs: document cross-compiling in a build source and the BUILD* args - #1320

Open
atiasadir wants to merge 2 commits into
project-dalec:mainfrom
atiasadir:docs/cross-compile
Open

atiasadir wants to merge 2 commits into
project-dalec:mainfrom
atiasadir:docs/cross-compile

Conversation

@atiasadir

Copy link
Copy Markdown

What this PR does / why we need it:

When the target platform isn't native, the spec's build steps run under emulation, which is slow for compilers. A build source already avoids that: Dalec builds its Dockerfile for the target platform, so a stage with FROM --platform=$BUILDPLATFORM runs natively and can cross-compile for TARGETOS and TARGETARCH. The docs don't mention this, and the BUILDOS, BUILDARCH, BUILDPLATFORM and BUILDVARIANT spec args only appear in load.go and test/var_passthrough_test.go.

This adds:

  • sources.md: a "Cross-compiling in a build source" section under Build, with a Go example.
  • spec.md: the BUILD* args in the built-in args list, with a line on how they differ from the TARGET* args.

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Related to #843 and #842, which ask for native cross-compilation in Dalec itself. This documents what already works.

Special notes for your reviewer:

Checked with frontend 0.22.4 on an arm64 machine:

  • The example builds azlinux3/rpm and azlinux3/container for --platform linux/amd64, and the container prints hello from linux/amd64.
  • In a build source, uname -m is aarch64 for both --platform linux/amd64 and linux/arm64, TARGETPLATFORM follows --platform, and the binary's ELF machine matches the target.
  • debug/resolve with --platform linux/amd64 gives BUILDARCH=arm64 and TARGETARCH=amd64.
  • hugo --source website --gc --minify with the pinned Hugo image builds without errors.

It doesn't depend on #1301.

AI use: I used GitHub Copilot to help prepare this change and verify the example.

Signed-off-by: Adir Atias <30810249+atiasadir@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 22:42

Copilot AI left a comment

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.

🟡 Changes recommended

The documentation still needs to clarify that this path requires separate single-platform builds and that emulation guidance applies only to Linux package targets, since Windows cross-builds run on Ubuntu.

2 open issues
What changed in this PR

Documents Dalec’s existing build-source approach to native cross-compilation, complementing the broader requests in #842 and #843 without changing build behavior.

Changes:

  • Adds a Go example using FROM --platform=$BUILDPLATFORM to cross-compile for the target platform.
  • Documents the four BUILD* spec arguments and distinguishes them from TARGET*.
File Description
website/​content/​spec.md Lists BUILD* arguments and explains their relationship to --platform.
website/​content/​sources.md Adds Dockerfile and YAML examples for cross-compiling in a build source.

Review effort: Balanced

Comment thread website/content/sources.md Resolved
Comment thread website/content/sources.md Resolved
…m builds

Signed-off-by: Adir Atias <30810249+atiasadir@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants