I am not that familiar with building go applications, so I can’t tell if this is bug in Restic, a bug in Termux, or expected behavior. Here are the steps I took in Termux:
pkg install golang git
git clone https://github.com/restic/restic
cd restic
go run build.go
The last command failed with this output:
build: detected Go version Go 1.10.2
build: adding build-tag release
build: build tags: [release]
build: create GOPATH at /data/data/com.termux/files/usr/tmp/restic-build-626089241
build: copy contents of /data/data/com.termux/files/home/restic to /data/data/com.termux/files/usr/tmp/restic-build-626089241/github.com/restic/restic
build: copy contents of /data/data/com.termux/files/home/restic/vendor to /data/data/com.termux/files/usr/tmp/restic-build-626089241/github.com/restic/restic/vendor
build: git version is v0.8.3-226-gabdd59ea
build: version from file 'VERSION' is "0.8.3", version from git "v0.8.3-226-gabdd59ea"
build: ldflags: -s -w -X "main.version=0.8.3 (v0.8.3-226-gabdd59ea)"
build: Go version is at least 1.10, using new syntax for -gcflags
build: go [build -asmflags all=-trimpath=/data/data/com.termux/files/usr/tmp/restic-build-626089241 -gcflags all=-trimpath=/data/data/com.termux/files/usr/tmp/restic-build-626089241 -tags release -ldflags -s -w -X "main.version=0.8.3 (v0.8.3-226-gabdd59ea)" -o /data/data/com.termux/files/home/restic/restic github.com/restic/restic/cmd/restic]
# github.com/restic/restic/cmd/restic
/data/data/com.termux/files/usr/lib/go/pkg/tool/android_arm/link: running arm-linux-androideabi-clang failed: exit status 1
/data/data/com.termux/files/usr/tmp/go-link-771939528/go.o:(.data+0x0): undefined reference to `x_cgo_init'
/data/data/com.termux/files/usr/tmp/go-link-771939528/go.o:(.data+0x4): undefined reference to `x_cgo_notify_runtime_init_done'
/data/data/com.termux/files/usr/tmp/go-link-771939528/go.o:(.data+0x8): undefined reference to `x_cgo_thread_start'
/data/data/com.termux/files/usr/tmp/go-link-771939528/go.o:(.data+0x150): undefined reference to `x_cgo_setenv'
/data/data/com.termux/files/usr/tmp/go-link-771939528/go.o:(.data+0x154): undefined reference to `x_cgo_unsetenv'
/data/data/com.termux/files/usr/tmp/go-link-771939528/go.o:(.data+0x158): undefined reference to `_cgo_yield'
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
build failed: exit status 2
exit status 1
I found an old Restic issue that led to a Termux issue. Since all my error messages referenced cgo
and the workaround to the previous issue was to edit build.go
by removing a CGO_ENABLED=0
line, I re-ran the last line as go run build.go --enable-cgo
and the build succeeded.
Should I need to use --enable-cgo
to build Restic in Termux, or does this indicate that something is broken in the way build.go
interacts with Termux’s Go package like it was before?