I am compiling Syncthing for Android to develop an app as part of the Syncthing Tray project. I am usually just blindly using the Go version provided by Arch Linux, currently that is Go 1.23.5. It works - on my phone with Android 14 (aarch64) and the Android emulator with Android 15 (x86_64) I can run my app which in turn can run Syncthing (within the same process as I built Syncthing as library).
I noticed that it doesn’t work on my older phone with Android 10 (aarch64) and also not on the Android emulator with Android 10 (x86_64). The error log doesn’t say much:
2025-01-22 23:57:22.177 8343-8377 Qt io.github.martchus.syncthingtray I qt started
2025-01-22 23:57:22.189 8343-8381 libc io.github.martchus.syncthingtray A Fatal signal 31 (SIGSYS), code 1 (SYS_SECCOMP) in tid 8381 (qtMainLoopThrea), pid 8343 (s.syncthingtray)
2025-01-22 23:57:22.201 8343-8343 SyncthingActivity io.github.martchus.syncthingtray I Starting
2025-01-22 23:57:22.202 8343-8343 SyncthingActivity io.github.martchus.syncthingtray I Resuming
2025-01-22 23:57:22.229 8391-8391 DEBUG pid-8391 A pid: 8343, tid: 8381, name: qtMainLoopThrea >>> io.github.martchus.syncthingtray <<<
2025-01-22 23:57:22.229 8391-8391 DEBUG pid-8391 A #00 pc 000000000065d20e /data/app/io.github.martchus.syncthingtray-hAz0hxna8xVgPw-Qly4PwA==/lib/x86_64/libsyncthinginternal.so (offset 0x5d9000)
The startup of Qt is logged at which point it loads native libraries which means loading also Syncthing build as shared library. And there it crashes, presumably because Syncthing (or rather something in its Go software stack) tries to invoke an invalid/disallowed syscall.
Everything works also under Android 10 when I do not link against the Syncthing library. So I am sure it must be the culprit.
I am already adding --target=x86_64-none-linux-android21
to all C/C++ compiler invocations by setting CGO_CFLAGS
and other variables. To be super sure I also tried hardcoding CC=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang
and CXX=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++
. However, it didn’t make a difference and I am sure the Android API level for native compilations is set correctly.
This leaves the compilation of Go code. So I tried an older Go version:
$ go install golang.org/dl/go1.21.13@latest
$ $GOPATH/bin/go1.21.13 download
…
Success. You may now run 'go1.21.13'
$GOPATH/bin/go1.21.13 version
go version go1.21.13 linux/amd64
…
Then I re-configured/re-built Syncthing Tray (and the Syncthing library) with that Go version (just for my own record, I was using: cmake --preset arch-android -DGO_BIN=$GOPATH/bin/go1.21.13 && cmake --build --preset arch-android
). The resulting APK then worked under Android 10 in the emulator. (I haven’t tested it on my older phone yet.)
Then I changed it back to /usr/bin/go
(this is 1.13.5 as provided by Arch Linux) to be sure the problem has not just ceased due to some cache wiping when changing the Go version. Considering it immediately stopped to work again I don’t think this is the case.
Then I changed the binary to $GOPATH/bin/go1.22.11
(installed using the same steps as shown for 1.21.13) and it worked again.
This suggests that Go introduced the unconditional usage of a syscall as of version 1.23.? and that syscall is not available under older Android versions. Not sure what the new minimum Android version is with that syscall (but the new minimum must be in the range of (10, 14]
).
This might be an intentional change. Unfortunately I couldn’t find anything about the minimum Android version required by Go, e.g. Go Wiki: Minimum Requirements - The Go Programming Language doesn’t mention Android at all. I also haven’t found much via Google.
@Catfriend1 If you’re reading this, did you also run into this problem when testing the fork app? What version of Go and Android have you been testing on?