Browse Source

Fixed Android build

Caleb James DeLisle 1 year ago
parent
commit
78adf05ef0
5 changed files with 76 additions and 59 deletions
  1. 48 39
      Cargo.lock
  2. 22 16
      android_do
  3. 1 0
      node_build/dependencies/libuv/src/unix/pthread-fixes.c
  4. 3 2
      node_build/make.js
  5. 2 2
      rust/cjdns_sys/Cargo.toml

+ 48 - 39
Cargo.lock

@@ -120,7 +120,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
 [[package]]
 name = "boringtun"
 version = "0.3.0"
-source = "git+https://github.com/cjdelisle/boringtun?rev=9dd253904616ff5327267cc4073dcf61e60b858e#9dd253904616ff5327267cc4073dcf61e60b858e"
+source = "git+https://github.com/cjdelisle/boringtun?rev=f288b2f461e7322a278b63b1ddc4ab705b5b7462#f288b2f461e7322a278b63b1ddc4ab705b5b7462"
 dependencies = [
  "base64",
  "chrono",
@@ -475,9 +475,9 @@ dependencies = [
 
 [[package]]
 name = "ipnetwork"
-version = "0.18.0"
+version = "0.19.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4088d739b183546b239688ddbc79891831df421773df95e236daf7867866d355"
+checksum = "1f84f1612606f3753f205a4e9a2efd6fe5b4c573a6269b2cc6c3003d44a0d127"
 dependencies = [
  "serde",
 ]
@@ -531,9 +531,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
 
 [[package]]
 name = "libc"
-version = "0.2.112"
+version = "0.2.139"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
+checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
 
 [[package]]
 name = "libloading"
@@ -621,6 +621,12 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "no-std-net"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65"
+
 [[package]]
 name = "nom"
 version = "5.1.2"
@@ -750,9 +756,9 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
 
 [[package]]
 name = "pnet"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8750e073f82219c01e771133c64718d7685aef922da8a0d430a46aed05b6341a"
+checksum = "0caaf5b11fd907ff15cf14a4477bfabca4b37ab9e447a4f8dead969a59cdafad"
 dependencies = [
  "ipnetwork",
  "pnet_base",
@@ -764,15 +770,18 @@ dependencies = [
 
 [[package]]
 name = "pnet_base"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8205fe084bd43a3af79b3155c19feddd62e733640498842e631a2ffe107d1538"
+checksum = "f9d3a993d49e5fd5d4d854d6999d4addca1f72d86c65adf224a36757161c02b6"
+dependencies = [
+ "no-std-net",
+]
 
 [[package]]
 name = "pnet_datalink"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f85aef5e52e22ff06b1b11f2eb6d52959a9e0ecad3cb3f5cc2d78cadc077f0e"
+checksum = "e466faf03a98ad27f6e15cd27a2b7cc89e73e640a43527742977bc503c37f8aa"
 dependencies = [
  "ipnetwork",
  "libc",
@@ -783,9 +792,9 @@ dependencies = [
 
 [[package]]
 name = "pnet_macros"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "98cc3af95fed6dc318dfede3e81320f96ad5e237c6f7c4688108b19c8e67432d"
+checksum = "48dd52a5211fac27e7acb14cfc9f30ae16ae0e956b7b779c8214c74559cef4c3"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -795,18 +804,18 @@ dependencies = [
 
 [[package]]
 name = "pnet_macros_support"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "feaba58ba96abb218ec584d6caf0d3ff48922df05dbbeb1560553c197091b29e"
+checksum = "89de095dc7739349559913aed1ef6a11e73ceade4897dadc77c5e09de6740750"
 dependencies = [
  "pnet_base",
 ]
 
 [[package]]
 name = "pnet_packet"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f246edaaf1aaf82072d4cd38ee18bcc5dfc0464093f9ca39e4ac5962d68cf9d4"
+checksum = "bc3b5111e697c39c8b9795b9fdccbc301ab696699e88b9ea5a4e4628978f495f"
 dependencies = [
  "glob",
  "pnet_base",
@@ -816,9 +825,9 @@ dependencies = [
 
 [[package]]
 name = "pnet_sys"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "028c87a5e3a48fc07df099a2025f2ef16add5993712e1494ba69a6707ee7ed06"
+checksum = "328e231f0add6d247d82421bf3790b4b33b39c8930637f428eef24c4c6a90805"
 dependencies = [
  "libc",
  "winapi",
@@ -826,9 +835,9 @@ dependencies = [
 
 [[package]]
 name = "pnet_transport"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "950f2a7961e19d22e19e84ff0a6e0955013185fe149673499662633d02b41b7a"
+checksum = "ff597185e6f1f5671b3122e4dba892a1c73e17c17e723d7669bd9299cbe7f124"
 dependencies = [
  "libc",
  "pnet_base",
@@ -844,11 +853,11 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.36"
+version = "1.0.50"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
+checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
 dependencies = [
- "unicode-xid",
+ "unicode-ident",
 ]
 
 [[package]]
@@ -859,9 +868,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
 
 [[package]]
 name = "quote"
-version = "1.0.14"
+version = "1.0.23"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
+checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
 dependencies = [
  "proc-macro2",
 ]
@@ -933,9 +942,9 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.5.4"
+version = "1.7.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
+checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
 dependencies = [
  "aho-corasick",
  "memchr",
@@ -944,9 +953,9 @@ dependencies = [
 
 [[package]]
 name = "regex-syntax"
-version = "0.6.25"
+version = "0.6.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
+checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
 
 [[package]]
 name = "remove_dir_all"
@@ -1113,13 +1122,13 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
 
 [[package]]
 name = "syn"
-version = "1.0.85"
+version = "1.0.107"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7"
+checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
 dependencies = [
  "proc-macro2",
  "quote",
- "unicode-xid",
+ "unicode-ident",
 ]
 
 [[package]]
@@ -1241,6 +1250,12 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "unicode-ident"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
+
 [[package]]
 name = "unicode-segmentation"
 version = "1.7.1"
@@ -1253,12 +1268,6 @@ version = "0.1.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
 
-[[package]]
-name = "unicode-xid"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
-
 [[package]]
 name = "unreachable"
 version = "1.0.0"

+ 22 - 16
android_do

@@ -25,7 +25,7 @@ need rustc
 need cargo
 
 BUILD_PATH=$(pwd)/build_android
-NDK_VERSION="android-ndk-r21"
+NDK_VERSION="android-ndk-r25b"
 
 case $(uname -s) in
     Darwin)
@@ -70,10 +70,10 @@ cpu_arch="$(uname -m)"
 if test "x$CJDNS_NDK_PATH" = "x"; then
   mkdir "$BUILD_PATH" 2>/dev/null
   cd "$BUILD_PATH"
-  filename="$NDK_VERSION-${TYPE}-${cpu_arch}.zip"
+  filename="$NDK_VERSION-${TYPE}.zip"
   echo "$filename"
   if ! [ -f "$filename" ]; then
-    url="https://dl.google.com/android/repository/$NDK_VERSION-${TYPE}-${cpu_arch}.zip"
+    url="https://dl.google.com/android/repository/$NDK_VERSION-${TYPE}.zip"
     wget "$url" || die "wget $url failed"
   fi
   if ! [ -d "$NDK_VERSION" ]; then
@@ -86,41 +86,47 @@ fi
 
 BUILD_0='
   APP_ABI=armv7a
-  TOOLCHAIN_PREFIX=arm
+  RUST_TARGET=armv7-linux-androideabi
   EABI=androideabi
-  VERSION=16
+  VERSION=26
 '
 BUILD_1='
   APP_ABI=aarch64
-  VERSION=21
+  VERSION=26
 '
 BUILD_2='
   APP_ABI=i686
-  VERSION=16
+  VERSION=26
 '
 BUILD_3='
   APP_ABI=x86_64
-  VERSION=21
+  VERSION=26
 '
 
-for i in $(seq 1 100); do
+# https://github.com/rust-lang/rust/pull/85806
+find "${BUILD_PATH}" -name 'libunwind.a' | \
+  sed 's@libunwind.a$@libgcc.a@' | \
+  while read x; do
+    echo "INPUT(-lunwind)" > $x
+  done
+
+for i in $(seq 0 100); do
   BUILD=$(eval echo "\$BUILD_$i")
   if test "x$BUILD" = "x"; then
     continue
   fi
-  TOOLCHAIN_PREFIX=
+  RUST_TARGET=
   APP_ABI=
   VERSION=
   EABI=android
   export $BUILD
-  if test "x$TOOLCHAIN_PREFIX" = "x"; then
-    TOOLCHAIN_PREFIX=$APP_ABI
+  if test "x$RUST_TARGET" = "x"; then
+    RUST_TARGET="$APP_ABI-linux-$EABI"
   fi
 
-  RUST_TARGET="$APP_ABI-linux-$EABI"
   if ! [ -d "$(rustc --target "$RUST_TARGET" --print target-libdir)" ]; then
     echo
-    echo 'Skipping i686-linux-android because we dont have that toolchain'
+    echo "Skipping $RUST_TARGET because we dont have that toolchain"
     echo "Use: \`rustup target add $RUST_TARGET\` to install it"
     echo
     echo
@@ -128,7 +134,7 @@ for i in $(seq 1 100); do
   fi
 
   CROSS_PATH=$CJDNS_NDK_PATH/toolchains/llvm/prebuilt/${TYPE}-${cpu_arch}/bin
-  CROSS_PREFIX=${CROSS_PATH}/${TOOLCHAIN_PREFIX}-linux-${EABI}
+  CROSS_PREFIX=${CROSS_PATH}/llvm
 
   export CC=${CROSS_PATH}/${APP_ABI}-linux-${EABI}${VERSION}-clang
 
@@ -144,7 +150,7 @@ for i in $(seq 1 100); do
   export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$CC
   export CARGO_TARGET_I686_LINUX_ANDROID_LINKER=$CC
   export CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$CC
-  export CARGO_TARGET_ARMV7A_LINUX_ANDROIDEABI_LINKER=$CC
+  export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$CC
 
   echo "Compiler CC: $CC - $(${CC} --version)"
   cargo build --release -v --target "$RUST_TARGET"

+ 1 - 0
node_build/dependencies/libuv/src/unix/pthread-fixes.c

@@ -29,6 +29,7 @@
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#include <pthread.h>
 
 /*Android doesn't provide pthread_barrier_t for now.*/
 #ifndef PTHREAD_BARRIER_SERIAL_THREAD

+ 3 - 2
node_build/make.js

@@ -35,7 +35,7 @@ Builder.configure({
 }, function (builder, waitFor) {
 
     builder.config.crossCompiling = process.env['CROSS'] !== undefined;
-    let optimizeLevel = '-O0';
+    let optimizeLevel = '-O2';
 
     builder.config.cflags.push(
         '-std=c99',
@@ -168,7 +168,8 @@ Builder.configure({
     }
 
     if (android) {
-        builder.config.cflags.push('-Dandroid=1');
+        // NDK uses the word `android` in places
+        builder.config.cflags.push('-Dandroid=android');
     }
 
     var uclibc = process.env['UCLIBC'] == '1';

+ 2 - 2
rust/cjdns_sys/Cargo.toml

@@ -14,9 +14,9 @@ log = { version = "0.4", features = ["std", "release_max_level_trace"] }
 parking_lot = "0.11"
 thiserror = "1.0"
 anyhow = { version = "1.0", features = ["backtrace"] }
-boringtun = { git = "https://github.com/cjdelisle/boringtun", rev = "9dd253904616ff5327267cc4073dcf61e60b858e", version = "0.3", features = ["additional_data"] }
+boringtun = { git = "https://github.com/cjdelisle/boringtun", rev = "f288b2f461e7322a278b63b1ddc4ab705b5b7462", version = "0.3", features = ["additional_data"] }
 slog = { version = "2.7", features = ["release_max_level_trace"] }
-pnet = "0.29"
+pnet = { version = "0.31", features = ["std"] }
 tokio = { version = "1", features = ["macros","time","sync","fs","rt-multi-thread","process"], default-features = false }
 
 [build_dependencies]