-
Notifications
You must be signed in to change notification settings - Fork 145
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
mac: build arm64 binaries #540
Conversation
c31456e
to
9e8e620
Compare
@@ -10,8 +10,7 @@ override_dh_auto_build: | |||
cd engine && TMP_GOPATH="/go" hack/dockerfile/install/install.sh proxy dynamic | |||
cd engine && TMP_GOPATH="/go" hack/dockerfile/install/install.sh rootlesskit dynamic | |||
# Build the CLI | |||
cd /go/src/github.com/docker/cli && \ | |||
LDFLAGS='' DISABLE_WARN_OUTSIDE_CONTAINER=1 make VERSION=$(VERSION) GITCOMMIT=$(CLI_GITCOMMIT) dynbinary manpages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the LDFLAGS='' here?
(perhaps we need the same comment as in the plugins install script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think enough, and had too much confidence in Tonis's scripts :) I put it back.
deb/common/rules
Outdated
@@ -10,8 +10,7 @@ override_dh_auto_build: | |||
cd engine && TMP_GOPATH="/go" hack/dockerfile/install/install.sh proxy dynamic | |||
cd engine && TMP_GOPATH="/go" hack/dockerfile/install/install.sh rootlesskit dynamic | |||
# Build the CLI | |||
cd /go/src/github.com/docker/cli && \ | |||
LDFLAGS='' DISABLE_WARN_OUTSIDE_CONTAINER=1 make VERSION=$(VERSION) GITCOMMIT=$(CLI_GITCOMMIT) dynbinary manpages | |||
cd /go/src/github.com/docker/cli && VERSION=$(VERSION) GITCOMMIT=$(CLI_GITCOMMIT) LDFLAGS='' GO_LINKMODE=dynamic ./scripts/build/binary && DISABLE_WARN_OUTSIDE_CONTAINER=1 make manpages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd /go/src/github.com/docker/cli && VERSION=$(VERSION) GITCOMMIT=$(CLI_GITCOMMIT) LDFLAGS='' GO_LINKMODE=dynamic ./scripts/build/binary && DISABLE_WARN_OUTSIDE_CONTAINER=1 make manpages | |
cd /go/src/github.com/docker/cli && VERSION=$(VERSION) GITCOMMIT=$(CLI_GITCOMMIT) LDFLAGS='' GO_LINKMODE=dynamic ./scripts/build/binary && LDFLAGS='' DISABLE_WARN_OUTSIDE_CONTAINER=1 make manpages |
Need to set it for both ./scripts/build/binary
and for make manpages
(we don't export LDFLAGS, so it's not set after &&
otherwise)
ab9e47a
to
4d88967
Compare
static/Makefile
Outdated
cp $(CLI_DIR)/build/docker-darwin-amd64 build/mac/docker/docker | ||
tar -C build/mac -c -z -f build/mac/docker-$(GEN_STATIC_VER).tgz docker | ||
cross-mac: buildx cross-mac-plugins | ||
cd $(CLI_DIR) && VERSION=$(GEN_STATIC_VER) docker buildx bake --set cross.platform=darwin/amd64,darwin/arm64 cross |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you building cross?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after fixing the windows stage
Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
6866c36
to
85c07f0
Compare
Makefile
Outdated
@@ -75,5 +75,5 @@ deb: checkout ## build deb packages | |||
static: DOCKER_BUILD_PKGS:=static-linux cross-mac cross-win cross-arm | |||
static: checkout ## build static-compiled packages | |||
for p in $(DOCKER_BUILD_PKGS); do \ | |||
$(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $${p}; \ | |||
$(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) GOPLATFORM=$(GOPLATFORM) $${p}; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this called GOPLATFORM
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can call it PLATFORM if you want but in this repo it's confusing as it can also mean the stupid "Docker CE" PLATFORM string. Happy to change the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not GOARCH?
Could be GO_PLATFORM to be consistent with GO_VERSION
static/Makefile
Outdated
@@ -66,7 +73,7 @@ cross-arm: cross-all-cli ## create tgz with linux armhf client only | |||
|
|||
.PHONY: static-cli | |||
static-cli: | |||
$(MAKE) -C $(CLI_DIR) -f docker.Makefile VERSION=$(GEN_STATIC_VER) build | |||
cd $(CLI_DIR) && VERSION=$(GEN_STATIC_VER) docker buildx bake --set binary.platform=$(GOPLATFORM) $(if $(findstring arm/,$(GOPLATFORM)),--set binary.args.CGO_ENABLED=0) binary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you just pass in CGO_ENABLED
? Afaics it is not that arm binaries can't use cgo but that arm call happens on some specific environment/jenkins node set from the caller side that causes it. If this would be arm specific we would disable cgo in docker/cli
for that case(as we disable pie for some arch) but don't think but I don't think there is any proof of that atm.
88eb12b
to
6fa4429
Compare
Signed-off-by: Tibor Vass <tibor@docker.com>
c3d6ef8
to
eb9402b
Compare
@tonistiigi fixed your concerns. |
Since we are building arm on arm64 machines we have to specify the desired platform and not rely on the host's architecture. Also when building arm on arm64 machines, there can be issues with cgo. So this patch makes sure CGO_ENABLED env var gets passed on as a build arg. Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
In docker/cli#2993, Makefile target dynbinary changed from a host script not depending on docker to a dockerized script. Instead call the underlying script directly for deb/rpm. I still think we should build deb/rpms using docker. Signed-off-by: Tibor Vass <tibor@docker.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Tibor Vass tibor@docker.com
This PR uses golang 1.16 In order to build plugins for darwin/arm64.
However, docker app plugin does not build with go 1.16 (could not figure out how to disable go modules), and it was meant to be removed anyway.
ARM binaries had issues building with cgo, so as a workaround, this PR sets CGO_ENABLED=0 for arm (32 bit, aka armel/armhf) binaries only.
Related: