From 4b596df69cfd18cade113d81720d2bb4e4ec0ddf Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 2 Sep 2024 15:48:30 +0200 Subject: [PATCH 1/4] gha: add linux/arm/v5 to list of platforms We include this in the moby/moby repo, but it looks like we didn't for the CLI. Signed-off-by: Sebastiaan van Stijn --- docker-bake.hcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-bake.hcl b/docker-bake.hcl index e486e2e037..e476b1d4d6 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -31,6 +31,7 @@ target "_platforms" { "darwin/amd64", "darwin/arm64", "linux/amd64", + "linux/arm/v5", "linux/arm/v6", "linux/arm/v7", "linux/arm64", @@ -186,6 +187,7 @@ target "bin-image-cross" { "darwin/amd64", "darwin/arm64", "linux/amd64", + "linux/arm/v5", "linux/arm/v6", "linux/arm/v7", "linux/arm64", From 3271cc7fc6a7f8ff9a26feb56a9e5aaa015bf7ef Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 2 Sep 2024 16:00:13 +0200 Subject: [PATCH 2/4] Dockerfile: install libgcc instead of gcc The comment describes we need gcc for libgcc only, so we may as well install that. Signed-off-by: Sebastiaan van Stijn --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f2e249eb69..a0d0d1b9f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,7 @@ WORKDIR /go/src/github.com/docker/cli FROM build-base-alpine AS build-alpine ARG TARGETPLATFORM # gcc is installed for libgcc only -RUN xx-apk add --no-cache musl-dev gcc +RUN xx-apk add --no-cache musl-dev libgcc FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO} AS build-base-debian ENV GOTOOLCHAIN=local From 1216a799d8368f4214f07be900f41fc0554ee59a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 2 Sep 2024 16:38:24 +0200 Subject: [PATCH 3/4] scripts/build/plugins: don't -buildmode=pie without CGO enabled The `.variables` sets `CGO_ENABLED=1` on arm; https://github.com/docker/cli/blob/b0c41b78d8c80c5f8faa736cf3c74dc31092e443/scripts/build/.variables#L57-L68 And if enabled, it sets `-buildmode=pie`; https://github.com/docker/cli/blob/b0c41b78d8c80c5f8faa736cf3c74dc31092e443/scripts/build/.variables#L79-L88 But that looks to be conflicting with the hard-coded `CGO_ENABLED=0` in this script. > [build-plugins 1/1] RUN --mount=ro --mount=type=cache,target=/root/.cache xx-go --wrap && TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/*: 0.127 Building static docker-helloworld 0.127 + CGO_ENABLED=0 0.127 + GO111MODULE=auto 0.127 + go build -o /out/plugins-linux-arm/docker-helloworld -tags ' osusergo' -ldflags ' -X "github.com/docker/cli/cli/version.GitCommit=5c123b1" -X "github.com/docker/cli/cli/version.BuildTime=2024-09-02T13:52:17Z" -X "github.com/docker/cli/cli/version.Version=pr-5387" -extldflags -static' -buildmode=pie github.com/docker/cli/cli-plugins/examples/helloworld 0.135 -buildmode=pie requires external (cgo) linking, but cgo is not enabled Remove `GO_BUILDMODE` from this script so that we don't try to build with `-buildmode=pie`. Signed-off-by: Sebastiaan van Stijn --- scripts/build/plugins | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/plugins b/scripts/build/plugins index 634d3f9db7..9384209198 100755 --- a/scripts/build/plugins +++ b/scripts/build/plugins @@ -21,5 +21,5 @@ for p in cli-plugins/examples/* "$@" ; do mkdir -p "$(dirname "${TARGET_PLUGIN}")" echo "Building $GO_LINKMODE $(basename "${TARGET_PLUGIN}")" - (set -x ; GO111MODULE=auto go build -o "${TARGET_PLUGIN}" -tags "${GO_BUILDTAGS}" -ldflags "${GO_LDFLAGS}" ${GO_BUILDMODE} "github.com/docker/cli/${p}") + (set -x ; GO111MODULE=auto go build -o "${TARGET_PLUGIN}" -tags "${GO_BUILDTAGS}" -ldflags "${GO_LDFLAGS}" "github.com/docker/cli/${p}") done From 8a33306f08aeb4b7adb64a1865837bfbfeb3f671 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 2 Sep 2024 16:46:34 +0200 Subject: [PATCH 4/4] Revert "Dockerfile: install libgcc instead of gcc" This reverts commit df2a797b489d95774fdc77054ca8f5d475643c2e. Signed-off-by: Sebastiaan van Stijn --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a0d0d1b9f0..f2e249eb69 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,7 @@ WORKDIR /go/src/github.com/docker/cli FROM build-base-alpine AS build-alpine ARG TARGETPLATFORM # gcc is installed for libgcc only -RUN xx-apk add --no-cache musl-dev libgcc +RUN xx-apk add --no-cache musl-dev gcc FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO} AS build-base-debian ENV GOTOOLCHAIN=local