mirror of
https://git.yoctoproject.org/poky
synced 2026-02-20 08:29:42 +01:00
go: fixes for cross-canadian builds
* Add patch for go's make script to allow for build system != host system * Add dependencies on the appropriate crosssdk recipes, and use the crosssdk C compiler and linker * Remove bashism in the wrapper script * Restrict installation to only the tool binaries to address some packaging errors (From OE-Core rev: e2171f14a2dbf630a926a6792f6e6355f80e18b1) Signed-off-by: Matt Madison <matt@madison.systems> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
975246ffe6
commit
6590c03808
@@ -13,6 +13,7 @@ SRC_URI += "\
|
||||
file://0005-cmd-go-make-GOROOT-precious-by-default.patch \
|
||||
file://0006-make.bash-add-GOTOOLDIR_BOOTSTRAP-environment-variab.patch \
|
||||
file://0007-ld-add-soname-to-shareable-objects.patch \
|
||||
file://0008-make.bash-add-GOHOSTxx-indirection-for-cross-canadia.patch \
|
||||
"
|
||||
SRC_URI[main.md5sum] = "da2d44ea384076efec43ee1f8b7d45d2"
|
||||
SRC_URI[main.sha256sum] = "a4ab229028ed167ba1986825751463605264e44868362ca8e7accc8be057e993"
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
From 03e6c339d4fb712fbb8c4ca6ef2fc7100dcdb3d7 Mon Sep 17 00:00:00 2001
|
||||
From: Matt Madison <matt@madison.systems>
|
||||
Date: Thu, 14 Sep 2017 05:38:10 -0700
|
||||
Subject: [PATCH 8/8] make.bash: add GOHOSTxx indirection for cross-canadian
|
||||
builds
|
||||
|
||||
Add environment variables for specifying the host OS/arch
|
||||
that we are building the compiler for, so it can differ from
|
||||
the build host OS/arch.
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Matt Madison <matt@madison.systems>
|
||||
---
|
||||
src/make.bash | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/make.bash b/src/make.bash
|
||||
index 2e6fb05..0bdadc6 100755
|
||||
--- a/src/make.bash
|
||||
+++ b/src/make.bash
|
||||
@@ -173,6 +173,8 @@ if [ "$do_host_build" = "yes" ]; then
|
||||
echo
|
||||
|
||||
GOTOOLDIR_BOOTSTRAP="${GOTOOLDIR_BOOTSTRAP:-$GOTOOLDIR}"
|
||||
+ GOHOSTOS="${GOHOSTOS_CROSS:-$GOHOSTOS}"
|
||||
+ GOHOSTARCH="${GOHOSTARCH_CROSS:-$GOHOSTARCH}"
|
||||
echo "##### Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH."
|
||||
# CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however,
|
||||
# use the host compiler, CC, from `cmd/dist/dist env` instead.
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
inherit cross-canadian
|
||||
|
||||
DEPENDS = "go-native virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-${HOST_PREFIX}libc-for-gcc virtual/nativesdk-${HOST_PREFIX}compilerlibs"
|
||||
DEPENDS = "go-native virtual/${HOST_PREFIX}go-crosssdk virtual/nativesdk-${HOST_PREFIX}go-runtime \
|
||||
virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-${HOST_PREFIX}libc-for-gcc \
|
||||
virtual/nativesdk-${HOST_PREFIX}compilerlibs"
|
||||
PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
|
||||
|
||||
export GOHOSTOS = "${BUILD_GOOS}"
|
||||
export GOHOSTARCH = "${BUILD_GOARCH}"
|
||||
export GOOS = "${HOST_GOOS}"
|
||||
export GOARCH = "${HOST_GOARCH}"
|
||||
export GOARM = "${HOST_GOARM}"
|
||||
export GOHOSTOS_CROSS = "${HOST_GOOS}"
|
||||
export GOHOSTARCH_CROSS = "${HOST_GOARCH}"
|
||||
export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
|
||||
export GOTOOLDIR_BOOTSTRAP = "${GOROOT_BOOTSTRAP}/pkg/tool/${BUILD_GOTUPLE}"
|
||||
export GOTOOLDIR_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/${HOST_SYS}/go/pkg/tool/${BUILD_GOTUPLE}"
|
||||
export GOROOT_FINAL = "${libdir}/go"
|
||||
export CGO_ENABLED = "1"
|
||||
export CC_FOR_TARGET = "${HOST_CC}"
|
||||
export CXX_FOR_TARGET = "${HOST_CXX}"
|
||||
CC = "${@d.getVar('BUILD_CC', True).strip()}"
|
||||
export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "${TOOLCHAIN_OPTIONS} ${LDFLAGS}"'
|
||||
export CC_FOR_TARGET = "${TARGET_PREFIX}gcc"
|
||||
export CXX_FOR_TARGET = "${TARGET_PREFIX}g++"
|
||||
CC = "${HOST_PREFIX}gcc"
|
||||
export CGO_CFLAGS = "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${CFLAGS}"
|
||||
export CGO_LDFLAGS = "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${LDFLAGS}"
|
||||
export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${LDFLAGS}"'
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
|
||||
@@ -32,34 +35,27 @@ do_compile() {
|
||||
make_wrapper() {
|
||||
rm -f ${D}${bindir}/$2
|
||||
cat <<END >${D}${bindir}/$2
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
here=\`dirname \$0\`
|
||||
native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\`
|
||||
export GOARCH="${TARGET_GOARCH}"
|
||||
export GOOS="${TARGET_GOOS}"
|
||||
export GOARM="\${GOARM:-${TARGET_GOARM}}"
|
||||
test -n "\$GOARM" || export GOARM="${TARGET_GOARM}"
|
||||
export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}"
|
||||
export GOROOT="\${GOROOT:-\$OECORE_TARGET_SYSROOT/${target_libdir}/go}"
|
||||
test -n "\$GOROOT" || export GOROOT="\$OECORE_TARGET_SYSROOT/${target_libdir}/go"
|
||||
\$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@"
|
||||
END
|
||||
chmod +x ${D}${bindir}/$2
|
||||
}
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${libdir}/go
|
||||
cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
|
||||
install -d ${D}${libdir}/go/src
|
||||
(cd ${S}/src; for d in *; do \
|
||||
[ -d $d ] && cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \
|
||||
done)
|
||||
rm -rf ${D}${libdir}/go/src/runtime/pprof/testdata
|
||||
install -d ${D}${libdir}/go/pkg/tool
|
||||
cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/
|
||||
install -d ${D}${bindir} ${D}${libdir}/go/bin
|
||||
for f in ${B}/bin/*
|
||||
for f in ${B}/${GO_BUILD_BINDIR}/*
|
||||
do
|
||||
base=`basename $f`
|
||||
install -m755 $f ${D}${libdir}/go/bin
|
||||
make_wrapper $base ${TARGET_PREFIX}$base
|
||||
done
|
||||
}
|
||||
|
||||
FILES_${PN}-staticdev = "${libdir}/go/pkg"
|
||||
|
||||
Reference in New Issue
Block a user