From 740c93a8334ceb44c3e4c41984fca9d59273b530 Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Thu, 27 Aug 2020 15:41:08 -0400 Subject: [PATCH] [Build] Make mage-linux-amd64 statically compiled. (#20827) * [Build] Make mage-linux-amd64 statically compiled. When I've upgraded my arch system, they have upgraded the libc library, that libary is much newer than the library used in the crossbuild docker images. This made building beats impossible because the mage-linux-amd64 is compiled dynamically and used in all our docker build. This PR make the mage binary to be statically compiled so it doesn't rely on any installed libraries. --- CHANGELOG-developer.next.asciidoc | 1 + dev-tools/mage/crossbuild.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-developer.next.asciidoc b/CHANGELOG-developer.next.asciidoc index 29734e17fa8..cf02bc84960 100644 --- a/CHANGELOG-developer.next.asciidoc +++ b/CHANGELOG-developer.next.asciidoc @@ -101,3 +101,4 @@ The list below covers the major changes between 7.0.0-rc2 and master only. - Update Go version to 1.14.4. {pull}19753[19753] - Update Go version to 1.14.7. {pull}20508[20508] - Add packaging for docker image based on UBI minimal 8. {pull}20576[20576] +- Make the mage binary used by the build process in the docker container to be statically compiled. {pull}20827[20827] diff --git a/dev-tools/mage/crossbuild.go b/dev-tools/mage/crossbuild.go index 6a11f7666cd..22b0ae574df 100644 --- a/dev-tools/mage/crossbuild.go +++ b/dev-tools/mage/crossbuild.go @@ -173,7 +173,7 @@ func CrossBuildXPack(options ...CrossBuildOption) error { // values for Docker. It has the benefit of speeding up the build because the // mage -compile is done only once rather than in each Docker container. func buildMage() error { - return sh.Run("mage", "-f", "-goos=linux", "-goarch=amd64", + return sh.RunWith(map[string]string{"CGO_ENABLED": "0"}, "mage", "-f", "-goos=linux", "-goarch=amd64", "-compile", CreateDir(filepath.Join("build", "mage-linux-amd64"))) }