Failling to compile for mipsle (mipsel)

Greetings, I want to run a relay server on a mips device and there are no prebuilt binaries for this architecture, reading compilation documentation, it seemed go is easy to cross compile, but I face errors before any compilation takes place :

Magissia@Marshmallow ~/go/syncthing/syncthing $ GOROOT=/home/Magissia/go GOPATH=/usr/lib/go-1.10/:/usr/share/go-1.10/ go run build.go -goos linux -goarch mipsle -no-upgrade zip
import cycle not allowed
package main
	imports archive/tar
	imports os/user
	imports runtime/cgo
	imports runtime/cgo

What am I missing there ? I’m using Canonical’s Xenial backport repo to install go 1.10.

Seeing the mipsle stats, I understand why there’s no pre compiled binaries for the relay.

You probably need to disable or enable cgo

Don’t ever set GOROOT. If you think you need to, fix your Go installation so that you don’t. It’s the single most common cause of mysterious errors due to screwed up Go installations. Your GOPATH is also incorrect (compared to the source being in ~/go) and the Syncthing build script will manage with it unset. The source is in the wrong place within ~/go, which is what your GOPATH is by default.

In short, don’t set GOROOT. Follow the build instructions at https://docs.syncthing.net/dev/building.html. Then you should be fine.

1 Like

Apart from using my distro’s go instead of savage installing one outside of repo, I tried to follow step by step the documentation without success because it require being root.

By using the GOROOT/GOPATH I tried to make it build it’s deps elsewhere.

Magissia@Marshmallow ~ $ cd go
Magissia@Marshmallow ~/go $ ls
github.com  src  syncthing
Magissia@Marshmallow ~/go $ cd syncthing/
Magissia@Marshmallow ~/go/syncthing $ ls
syncthing
Magissia@Marshmallow ~/go/syncthing $ cd syncthing/
Magissia@Marshmallow ~/go/syncthing/syncthing $ go run build.go -goos linux -goarch mipsle -no-upgrade zip
GOPATH is /tmp/syncthing-778fccaa
go build errors: mkdir /usr/lib/go-1.10/pkg/linux_mipsle/: permission denied
go build internal/race: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build runtime/internal/sys: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build sync/atomic: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build unicode/utf8: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build unicode: open /usr/lib/go-1.10/pkg/linux_mipsle/unicode.a: no such file or directory
go build math/bits: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build crypto/subtle: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build container/list: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build crypto/internal/cipherhw: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build math: open /usr/lib/go-1.10/pkg/linux_mipsle/math.a: no such file or directory
go build internal/nettrace: open /usr/lib/go-1.10/pkg/linux_mipsle/internal/nettrace.a: no such file or directory
go build encoding: open /usr/lib/go-1.10/pkg/linux_mipsle/encoding.a: no such file or directory
go build unicode/utf16: open /usr/lib/go-1.10/pkg/linux_mipsle/unicode/utf16.a: no such file or directory
go build vendor/golang_org/x/crypto/cryptobyte/asn1: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
go build image/color: mkdir /usr/lib/go-1.10/pkg/linux_mipsle: permission denied
exit status 1
exit status 1

You can set pkgdir to set creation of packages in a separate location. GOROOT is not the way.

go run build.go \
   -pkgdir /tmp/foo \
   -goos linux -goarch mipsle \
   -no-upgrade zip

I don’t remember off hand if “zip” works as expected for the non-Windows build, otherwise “tar” is what you’re looking for.

Having the source in ~/go/src/github.com/syncthing/syncthing (not ~/go/syncthing/syncthing as you have above) means it’s in the expected place in the default GOPATH and will work best for you. Otherwise the build script will do a little dance with creating a temporary GOPATH in /tmp and copy the source there for the build, etc, which probably works but is one thing you can avoid. The build instructions are quite explicit on this. There is even a bold “must” in a blue box.

1 Like

Thanks, built successfully for mipsle, now time to torture the poor router to check if the binaries work.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.