Fix Go package cross-compilation and add parallel builds#5811
Merged
rene merged 6 commits intolf-edge:masterfrom Apr 22, 2026
Merged
Fix Go package cross-compilation and add parallel builds#5811rene merged 6 commits intolf-edge:masterfrom
rene merged 6 commits intolf-edge:masterfrom
Conversation
4abb9af to
02016dc
Compare
Contributor
be careful with the backport section written by claude - 9 out of 10 times it's garbage build improvements should be backported |
Contributor
Author
this is no Claude :) and I always instruct manually about backports. and since when we backport build improvements? @rene ? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5811 +/- ##
==========================================
+ Coverage 19.52% 26.56% +7.03%
==========================================
Files 19 24 +5
Lines 3021 4213 +1192
==========================================
+ Hits 590 1119 +529
- Misses 2310 2872 +562
- Partials 121 222 +101 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add --platform=$BUILDPLATFORM so the Go build runs natively on the host instead of under QEMU emulation. Cross-compile with GOARCH=$TARGETARCH. The build is pure Go with CGO_ENABLED=0, so no C toolchain is needed. Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
Add --platform=$BUILDPLATFORM so the Go build runs natively on the host instead of under QEMU emulation. Cross-compile with GOARCH=$TARGETARCH. The build is pure Go with CGO_ENABLED=0, so no C toolchain is needed. Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
Add --platform=$BUILDPLATFORM so the Go build runs natively on the host instead of under QEMU emulation. Cross-compile with GOARCH=$TARGETARCH. The build is pure Go with CGO_ENABLED=0, so no C toolchain is needed. Runtime packages (coreutils) are installed in a separate stage without --platform so they resolve to the correct target architecture. Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
lshw's Makefile has a race condition with parallel builds: the "static" target depends on both the "core" phony target and "core/liblshw.a" file. With -j, make starts building liblshw.a via the "core" target while simultaneously looking for the liblshw.a file which doesn't exist yet. Work around this by building the "core" target first in a separate make invocation, then building "static" once the library is available. Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
Add --platform=$BUILDPLATFORM so the Go build runs natively on the host instead of under QEMU emulation. Cross-compile with GOARCH=$TARGETARCH. The build is pure Go with CGO_ENABLED=0, so no C toolchain is needed. Runtime packages (iproute2, iptables, etc.) are installed in a separate stage without --platform so they resolve to the correct target architecture. Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
02016dc to
d9ee4ae
Compare
- update hashes in dependent packages Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
these commits are cherry-picked from #5730 and will be removed from that PR.
Fix cross-compilation for several pure-Go EVE packages by adding
--platform=$BUILDPLATFORMso the Go compiler runs natively on the host instead of under QEMU emulation. Cross-compilation is achieved withGOARCH=$TARGETARCHandCGO_ENABLED=0. Runtime dependencies are installed in separate stages without--platformso they resolve to the correct target architecture.Packages fixed:
Additionally:
-j) for lshw and hexedit builds, with a workaround for lshw's Makefile race condition.How to test and validate this PR
Changelog notes
Speedup cross-compilation of GO applications on CI and MacOS
PR Backports
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.