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

Cross-compile to avoid a lot of QEMU #16

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

Stelminator
Copy link
Contributor

In the interests of getting more target platforms upstream (#15).

Leverage Golang's cross-compilation to run compilation natively, but target different architectures. This alleviates the need to run the compiler under emulation of the targets. Effectively, any target runs as fast as the native arch.

docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/arm/v5 .

Takes under a minute to run on my Core i7-11700KF.

TARGETVARIANT will be v5/v6/v7 for the above arm targets, but was empty for the rest. I'm unsure about other architectures with variants, but this could be adapted further to only set GOARM for arm targets.

If this doesn't work out of the box (buildx seems to cache some arguments), then adding ARG BUILDPLATFORM at the top of Dockerfile and --build-arg BUILDPLATFORM=<arch> to the command should do the trick, which for me resulted in:

docker buildx build --build-arg BUILDPLATFORM=amd64 --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/arm/v5 .

Copy link
Owner

@blake blake left a comment

Choose a reason for hiding this comment

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

This is a great improvement. 🚀 Thank you!

@blake blake merged commit 0176f99 into blake:master Mar 9, 2024
iamasmith pushed a commit to iamasmith/external-mdns that referenced this pull request Mar 10, 2024
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