Skip to content

build: stop exporting GOOS=linux globally#5714

Merged
rene merged 1 commit intolf-edge:masterfrom
rucoder:rucoder/fix-goos-export-macos
Mar 31, 2026
Merged

build: stop exporting GOOS=linux globally#5714
rene merged 1 commit intolf-edge:masterfrom
rucoder:rucoder/fix-goos-export-macos

Conversation

@rucoder
Copy link
Copy Markdown
Contributor

@rucoder rucoder commented Mar 30, 2026

Description

The top-level Makefile hardcodes GOOS=linux and exports it to all sub-makes and child processes. This is correct for EVE packages (they run on Linux), but breaks host tools on macOS: the exported value overrides each tool's own host-OS detection, producing Linux binaries that cannot execute on the build host.

The immediate symptom is linuxkit (built from source via mk/linuxkit.mk) getting GOOS=linux instead of GOOS=darwin, but the same bug is latent in dockerfile-from-checker and GOSOURCES.

Changes:

  • Remove the global GOOS=linux assignment and drop GOOS/GOARCH from the
    export list.
  • In DOCKER_GO, hardcode -e GOOS=linux -e GOARCH=$(ZARCH) so the Linux container always gets the correct values explicitly.
  • Remove the now-redundant GOOS=$(LOCAL_GOOS) overrides from get-deps and compare-sbom-sources — with no global export, Go defaults to the host OS.

How to test and validate this PR

  • On Linux: make linuxkit — should build a linux-amd64 binary (no behavior change)
  • On macOS: make linuxkit — should build a darwin binary (was broken before)
  • On macOS: make linuxkit LINUXKIT_GIT_URL="" — should download linuxkit-darwin-amd64
  • Full image build: make rootfs HV=kvm ZARCH=amd64 — pillar and all EVE packages still build with GOOS=linux

Changelog notes

No user-facing changes. Build system fix for macOS developers.

PR Backports

  • 16.0-stable: yes
  • 14.5-stable: yes
  • 13.4-stable: yes

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 March 30, 2026 11:57
@rucoder rucoder added the stable Should be backported to stable release(s) label Mar 30, 2026
@rucoder rucoder requested review from rene and zedi-pramodh March 30, 2026 11:59
@rucoder rucoder force-pushed the rucoder/fix-goos-export-macos branch 3 times, most recently from 7860b87 to 5c6dd7a Compare March 30, 2026 12:31
Copy link
Copy Markdown
Contributor

@rene rene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The top-level Makefile hardcodes GOOS=linux and exports it to all
sub-makes and child processes.  This is correct for EVE packages
(they run on Linux), but breaks host tools on macOS: the exported
value overrides each tool's own host-OS detection, producing Linux
binaries that cannot execute on the build host.

The immediate symptom is linuxkit (built from source via
mk/linuxkit.mk) getting GOOS=linux instead of GOOS=darwin, but the
same bug is latent in dockerfile-from-checker and GOSOURCES.

Fix:
- Remove the global GOOS=linux assignment (line 337) and drop GOOS
  and GOARCH from the export list.
- In DOCKER_GO, hardcode -e GOOS=linux -e GOARCH=$(ZARCH) so the
  Linux container always gets the correct values explicitly.
- Remove the now-redundant GOOS=$(LOCAL_GOOS) overrides from
  get-deps and compare-sbom-sources — with no global export, Go
  defaults to the host OS automatically.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@rucoder rucoder force-pushed the rucoder/fix-goos-export-macos branch from 5c6dd7a to a364d1b Compare March 30, 2026 23:09
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5714      +/-   ##
==========================================
+ Coverage   19.52%   29.12%   +9.59%     
==========================================
  Files          19       10       -9     
  Lines        3021     1133    -1888     
==========================================
- Hits          590      330     -260     
+ Misses       2310      768    -1542     
+ Partials      121       35      -86     

☔ 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.

@rene rene merged commit 8c83465 into lf-edge:master Mar 31, 2026
43 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable Should be backported to stable release(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants