From 1b9e75ac4844630ea1ffc180ba9ad2d6a9340181 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 23 Mar 2021 23:26:10 +0100 Subject: [PATCH] buildx: add add -ldflags=-linkmode=external to fix missing build-id warning I noticed this warning during a build in CI: warning: Missing build-id in /root/rpmbuild/BUILDROOT/docker-ce-cli-0.0.0.20210311145359.d3c36a2-0.el8.x86_64/usr/libexec/docker/cli-plugins/docker-buildx And looks looks like we had that issue before at some point; https://github.com/rpm-software-management/rpm/issues/367#issuecomment-350391947 From that thread: > OK one way is to use gccgo instead of go build, and the other way is to add -ldflags=-linkmode=external flag to go build. > > Still, by default (i.e. using go build) it doesn't do that and it's a problem. Signed-off-by: Sebastiaan van Stijn --- plugins/buildx.installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/buildx.installer b/plugins/buildx.installer index 7585b9e3a5..1f2d494fbf 100755 --- a/plugins/buildx.installer +++ b/plugins/buildx.installer @@ -18,7 +18,7 @@ build() { git fetch --all git checkout -q "${BUILDX_COMMIT}" local LDFLAGS - LDFLAGS="-X ${PKG}/version.Version=$(git describe --match 'v[0-9]*' --always --tags)-docker -X ${PKG}/version.Revision=$(git rev-parse HEAD) -X ${PKG}/version.Package=${PKG}" + LDFLAGS="-linkmode=external -X ${PKG}/version.Version=$(git describe --match 'v[0-9]*' --always --tags)-docker -X ${PKG}/version.Revision=$(git rev-parse HEAD) -X ${PKG}/version.Package=${PKG}" set -x GOFLAGS=-mod=vendor go build -o bin/docker-buildx -ldflags "${LDFLAGS}" ./cmd/buildx )