Android NDK r22 build problem

Hi,

I’ve bumped the go version (for the forked android app) from 1.15.2 to 1.15.6 → no problem. I’ve bumped SyncthingNative to the v1.12.1-rc.1 RC commit. → no problem. I’ve bumped the Android NDK version from r21b to r22. → I’m getting this error.

Do you have any idea what could be the cause here (code? build parameters?). I would happily provide more info if neccessary. Which NDK version is used for the “docker build” in official?

Cleaning go-build cache
Building syncthing version v1.12.1-preview.1

*** Building for arm
runtime/internal/sys
internal/cpu
unicode/utf8
internal/race
internal/unsafeheader
unicode
container/list
sync/atomic
math/bits
crypto/internal/subtle
runtime/internal/math
crypto/subtle
internal/bytealg
runtime/internal/atomic
unicode/utf16
vendor/golang.org/x/crypto/cryptobyte/asn1
internal/nettrace
internal/testlog
math
vendor/golang.org/x/crypto/internal/subtle
encoding
google.golang.org/protobuf/internal/flags
runtime/cgo
google.golang.org/protobuf/internal/fieldnum
google.golang.org/protobuf/internal/set
google.golang.org/protobuf/internal/genname
golang.org/x/sys/internal/unsafeheader
golang.org/x/net/internal/iana
golang.org/x/crypto/internal/subtle
github.com/dgraph-io/badger/v2/options
github.com/dgraph-io/badger/v2/trie
github.com/cheekybits/genny/generic
golang.org/x/crypto/cryptobyte/asn1
github.com/gobwas/glob/util/runes
image/color
runtime
github.com/greatroar/blobloom
internal/reflectlite
sync
internal/singleflight
google.golang.org/protobuf/internal/pragma
math/rand
errors
sort
internal/oserror
vendor/golang.org/x/net/dns/dnsmessage
io
strconv
container/heap
github.com/gogo/protobuf/sortkeys
syscall
hash
bytes
strings
crypto/internal/randutil
crypto/hmac
hash/crc32
vendor/golang.org/x/crypto/hkdf
hash/fnv
golang.org/x/crypto/hkdf
crypto
reflect
crypto/rc4
bufio
path
regexp/syntax
github.com/petermattis/goid
vendor/golang.org/x/text/transform
golang.org/x/text/transform
encoding/base32
golang.org/x/crypto/pbkdf2
github.com/dchest/siphash
html
text/tabwriter
github.com/syndtr/goleveldb/leveldb/comparer
time
internal/syscall/unix
internal/syscall/execenv
golang.org/x/crypto/md4
regexp
github.com/gobwas/glob/util/strings
hash/adler32
github.com/kballard/go-shellquote
github.com/chmduquesne/rollinghash
github.com/vitrun/qart/gf256
image
golang.org/x/crypto/blowfish
github.com/chmduquesne/rollinghash/adler32
context
internal/poll
internal/fmtsort
encoding/binary
github.com/syncthing/syncthing/lib/weakhash
crypto/sha256
crypto/md5
crypto/ed25519/internal/edwards25519
crypto/sha512
crypto/sha1
crypto/cipher
os
encoding/base64
vendor/golang.org/x/crypto/poly1305
crypto/aes
crypto/des
vendor/golang.org/x/crypto/chacha20
golang.org/x/sys/unix
encoding/pem
github.com/bkaradzic/go-lz4
github.com/miscreant/miscreant.go/block
github.com/minio/sha256-simd
fmt
path/filepath
vendor/golang.org/x/crypto/chacha20poly1305
google.golang.org/protobuf/internal/detrand
github.com/miscreant/miscreant.go/cmac
runtime/debug
github.com/miscreant/miscreant.go/pmac
golang.org/x/crypto/chacha20
golang.org/x/crypto/poly1305
golang.org/x/crypto/scrypt
io/ioutil
os/exec
github.com/cespare/xxhash
golang.org/x/crypto/chacha20poly1305
github.com/dgryski/go-farm
github.com/golang/snappy
golang.org/x/sys/cpu
os/signal
math/big
encoding/hex
net/url
vendor/golang.org/x/crypto/curve25519
flag
github.com/pkg/errors
log
encoding/json
encoding/xml
compress/flate
github.com/syncthing/syncthing/lib/build
google.golang.org/protobuf/internal/errors
go/token
google.golang.org/protobuf/internal/version
google.golang.org/protobuf/encoding/protowire
github.com/shirou/gopsutil/internal/common
github.com/syncthing/syncthing/lib/logger
compress/gzip
github.com/gogo/protobuf/proto
os/user
crypto/elliptic
encoding/asn1
crypto/rand
crypto/dsa
google.golang.org/protobuf/reflect/protoreflect
github.com/sasha-s/go-deadlock
crypto/ed25519
crypto/rsa
github.com/shirou/gopsutil/disk
github.com/thejerf/suture/v4
vendor/golang.org/x/crypto/cryptobyte
crypto/x509/pkix
google.golang.org/protobuf/internal/descfmt
google.golang.org/protobuf/internal/descopts
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/internal/fieldsort
google.golang.org/protobuf/internal/mapsort
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/internal/encoding/text
github.com/syncthing/syncthing/lib/sync
crypto/ecdsa
google.golang.org/protobuf/internal/encoding/messageset
github.com/syncthing/notify
runtime/trace
github.com/syncthing/syncthing/lib/events
github.com/syncthing/syncthing/lib/connections/registry
google.golang.org/protobuf/proto
# runtime/cgo
ld: error: duplicate symbol: x_cgo_inittls
>>> defined at gcc_android.c:90
>>>            $WORK\b078\_x003.o:(x_cgo_inittls)
>>> defined at gcc_linux_arm.c:13
>>>            $WORK\b078\_x006.o:(.bss+0x4)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
golang.org/x/net/bpf
testing
vendor/golang.org/x/text/unicode/bidi
google.golang.org/protobuf/internal/encoding/defval
vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/net/http2/hpack
mime
mime/quotedprintable
vendor/golang.org/x/text/secure/bidirule
net/http/internal
golang.org/x/text/unicode/norm
github.com/miscreant/miscreant.go
github.com/syncthing/syncthing/lib/rand
github.com/syncthing/syncthing/lib/sha256
google.golang.org/protobuf/internal/filedesc
google.golang.org/protobuf/encoding/prototext
github.com/syncthing/syncthing/lib/upgrade
golang.org/x/net/internal/timeseries
text/template/parse
vendor/golang.org/x/net/idna
github.com/dgraph-io/ristretto/z
github.com/dustin/go-humanize
github.com/syndtr/goleveldb/leveldb/util
github.com/syndtr/goleveldb/leveldb/storage
github.com/dgraph-io/ristretto
archive/zip
github.com/go-asn1-ber/asn1-ber
github.com/syndtr/goleveldb/leveldb/cache
text/template
github.com/syndtr/goleveldb/leveldb/filter
google.golang.org/protobuf/internal/encoding/tag
runtime/pprof
github.com/gogo/protobuf/protoc-gen-gogo/descriptor
github.com/syndtr/goleveldb/leveldb/errors
github.com/gogo/protobuf/types
github.com/syndtr/goleveldb/leveldb/opt
google.golang.org/protobuf/internal/impl
github.com/lucas-clemente/quic-go/internal/protocol
github.com/syndtr/goleveldb/leveldb/iterator
github.com/syndtr/goleveldb/leveldb/journal
golang.org/x/crypto/cryptobyte
github.com/syndtr/goleveldb/leveldb/memdb
github.com/syndtr/goleveldb/leveldb/table
golang.org/x/crypto/curve25519
html/template
github.com/calmh/xdr
golang.org/x/time/rate
github.com/gobwas/glob/match
github.com/gobwas/glob/syntax/lexer
github.com/syndtr/goleveldb/leveldb
database/sql/driver
github.com/gogo/protobuf/gogoproto
github.com/syncthing/syncthing/proto/ext
github.com/gobwas/glob/syntax/ast
github.com/vitrun/qart/coding
github.com/syncthing/syncthing/lib/fs
golang.org/x/crypto/bcrypt
github.com/syncthing/syncthing/lib/protocol
github.com/gobwas/glob/compiler
github.com/gobwas/glob/syntax
github.com/vitrun/qart/qr
internal/profile
github.com/gobwas/glob
github.com/syncthing/syncthing/lib/locations
google.golang.org/protobuf/internal/filetype
google.golang.org/protobuf/runtime/protoimpl
google.golang.org/protobuf/types/known/timestamppb
github.com/golang/protobuf/proto
github.com/golang/protobuf/ptypes/timestamp
github.com/dgraph-io/badger/v2/pb
exit status 2
exit status 1

Thanks!

Catfriend1

We build with whatever sdkmanager gives us:

Which is likely not a particularly good idea (as your problems show).

Right now according to the ndk changelog in our docker image it is r21d. I think such problems existed in the past as well and disappeared again - I don’t think it’s worth looking into. Just keep using a working ndk until a newer one works again.

Also https://github.com/golang/go/issues/42655

2 Likes

Ok, I’m now back using r21b which works fine to compile and will monitor the GitHub issue you’ve linked to :-). Thanks

It appears that at the moment the only supported toolchain is r23 (see https://developer.android.com/ndk/downloads). Everything else has been marked as “unsupported”.

However, building Syncthing with the r23 toolchain using even the newest Go 1.17 results in

ld: error: cannot open output file $WORK\b083\_cgo_.o: Function not implemented
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exit status 2
exit status 1

Does this mean that the only way to build Syncthing for Android is to keep using the old r21e toolchain?

1 Like

Which makes sense as r23 removed GNU binutils and completed the switch to lld(not a typo):

1 Like

I had a successful build of v1.18.2 using NDK r22b and Go 1.17

I can confirm that NDK 22 works with Go 1.17 :slightly_smiling_face:. This version of NDK is still EOL, but I guess we should be happy that at least some progress has been made.

1 Like

Let’s close the thread and maybe later start a new one for r23 ndk.