Commit f5c4b298 authored by Timo Teräs's avatar Timo Teräs

community/go: cross-build support

parent fb8794ef
......@@ -15,24 +15,37 @@ makedepends="bash go-bootstrap"
options="!strip"
provides="go-bootstrap=$pkgver-r$pkgrel"
install=""
subpackages="$pkgname-doc $pkgname-tools"
subpackages="$pkgname-doc"
source="http://golang.org/dl/go${pkgver/_/}.src.tar.gz
$pkgname-tools-${pkgver/_/}.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz
go-tools-${pkgver/_/}.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz
default-buildmode-pie.patch
"
# NOTE: building go for x86 with grsec kernel requires:
# sysctl -w kernel.modify_ldt=1
_gotools="cover godoc stringer"
_tooldir="$srcdir"/tools-${_toolsver}
if [ "$CBUILD" = "$CTARGET" ]; then
makedepends="go-bootstrap $makedepends"
provides="go-bootstrap=$pkgver-r$pkgrel"
subpackages="$subpackages $pkgname-tools"
_gotools="cover godoc stringer"
_gocross="darwin freebsd openbsd windows"
else
pkgname="go-bootstrap"
makedepends="go $makedepends"
# Go expect host linker instead of the cross-compiler
export CC_FOR_TARGET="$CC"
export CC="${HOSTLD:-gcc}"
export CXX="${HOSTLD:-g++}"
export LD="${HOSTLD:-ld}"
fi
_gocross="darwin freebsd openbsd windows"
_tooldir="$srcdir"/tools-${_toolsver}
for os in $_gocross; do
subpackages="$subpackages $pkgname-cross-${os}:_crosspkg"
done
builddir="$srcdir"/$pkgname
builddir="$srcdir"/go
build() {
cd "$builddir/src"
......@@ -46,6 +59,7 @@ build() {
*) die "Unsupported arch" ;;
esac
export GOOS="linux"
export GOPATH="$srcdir"
export GOROOT="$builddir"
export GOBIN="$GOROOT"/bin
......@@ -64,6 +78,16 @@ build() {
done
done
# copied from bootstrap.bash to fixup cross-built bootstrap go
if [ "$CBUILD" != "$CTARGET" ]; then
local gohostos="$(../bin/go env GOHOSTOS)"
local gohostarch="$(../bin/go env GOHOSTARCH)"
mv ../bin/*_*/* ../bin
rmdir ../bin/*_*
rm -rf "../pkg/${gohostos}_${gohostarch}"* "../pkg/tool/${gohostos}_${gohostarch}"*
rm -rf ../pkg/bootstrap ../pkg/obj
fi
# FIXME some tests fail:
# PATH="$GOROOT/bin:$PATH" ./run.bash -no-rebuild || return 1
......
......@@ -20,7 +20,10 @@ CBUILDROOT="$(CTARGET=$TARGET_ARCH . /usr/share/abuild/functions.sh ; echo $CBUI
[ -e "$APORTS/main/build-base" ] || die "Unable to deduce aports base checkout"
apkbuildname() {
echo $APORTS/main/$1/APKBUILD
local repo="${1%%/*}"
local pkg="${1##*/}"
[ "$repo" = "$1" ] && repo="main"
echo $APORTS/$repo/$pkg/APKBUILD
}
msg() {
......@@ -100,6 +103,7 @@ for PKG in fortify-headers linux-headers musl libc-dev pkgconf zlib \
attr libcap patch sudo acl fakeroot tar \
pax-utils abuild openssh \
ncurses util-linux lvm2 popt xz cryptsetup kmod lddtree mkinitfs \
community/go \
$KERNEL_PKG ; do
CHOST=$TARGET_ARCH BOOTSTRAP=bootimage APKBUILD=$(apkbuildname $PKG) abuild -r
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment