

To disable SSE4 the Android NDK compiler needs to be passed “ -mno-sse4a -mno-sse4.1 -mno-sse4.2 -mno-popcnt” (that was the only way I found). Users complained about that and that client should run on as many systems as possible. On x86 and amd64/x86_64 the Android NDK automatically uses SSE4 CPU instructions which older CPUs do not support. Again, if any library one uses does use those, they’ll need to be replaced. The solution was to replace all those calls to an own version. The Android libc, however, calls /system/bin/sh instead, which is of course not present on non-Android distributions. If you are using a library that resolves addresses that needs to have the option of using c-ares as well (such as cURL).Ī call to system() or popen(), calls the shell (usually /bin/sh). The solution for this problem was to use c-ares instead of the libc to resolve addresses.
COMPILE AGAINST LIBCURL ANDROID NDK CODE
This won’t work with the Android NDK libc (bionic libc), because it uses the Android resolver by calling some Android runtime java code that is obviously not present on non-Android systems.

If one wants to resolve a DNS name such as to an IP address one usually uses getaddrinfo(). There are significant differences between Android and other Linux distributions. The Android NDK is of course made to build programs for Android. All the dependencies that are not bundled need to be compiled to a static library (for every architecture) and in my case I have put them into $TOOLCHAIN/sysroot/usr/. The advantage UrBackup has here, is that many dependencies are already bundled with the source code like crypto++, zstd, lua and sqlite. See also the script that builds the Linux client installer. configure -enable-headless -enable-c-ares -enable-embedded-cryptopp -enable-embedded-zstd LDFLAGS="-static -Wl,-gc-sections -O2 $NDK_CPUFLAGS -flto" -host $TARGET -with-zlib=$TOOLCHAIN/sysroot/usr -with-crypto-prefix=$TOOLCHAIN/sysroot/usr -with-openssl=$TOOLCHAIN/sysroot/usr CPPFLAGS="-DURB_THREAD_STACKSIZE64=8388608 -DURB_THREAD_STACKSIZE32=1048576 -DURB_WITH_CLIENTUPDATE -ffunction-sections -fdata-sections -ggdb -O2 -flto $ARCH_CPPFLAGS" CFLAGS="-ggdb -O2 -flto $NDK_CPUFLAGS" CXXFLAGS="-ggdb -O2 -flto $NDK_CPUFLAGS -I$NDK/sources/android/cpufeatures/ -DOPENSSL_SEARCH_CA" LIBS="-ldl" Since UrBackup uses autotools to build, cross compilation is automatically present and can be used simply by setting a few environment variables before building: export NDK=/path/to/android/ndk/android-ndk-r20Įxport TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAGĮxport CXX=$TOOLCHAIN/bin/$TARGET2-clang++Įxport RANLIB=$TOOLCHAIN/bin/$TARGET-ranlibĮxport STRIP=$TOOLCHAIN/bin/$TARGET-strip Previously this was done with ELLCC, but that doesn’t support C++ exceptions and doesn’t seem to get updated anymore. because the glibc is too old), does it fall back to the NDK build. To mitigate the disadvantages the UrBackup client Linux binary installer first tries to use a glibc (non-static) build on amd64/x86_64 (the most common platform). when it doesn’t respect /etc/nf, parses /etc/nf differently or when OpenSSL looks for the root certificates in the wrong place Behavior might deviate from other programs in the distribution.Might use more memory at runtime since libraries (such as libc.so) aren’t shared with other programs.All the dependencies are static and confirmed to work together.Theoretically it’ll even work without a Linux distribution, e.g.

Linus Torvalds) is pretty strict about backwards compatibility so it’ll continue to run on future Linux kernels without problems
