Skip to content

Allow cross compile on different platform#292

Merged
mogren merged 1 commit intoaws:masterfrom
nak3:cross-compile
Jan 18, 2019
Merged

Allow cross compile on different platform#292
mogren merged 1 commit intoaws:masterfrom
nak3:cross-compile

Conversation

@nak3
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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