From fa623fed8492e34f08201ecc8fcbbde63a002619 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Fri, 27 Oct 2023 16:50:34 +0200 Subject: [PATCH] make.defaults, go-env.eclass: export cgo flags, enable cgo by default This change adds exporting CGO_* flags to go-env.eclass; the upstream pr https://github.com/gentoo/gentoo/pull/33539 has been updated accordingly. Also, CGO_ENABLED=1 has been added to coreos/../make.conf to enable gco by default. This fixes a build issue for arm64 with Docker's device-mapper storage driver: daemon/graphdriver/devmapper/deviceset.go:306:25: undefined: devicemapper.SetTransactionID ... daemon/graphdriver/devmapper/deviceset.go:867:28: undefined: devicemapper.ErrEnxio daemon/graphdriver/devmapper/deviceset.go:867:28: too many errors gco is enabled on AMD64 by default, and cgo was always enabled in the coreos docker ebuilds. This way we retain that setting for the Gentoo ebuilds. --- .../coreos-overlay/profiles/coreos/base/make.defaults | 3 +++ .../src/third_party/portage-stable/eclass/go-env.eclass | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/make.defaults b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/make.defaults index 1b49142ee6..6f15ef413a 100644 --- a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/make.defaults +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/make.defaults @@ -127,3 +127,6 @@ DONT_MOUNT_BOOT=1 # inside the scripts repository that poke binary packages assume that # bzip2 is used, not zstd. Eventually we will want to move to zstd. BINPKG_COMPRESS=bzip2 + +# Enable cgo by default. Required for the docker device-mapper driver to compile. +CGO_ENABLED=1 diff --git a/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass b/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass index 9d081f23a0..5e5681ff15 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/go-env.eclass @@ -19,6 +19,7 @@ inherit toolchain-funcs # @FUNCTION: go-env_set_compile_environment # @DESCRIPTION: # Set up basic compile environment: CC, CXX, and GOARCH. +# Also carry over CFLAGS, LDFLAGS and friends. # Required for cross-compiling with crossdev. # If not set, host defaults will be used and the resulting binaries are host arch. # (e.g. "emerge-aarch64-cross-linux-gnu foo" run on x86_64 will emerge "foo" for x86_64 @@ -38,6 +39,10 @@ go-env_set_compile_environment() { tc-export CC CXX export GOARCH + export CGO_CFLAGS="${CGO_CFLAGS:-$CFLAGS}" + export CGO_CPPFLAGS="${CGO_CPPFLAGS:-$CPPFLAGS}" + export CGO_CXXFLAGS="${CGO_CXXFLAGS:-$CXXFLAGS}" + export CGO_LDFLAGS="${CGO_LDFLAGS:-$LDFLAGS}" } fi