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

Allow cross compile on different platform #292

Merged
merged 1 commit into from
Jan 18, 2019
Merged

Allow cross compile on different platform #292

merged 1 commit into from
Jan 18, 2019

Conversation

nak3
Copy link
Contributor

@nak3 nak3 commented Jan 18, 2019

This patch adds GOARCH option to go build, so any platform can
perform the build for arm64, amd64 and so on from different platform.

  • Example usage:
$ ARCH=amd64 make build-linux
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o aws-k8s-agent -ldflags "-X main.version=v1.3.0-49-g729fcd41"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o aws-cni -ldflags "-X main.version=v1.3.0-49-g729fcd41" ./plugins/routed-eni/

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Makefile Outdated

docker-build:
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-vpc-cni-k8s \
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-vpc-cni-k8s:z \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need the :z suffix for shared bind mounts? Is it just for building on SELinux?

Copy link
Contributor Author

@nak3 nak3 Jan 18, 2019

Choose a reason for hiding this comment

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

Exactly, it is just for building on SELinux. I put it as my machine is enabled SELinux (and sorry I forgot to remove it when I sent this PR). I removed it now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like it doesn't have any negative effects on non SE systems, so maybe we could have it around. I had no idea it was needed on SELinux, thanks for letting me know 🙃

This patch adds `GOARCH` option to `go build`, so any platform can
perform the build for arm64, amd64, or any platform if you like.

- Example usage:
```
$ ARCH=amd64 make build-linux
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o aws-k8s-agent -ldflags "-X main.version=v1.3.0-49-g729fcd41"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o aws-cni -ldflags "-X main.version=v1.3.0-49-g729fcd41" ./plugins/routed-eni/
```
@mogren mogren merged commit b386e9c into aws:master Jan 18, 2019
@nak3 nak3 deleted the cross-compile branch January 19, 2019 08:52
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