I am trying to cross compile the sers library from
github.com/distributed/sers to arm64 android.
I have an Android SDK on my computer and I point $AR, $CC, $CXX and so on to the relevant programs.
~/tmp/sers$ CGO_ENABLED=1 GOARCH=arm64 GOOS=linux go get
# runtime/cgo
/home/joe/android/toolchain/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lpthread
clang60: error: linker command failed with exit code 1 (use -v to see invocation)
My go env is:
~/tmp/sers$ CGO_ENABLED=1 GOARCH=arm64 GOOS=linux go env
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/joe/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/joe/gop"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="aarch64-linux-android-clang"
CXX="aarch64-linux-android-clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build095666131=/tmp/go-build -gno-record-gcc-switches"
I am using Go 1.11.
I suspect that the toolchain attempts to link against -lpthread, but this is not necessary, since pthread functionality is included in the C library in Android.
Does anybody know how to circumvent this build problem?