Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beats packaging fails when cross-compiling to Darwin after upgrade from Go 1.17.10 to Go 1.17.11 image #217

Open
cmacknz opened this issue Jul 8, 2022 · 2 comments
Labels
Team:Automation Label for the Observability productivity team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Comments

@cmacknz
Copy link
Member

cmacknz commented Jul 8, 2022

To reproduce the issue in https://github.com/elastic/beats:

cd auditbeat
CGO_ENABLED=1 PLATFORMS="darwin/amd64" DEV=1 MAGEFILE_VERBOSE=true mage package

The command will fail with the error:

[2022-07-08T12:08:43.110Z] Status: Downloaded newer image for docker.elastic.co/beats-dev/golang-crossbuild:1.17.11-darwin-arm64-debian10
[2022-07-08T12:08:49.693Z] >> Building using: cmd='build/mage-linux-amd64 golangCrossBuild', env=[CC=oa64-clang, CXX=oa64-clang++, GOARCH=arm64, GOARM=, GOOS=darwin, PLATFORM_ID=darwin-arm64]
[2022-07-08T12:11:14.379Z] # github.com/elastic/beats/v7/auditbeat
[2022-07-08T12:11:14.379Z] /usr/local/go/pkg/tool/linux_amd64/link: /usr/local/go/pkg/tool/linux_amd64/link: running dsymutil failed: exit status 1
[2022-07-08T12:11:14.379Z] osxcross: error: xcrun: cannot find 'dsymutil' executable
[2022-07-08T12:11:14.379Z] 
[2022-07-08T12:11:14.379Z] Error: running "go build -o build/golang-crossbuild/auditbeat-darwin-amd64 -buildmode pie -gcflags "all=-N -l" -ldflags -X github.com/elastic/beats/v7/libbeat/version.buildTime=2022-07-08T12:07:37Z -X github.com/elastic/beats/v7/libbeat/version.commit=ea6635f5bfb8586ff63b91e14995084fd56da2e3" failed with exit code 2
[2022-07-08T12:11:14.379Z] Error: failed building for darwin/amd64: exit status 2
[2022-07-08T12:11:14.379Z] failed building for darwin/amd64: exit status 2

Downgrading to the Go 1.17.10 crossbuild image or setting DEV=0 fixes the issue.

There were multiple changes merged to the Go 1.17 branch between the Go 1.17.10 and Go 1.17.11 version bumps (https://github.com/elastic/golang-crossbuild/commits/1.17) that could be responsible for this:

@cmacknz cmacknz added Team:Automation Label for the Observability productivity team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Jul 8, 2022
@cmacknz
Copy link
Member Author

cmacknz commented Jul 8, 2022

This doesn't seem to affect builds with PLATFORMS="darwin/arm64", at least not when building on an M1 machine.

@kuisathaverat
Copy link
Contributor

at least not when building on an M1 machine.

Running on arm64 Docker chooses the Docker image build for arm64, it is different than the one run on an amd64-based machine, all the tools compilers, and so on are built for a different architecture so it is not a surprise that behaves in a different way.

CGO_ENABLED=1 in a cross-compile environment could behave differently than in a native build environment, for me it is difficult to justify the use of CGO_ENABLED (see https://dave.cheney.net/tag/cgo)

cmacknz added a commit to elastic/beats that referenced this issue Jul 8, 2022
* Force DEV=0 when cross compiling for darwin/amd64.

elastic/golang-crossbuild#217

* Revert "Revert "Fix flags for dev build (#31955)" (#32250)"

This reverts commit ba5d0cb.
chrisberkhout pushed a commit to elastic/beats that referenced this issue Jun 1, 2023
* Force DEV=0 when cross compiling for darwin/amd64.

elastic/golang-crossbuild#217

* Revert "Revert "Fix flags for dev build (#31955)" (#32250)"

This reverts commit ba5d0cb.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Automation Label for the Observability productivity team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

No branches or pull requests

2 participants