From 87b085c8cd7b87d2ea26a0b846e4e4f2e99e0ded Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 23 Jul 2022 09:38:50 +0200 Subject: [PATCH 1/2] missing DWARF symbol table Signed-off-by: CrazyMax --- scripts/build/.variables | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build/.variables b/scripts/build/.variables index f14e54f2f4..449fde7900 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -71,7 +71,7 @@ if [ "$CGO_ENABLED" = "1" ] && [ "$(go env GOOS)" != "windows" ]; then fi export GO_BUILDMODE -GO_LDFLAGS="${GO_LDFLAGS:-} -w" +GO_LDFLAGS="${GO_LDFLAGS:-}" GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\"" GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\"" GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.Version=${VERSION}\"" @@ -86,7 +86,7 @@ if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ]; then GO_BUILDTAGS="$GO_BUILDTAGS osusergo" fi if [ -n "$GO_STRIP" ]; then - GO_LDFLAGS="$GO_LDFLAGS -s" + GO_LDFLAGS="$GO_LDFLAGS -s -w" fi export GO_LDFLAGS="$GO_LDFLAGS" # https://github.com/koalaman/shellcheck/issues/2064 From 6f799c1a1cdbcc809e9fedbbc7d2b5fbe4dbe00d Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 28 Jul 2022 22:49:02 +0200 Subject: [PATCH 2/2] dockerfile: llvm needed on debian for cross comp Signed-off-by: CrazyMax --- Dockerfile | 9 ++++++++- scripts/build/.variables | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1ecb243663..9aa9ea5225 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,12 +21,19 @@ RUN xx-apk add --no-cache musl-dev gcc FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bullseye AS build-base-bullseye COPY --from=xx / / -RUN apt-get update && apt-get install --no-install-recommends -y bash clang lld file +RUN apt-get update && apt-get install --no-install-recommends -y bash clang lld llvm file WORKDIR /go/src/github.com/docker/cli FROM build-base-bullseye AS build-bullseye ARG TARGETPLATFORM RUN xx-apt-get install --no-install-recommends -y libc6-dev libgcc-10-dev +# workaround for issue with llvm 11 for darwin/amd64 platform: +# # github.com/docker/cli/cmd/docker +# /usr/local/go/pkg/tool/linux_amd64/link: /usr/local/go/pkg/tool/linux_amd64/link: running strip failed: exit status 1 +# llvm-strip: error: unsupported load command (cmd=0x5) +# more info: https://github.com/docker/cli/pull/3717 +# FIXME: remove once llvm 12 available on debian +RUN [ "$TARGETPLATFORM" != "darwin/amd64" ] || ln -sfnT /bin/true /usr/bin/llvm-strip FROM build-base-${BASE_VARIANT} AS goversioninfo ARG GOVERSIONINFO_VERSION diff --git a/scripts/build/.variables b/scripts/build/.variables index 449fde7900..e0147655b4 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -86,6 +86,12 @@ if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ]; then GO_BUILDTAGS="$GO_BUILDTAGS osusergo" fi if [ -n "$GO_STRIP" ]; then + # if stripping enabled and building with llvm < 12 against darwin/amd64 + # platform, it will fail with: + # # github.com/docker/cli/cmd/docker + # /usr/local/go/pkg/tool/linux_amd64/link: /usr/local/go/pkg/tool/linux_amd64/link: running strip failed: exit status 1 + # llvm-strip: error: unsupported load command (cmd=0x5) + # more info: https://github.com/docker/cli/pull/3717 GO_LDFLAGS="$GO_LDFLAGS -s -w" fi export GO_LDFLAGS="$GO_LDFLAGS" # https://github.com/koalaman/shellcheck/issues/2064