Skip to content

pkg/pillar: fix dhcpcd cross-compilation#5830

Draft
rucoder wants to merge 1 commit intolf-edge:masterfrom
rucoder:rucoder/fix-pillar-dhcpcd-cross-compile
Draft

pkg/pillar: fix dhcpcd cross-compilation#5830
rucoder wants to merge 1 commit intolf-edge:masterfrom
rucoder:rucoder/fix-pillar-dhcpcd-cross-compile

Conversation

@rucoder
Copy link
Copy Markdown
Contributor

@rucoder rucoder commented Apr 20, 2026

Description

THIS PR IS JSUT TO DEMONSTRATE HOW CROSS COMPILATION IS BROKEN

Cross-compiling pillar for a non-native architecture (e.g.
make ZARCH=arm64 pkg/pillar on an amd64 host) fails in the dhcpcd
build stage with:

Deriving operating system from ... x86_64-unknown-linux
...
No suitable user found for Priviledge Separation!
Using compiler .. aarch64-alpine-linux-musl-gcc
aarch64-alpine-linux-musl-gcc does not create executables

dhcpcd upstream uses a hand-rolled ./configure script (not autotools) that:

  1. Derives the target triplet from the build host's uname -m when --build/--host are not supplied, so it never realises this is a cross build and tries to produce a host-arch test executable using the cross compiler.
  2. Looks up the dhcpcd privsep user in the build host's /etc/passwd, which does not contain that user (it is only added to the runtime image later).

Even after fixing those two, the cross gcc itself still fails to link because it was built with --with-sysroot=/home/builder/sysroot-... (a path baked into the toolchain at its own build time) which does not exist in this image. The Alpine target libs/headers are copied to /usr/${EVE_TARGET_ARCH}-alpine-linux-musl by the build-cross-target stage, so we point gcc at that sysroot via --sysroot in CC. The same fix unblocks Go cgo builds further down the Dockerfile (which were silently broken too — they failed with stdlib.h: No such file or directory).

Detecting the cross build via EVE_TARGET_ARCH does not work because the eve-alpine base image already exports that variable in its own environment, so it would also be set in native builds. This PR uses CROSS_COMPILE_ENV, which is set only by the cross build stages, as the cross-compile signal.

How to test and validate this PR

On an amd64 host:

make ZARCH=arm64 pkg/pillar     # cross
make ZARCH=amd64 pkg/pillar     # native

Both should build to completion. The dhcpcd configure step should
print Configuring dhcpcd for ... linux with the correct target
triplet, and the Go vet / build steps should succeed.

I have verified locally:

  • make ZARCH=arm64 pkg/pillar (amd64 host → arm64 target): OK
  • make ZARCH=amd64 pkg/pillar (amd64 host → amd64 target): OK

Changelog notes

No user-facing changes (build-system fix only).

PR Backports

  • 16.0-stable: No, build-system fix; backport only if the same dhcpcd build step exists there and is broken.
  • 14.5-stable: No, build-system fix; backport only if the same dhcpcd build step exists there and is broken.
  • 13.4-stable: No, build-system fix; backport only if the same dhcpcd build step exists there and is broken.

Checklist

  • I've provided a proper description

  • I've added the proper documentation

  • I've tested my PR on amd64 device

  • I've tested my PR on arm64 device

  • I've written the test verification instructions

  • I've set the proper labels to this PR

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

@rucoder rucoder requested a review from eriknordmark as a code owner April 20, 2026 14:04
@rucoder rucoder marked this pull request as draft April 20, 2026 14:11
Cross-compiling pillar for a non-native architecture (e.g. `make
ZARCH=arm64 pkg/pillar` on an amd64 host) failed in the dhcpcd build
stage with:

    Deriving operating system from ... x86_64-unknown-linux
    ...
    No suitable user found for Priviledge Separation!
    Using compiler .. aarch64-alpine-linux-musl-gcc
    aarch64-alpine-linux-musl-gcc does not create executables

dhcpcd uses a hand-rolled ./configure script (not autotools) that:

  1. Derives the target triplet from the build host's `uname -m` when
     --build/--host are not supplied, so it never realizes this is a
     cross build and produces a host-arch test executable using the
     cross compiler.
  2. Looks up the dhcpcd privsep user in the build host's /etc/passwd,
     which does not contain that user (it is only added to the runtime
     image later).

Even with those two flags fixed, the cross gcc itself still fails to
link because it was built with --with-sysroot=/home/builder/sysroot-...
(a path baked into the toolchain at its own build time) which does not
exist in this image. The Alpine target libs/headers are copied to
/usr/${EVE_TARGET_ARCH}-alpine-linux-musl by the build-cross-target
stage, so we point gcc at that sysroot via --sysroot in CC.

Detecting the cross build via EVE_TARGET_ARCH does not work because
the eve-alpine base image already exports that variable in its own
environment, so it would also be set in native builds. CROSS_COMPILE_ENV
is set only by the cross build stages and is the correct signal.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@rucoder rucoder force-pushed the rucoder/fix-pillar-dhcpcd-cross-compile branch from 7747732 to 97a437a Compare April 20, 2026 14:35
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 24.36%. Comparing base (2281599) to head (97a437a).
⚠️ Report is 518 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5830      +/-   ##
==========================================
+ Coverage   19.52%   24.36%   +4.83%     
==========================================
  Files          19       24       +5     
  Lines        3021     5314    +2293     
==========================================
+ Hits          590     1295     +705     
- Misses       2310     3799    +1489     
- Partials      121      220      +99     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant