diff --git a/packages/golang/build.sh b/packages/golang/build.sh index b27b53c14..d745d36ad 100644 --- a/packages/golang/build.sh +++ b/packages/golang/build.sh @@ -1,6 +1,7 @@ TERMUX_PKG_HOMEPAGE=https://golang.org/ TERMUX_PKG_DESCRIPTION="Go programming language compiler" TERMUX_PKG_VERSION=1.5rc1 +TERMUX_PKG_BUILD_REVISION=1 TERMUX_PKG_SRCURL=https://storage.googleapis.com/golang/go1.5rc1.src.tar.gz TERMUX_PKG_FOLDERNAME=go TERMUX_PKG_KEEP_STATIC_LIBRARIES=true @@ -18,11 +19,13 @@ termux_step_post_extract_package () { termux_step_make_install () { if [ "$TERMUX_ARCH" = "arm" ]; then - TERMUX_GOLANG_DIRNAME=linux_arm + export GOOS=android + export CGO_ENABLED=1 export GOARCH=arm export GOARM=7 elif [ "$TERMUX_ARCH" = "i686" ]; then - TERMUX_GOLANG_DIRNAME=linux_386 + export GOOS=linux + export CGO_ENABLED=0 export GOARCH=386 export GO386=sse2 else @@ -30,12 +33,20 @@ termux_step_make_install () { exit 1 fi + TERMUX_GOLANG_DIRNAME=${GOOS}_$GOARCH + TERMUX_GODIR=$TERMUX_PREFIX/lib/go rm -Rf $TERMUX_GODIR mkdir -p $TERMUX_GODIR/{src,pkg/tool/$TERMUX_GOLANG_DIRNAME,pkg/include,pkg/$TERMUX_GOLANG_DIRNAME} cd $TERMUX_PKG_SRCDIR/src - env CC_FOR_TARGET=$CC CC=gcc GOROOT_BOOTSTRAP=$TERMUX_HOST_GOLANG_DIR GOROOT_FINAL=$TERMUX_GODIR GOOS=linux ./make.bash + env CC_FOR_TARGET=$CC \ + CXX_FOR_TARGET=$CXX \ + CC=gcc \ + GO_LDFLAGS="-extldflags=-pie" \ + GOROOT_BOOTSTRAP=$TERMUX_HOST_GOLANG_DIR \ + GOROOT_FINAL=$TERMUX_GODIR \ + ./make.bash cd .. cp bin/$TERMUX_GOLANG_DIRNAME/{go,gofmt} $TERMUX_PREFIX/bin diff --git a/packages/golang/src-runtime-cgo-cgo.go.patch b/packages/golang/src-runtime-cgo-cgo.go.patch new file mode 100644 index 000000000..30bfce272 --- /dev/null +++ b/packages/golang/src-runtime-cgo-cgo.go.patch @@ -0,0 +1,11 @@ +diff -u -r ../go/src/runtime/cgo/cgo.go ./src/runtime/cgo/cgo.go +--- ../go/src/runtime/cgo/cgo.go 2015-08-06 00:36:35.000000000 -0400 ++++ ./src/runtime/cgo/cgo.go 2015-08-16 16:03:29.614948543 -0400 +@@ -16,7 +16,6 @@ + #cgo darwin,arm64 LDFLAGS: -framework CoreFoundation + #cgo dragonfly LDFLAGS: -lpthread + #cgo freebsd LDFLAGS: -lpthread +-#cgo android LDFLAGS: -llog + #cgo !android,linux LDFLAGS: -lpthread + #cgo netbsd LDFLAGS: -lpthread + #cgo openbsd LDFLAGS: -lpthread diff --git a/packages/golang/src-runtime-cgo-gcc_android.c.patch b/packages/golang/src-runtime-cgo-gcc_android.c.patch new file mode 100644 index 000000000..9b1a1b4fd --- /dev/null +++ b/packages/golang/src-runtime-cgo-gcc_android.c.patch @@ -0,0 +1,25 @@ +diff -u -r ../go/src/runtime/cgo/gcc_android.c ./src/runtime/cgo/gcc_android.c +--- ../go/src/runtime/cgo/gcc_android.c 2015-08-06 00:36:35.000000000 -0400 ++++ ./src/runtime/cgo/gcc_android.c 2015-08-16 16:08:05.346940583 -0400 +@@ -11,21 +11,11 @@ + { + va_list ap; + +- // Write to both stderr and logcat. +- // +- // When running from an .apk, /dev/stderr and /dev/stdout +- // redirect to /dev/null. And when running a test binary +- // via adb shell, it's easy to miss logcat. +- + fprintf(stderr, "runtime/cgo: "); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + fprintf(stderr, "\n"); + +- va_start(ap, format); +- __android_log_vprint(ANDROID_LOG_FATAL, "runtime/cgo", format, ap); +- va_end(ap); +- + abort(); + }