How to compile Syncthing tools (stindex, etc.)?

I am trying to compile Syncthing tools, and specifically stindex for Android ARM. There is no information on building the tools in the Docs, but I have found this forum post by @Catfriend1 and trying to use a similar command.

go run build.go -goos android -goarch arm build all

but there are no binaries after the compilation. I am building on Windows, if that matters. When I build Windows binaries, then a bunch of Windows executables are also placed in the bin folder, but there is nothing like that when building for Android.

Also, just a side note, but it seems that the current tools keep failing to compile on https://build.syncthing.net/buildConfiguration/Syncthing_Tools?mode=builds#all-projects.

I think for these tools you can just target arm instead of android, as building for android requires ndk and the c toolchain.

I have both the NDK and the toolchain, and I can build the actual syncthing binary for Android, so this is not the issue. There are no visible errors, it is just that the bin folder is empty once the compiling has finished.

Anyhow, I have now tried using

go run build.go -goos linux -goarch arm build all

but there is nothing in bin after the compilation either.

I don’t think build all is a thing that works. It creates the appropriate command line for the go compiler, but it doesn’t appear to create binaries for the things. build otherwise puts the binaries in the current dir.

You can do the equivalent yourself, getting a binary that just lacks version tagging:

jb@kvin:../syncthing/syncthing % GOOS=linux GOARCH=arm go build ./cmd/stindex
jb@kvin:../syncthing/syncthing % ls -l stindex
-rwxr-xr-x  1 jb  staff  14795445 Oct 13 17:27 stindex*
jb@kvin:../syncthing/syncthing % file stindex
stindex: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go BuildID=5V6OT0i4Bx-IMNEeWGGH/shFfFThDt9BcwDfpm1om/8ZsxJz5RxqfDXUW0oVQi/FGxD0AixP3GmgxOK7lQV, not stripped
jb@kvin:../syncthing/syncthing %

Giving go build more than one package on the same command line appears to not create any binaries at all.

2 Likes