From 094af6ea07ce9cf0fc85a036deaff2ca9e5cd9c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 10 Apr 2024 16:09:20 +0200 Subject: [PATCH 1/3] darwin/build: Disallow CGO_ENABLED=1 when cross-compiling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cross compiling CGO to Darwin requires an Apple SDK. Signed-off-by: Paweł Gronowski --- scripts/build/.variables | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/build/.variables b/scripts/build/.variables index de7945d0a7..7cfec2409f 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -44,6 +44,16 @@ if [ "${GOOS}" = "windows" ]; then fi export TARGET +# No CGO when cross building to darwin +if [ "$(go env GOOS)" = "darwin" ] && [ "$(uname)" != "Darwin" ]; then + if [ -z "$CGO_ENABLED" ]; then + CGO_ENABLED=0 + elif [ "$CGO_ENABLED" = "1" ]; then + echo "CGO_ENABLED=1 not supported when cross-compiling for Darwin" + exit 1 + fi +fi + if [ -z "$CGO_ENABLED" ]; then case "$(go env GOOS)" in linux) From 0c2697d779fe99b7c59f37bd6fecd9b21fed31be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 10 Apr 2024 17:00:24 +0200 Subject: [PATCH 2/3] Dockerfile: Remove xx-sdk-extras MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d4d5533a39..cf703478da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,7 +63,6 @@ ARG PACKAGER_NAME COPY --link --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo RUN --mount=type=bind,target=.,ro \ --mount=type=cache,target=/root/.cache \ - --mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \ --mount=type=tmpfs,target=cli/winresources \ # override the default behavior of go with xx-go xx-go --wrap && \ @@ -89,7 +88,6 @@ ARG GO_STRIP ARG CGO_ENABLED ARG VERSION RUN --mount=ro --mount=type=cache,target=/root/.cache \ - --mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \ xx-go --wrap && \ TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/* From 1433df8fee931f3e65eeb6d0a00f9c7dcf5e72ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Mon, 8 Apr 2024 14:42:19 +0200 Subject: [PATCH 3/3] bake/bin-image-cross: Add darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So we can also have darwin binaries in the `dockereng/cli-bin` image. Signed-off-by: Paweł Gronowski --- docker-bake.hcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-bake.hcl b/docker-bake.hcl index bb65406d78..496b31a5da 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -180,6 +180,8 @@ target "bin-image-cross" { inherits = ["bin-image"] output = ["type=image"] platforms = [ + "darwin/amd64", + "darwin/arm64", "linux/amd64", "linux/arm/v6", "linux/arm/v7",