From de33c554918046fb401e7bbb754276db50848b3e Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 18 Feb 2015 09:50:52 -0800 Subject: [PATCH] mantle: build kola Add support for cgo to the go eclass and start building kola! --- ...antle-0.0.2.ebuild => mantle-0.0.3.ebuild} | 0 coreos-devel/mantle/mantle-9999.ebuild | 6 ++++-- eclass/coreos-go.eclass | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) rename coreos-devel/mantle/{mantle-0.0.2.ebuild => mantle-0.0.3.ebuild} (100%) diff --git a/coreos-devel/mantle/mantle-0.0.2.ebuild b/coreos-devel/mantle/mantle-0.0.3.ebuild similarity index 100% rename from coreos-devel/mantle/mantle-0.0.2.ebuild rename to coreos-devel/mantle/mantle-0.0.3.ebuild diff --git a/coreos-devel/mantle/mantle-9999.ebuild b/coreos-devel/mantle/mantle-9999.ebuild index 2efb937c1d..56953fb5c6 100644 --- a/coreos-devel/mantle/mantle-9999.ebuild +++ b/coreos-devel/mantle/mantle-9999.ebuild @@ -9,7 +9,7 @@ COREOS_GO_PACKAGE="github.com/coreos/mantle" if [[ "${PV}" == 9999 ]]; then KEYWORDS="~amd64" else - CROS_WORKON_COMMIT="a1a810b88e4fca2c320a31a740796eaffecab57f" + CROS_WORKON_COMMIT="444fecccb109b5a90765cb1b79311fb10dd5c5e5" KEYWORDS="amd64" fi @@ -21,5 +21,7 @@ LICENSE="Apache-2" SLOT="0" src_compile() { - go_build "${COREOS_GO_PACKAGE}"/cmd/plume + for cmd in kola plume; do + go_build "${COREOS_GO_PACKAGE}/cmd/${cmd}" + done } diff --git a/eclass/coreos-go.eclass b/eclass/coreos-go.eclass index aee8c64749..5280b424df 100644 --- a/eclass/coreos-go.eclass +++ b/eclass/coreos-go.eclass @@ -11,7 +11,7 @@ [[ ${EAPI} != "5" ]] && die "Only EAPI=5 is supported" -inherit multiprocessing +inherit flag-o-matic multiprocessing toolchain-funcs DEPEND="dev-lang/go" @@ -24,8 +24,8 @@ go_build() { local package_name="$1" local binary_name="${package_name##*/}" - # TODO: handle cgo, cross-compiling, etc etc... - CGO_ENABLED=0 go build -x -p "$(makeopts_jobs)" \ + go build -x -p "$(makeopts_jobs)" \ + -ldflags "-extldflags '${LDFLAGS}'" \ -o "${GOPATH}/bin/${binary_name}" "${package_name}" \ || die "go build failed" } @@ -44,6 +44,19 @@ coreos-go_src_prepare() { local package_path="${GOPATH}/src/${COREOS_GO_PACKAGE}" mkdir -p "${package_path%/*}" || die ln -sT "${S}" "${package_path}" || die + + # Go's 6l linker does not support PIE, disable so cgo binaries + # which use 6l+gcc for linking can be built correctly. + if gcc-specs-pie; then + append-ldflags -nopie + fi + + export CC=$(tc-getCC) + export CGO_ENABLED=1 + export CGO_CFLAGS="${CFLAGS}" + export CGO_CPPFLAGS="${CPPFLAGS}" + export CGO_CXXFLAGS="${CXXFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" } coreos-go_src_compile() {