Android NDK r23 build problem

Probably stating the obvious, but still: Make sure you are doing a clean build, i.e. there’s no leftover artifacts from previous builds. I have had a weird linker issues once when I mixed docker and non-docker build artifacts.

Also there’s something about abi 16 - does the issues persist with the raised minimum api level of 21 now (actually just noticed I didn’t adjust the cc file when bumping the min sdk version)? And the bumped gradle dependency? And possibly newer ndk still?

I’ve just tried using the current main (with the latest CC patch) but there doesn’t seem to be any difference.

> Task :syncthing:checkPython
Using python 3.10.5 from C:\Users\User\AppData\Local\Programs\Python\Python310 (python)
Couldn't get final path for handle 0x178c, error code: 1

> Task :syncthing:buildNative
Caught exception: Couldn't resolve final path of, error = 1: R:\syncthing\syncthing-android
[python] python -u ./build-syncthing.py
         Building syncthing for arm
         Notice: Next generation GUI will not be built; see --with-next-gen-gui.
         # github.com/syncthing/syncthing/cmd/syncthing
         C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running R:\commandlinetools-win-9123335_latest\ndk\23.2.8568313/toolchains/llvm/prebuilt//windows-x86_64/bin/armv7a-linux-androideabi21-clang failed: exit status 1
         ld: error: cannot open output file $WORK\b001\exe\a.out: Function not implemented
         clang: error: linker command failed with exit code 1 (use -v to see invocation)

         exit status 2
         exit status 1
         Traceback (most recent call last):
           File "R:\syncthing\syncthing-android\syncthing\build-syncthing.py", line 101, in <module>
             subprocess.check_call(
           File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
           File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
             raise CalledProcessError(retcode, cmd)
         subprocess.CalledProcessError: Command '['go', 'run', 'build.go', '-goos', 'android', '-goarch', 'arm', '-cc', 'R:\\commandlinetools-win-9123335_latest\\ndk\\23.2.8568313/toolchains/llvm/prebuilt//windows-x86_64/bin/armv7a-linux-androideabi21-clang', '-pkgdir', 'R:\\syncthing\\syncthing-android\\syncthing\\gobuild\\go-packages\\arm', '-no-upgrade', 'build']' returned non-zero exit status 1.

> Task :syncthing:buildNative FAILED

FAILURE: Build failed with an exception.

This is all done in a completely clean build environment that I set up just yesterday without re-using anything from anywhere else, i.e. both syncthing-android, SDK, NDK, etc. were downloaded from scratch, so I think the build is as clean as it can be :slightly_frowning_face:, unless I’m missing something very obvious here.

I’m not sure what’s up with the Couldn't get final path for handle 0x13a4, error code: 1 error though. It wasn’t there before with the older version of Gradle.

Edit:

I’ve managed to find https://stackoverflow.com/questions/54800309/linker-error-during-so-file-creation-error-function-not-implemented. Also not sure if actually related, but the answer does talk about the problem only happening “on Windows when doing a debug build”.

The build using NDK v25 works!!!

Both with Gradle but also just from the command line like this (to compile only the binary):

set "CGO_ENABLED=1"
set "CC=<absolute-path>\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi21-clang.cmd"
go run build.go -goos android -goarch arm zip

Thank you @imsodin very much for all the fixes!!! :smiley:

1 Like