Jigsaw-Code/outline-go-tun2socks

gomobile, go mod, and go1.16

ignoramous opened this issue · 2 comments

I tried but couldn't build outline-go-tun2socks with go1.16. It may have to do with the recent changes with go modules in 1.16 but I haven't been able to get to the bottom of it.

The gomobile wiki asks to set go env GO111MODULE=auto, which is set, but the builds still fail:

switch version

  outline-go-tun2socks git:(master) gvm use go1.16
Now using version go1.16.3

build failure:

➜  outline-go-tun2socks git:(master) ./build_android.sh intra
+ readonly BUILD_DIR=build/android
+ BUILD_DIR=build/android
++ mktemp
+ readonly LOG_FILE=/tmp/tmp.DJoid85xXO
+ LOG_FILE=/tmp/tmp.DJoid85xXO
+ readonly TARGET=android-intra
+ TARGET=android-intra
+ rm -rf build/android
+ make clean
rm -rf /home/murtaza/hub/outline-go-tun2socks/build
+ make android-intra
+ tee /tmp/tmp.DJoid85xXO
mkdir -p /home/murtaza/hub/outline-go-tun2socks/build/android
eval ""gomobile bind -a -ldflags '-w'  -target=android -tags android -work -o /home/murtaza/hub/outline-go-tun2socks/build/android/tun2socks.aar" github.com/Jigsaw-Code/outline-go-tun2socks/intra github.com/Jigsaw-Code/outline-go-tun2socks/intra/android github.com/Jigsaw-Code/outline-go-tun2socks/intra/doh github.com/Jigsaw-Code/outline-go-tun2socks/intra/split github.com/Jigsaw-Code/outline-go-tun2socks/intra/protect"
WORK=/tmp/gomobile-work-296560557
gomobile: go build -tags android -ldflags -w -work -buildmode=c-shared -o=/tmp/gomobile-work-296560557/android/src/main/jniLibs/armeabi-v7a/libgojni.so ./gobind failed: exit status 1
WORK=/tmp/gomobile-work-296560557/go-build3347104436
go: github.com/BurntSushi/xgb@v0.0.0-20160522181843-27f122750802: missing go.sum entry; to add it:
	go mod download github.com/BurntSushi/xgb

make: *** [Makefile:42: android-intra] Error 1
++ cat /tmp/tmp.DJoid85xXO
++ grep WORK=
++ cut -f2 -d=
+ readonly 'GO_WORK_DIR=/tmp/gomobile-work-296560557
/tmp/gomobile-work-296560557/go-build3347104436'
+ GO_WORK_DIR='/tmp/gomobile-work-296560557
/tmp/gomobile-work-296560557/go-build3347104436'
+ '[' '!' -z /tmp/gomobile-work-296560557 /tmp/gomobile-work-296560557/go-build3347104436 ']'
./build_android.sh: line 29: [: /tmp/gomobile-work-296560557: binary operator expected

go env:

➜  outline-go-tun2socks git:(master) go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/u/.cache/go-build"
GOENV="/home/u/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/u/.gvm/pkgsets/go1.16.3/global/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/u/.gvm/pkgsets/go1.16.3/global"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/u/.gvm/gos/go1.16.3"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/u/.gvm/gos/go1.16.3/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/u/hub/outline-go-tun2socks/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3210367305=/tmp/go-build -gno-record-gcc-switches"

Refetching deps go get -d ./... / re-downloading gomobile / re-initing gomobile didn't work.

building with

go env -w GOFLAGS=-mod=mod

fixes it.

From: golang/go#44129

This problem doesn't exist with go1.18 and gomobile transitioning to / working well with install.