bbqsrc / cargo-ndk

Compile Rust projects against the Android NDK without hassle
Apache License 2.0
694 stars 64 forks source link

Can't build crate that depends on `openssl` on macOS ARM #151

Closed setoelkahfi closed 4 hours ago

setoelkahfi commented 6 hours ago

I have a crate that uses reqwest that depends on native-tls that in turn depends on openssl:

 openssl-sys v0.9.103
├── native-tls v0.2.12
│   ├── hyper-tls v0.6.0
│   │   └── reqwest v0.12.7
│   │       └── crate_networking v0.1.0 (/splitfire/lib/crate_networking)
│   ├── reqwest v0.12.7 (*)
│   └── tokio-native-tls v0.3.1
│       ├── hyper-tls v0.6.0 (*)
│       └── reqwest v0.12.7 (*)
└── openssl v0.10.66
    ├── crate_networking v0.1.0 (/splitfire/lib/crate_networking)
    └── native-tls v0.2.12 (*)

I tried to vendor the openssl like so: openssl = { version = "0.10.66", features = ["vendored"] }

Still, error when running cargo ndk -o ./jniLibs build. Any clue? Is there a minimum supported version of the NDK?

Some of the errors:

 providers/implementations/rands/seeding/rand_unix.c:360:9: error: 'getentropy' is unavailable: introduced in Android 28
    360 |     if (getentropy != NULL) {
        |         ^
  /Library/Android/sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/bits/getentropy.h:51:11: note: 'getentropy' has been explicitly marked unavailable here
     51 | __wur int getentropy(void* _Nonnull __buffer, size_t __buffer_size) __INTRODUCED_IN(28);
        |           ^
  providers/implementations/rands/seeding/rand_unix.c:361:13: error: 'getentropy' is unavailable: introduced in Android 28
    361 |         if (getentropy(buf, buflen) == 0)
        |             ^
  /Library/Android/sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/bits/getentropy.h:51:11: note: 'getentropy' has been explicitly marked unavailable here
     51 | __wur int getentropy(void* _Nonnull __buffer, size_t __buffer_size) __INTRODUCED_IN(28);
        |           ^
  2 errors generated.
  make[1]: *** [providers/implementations/rands/seeding/libdefault-lib-rand_unix.o] Error 1
  make[1]: *** Waiting for unfinished jobs....
  make: *** [build_libs] Error 2
  thread 'main' panicked at /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-300.3.2+3.3.2/src/lib.rs:633:9:
bbqsrc commented 5 hours ago

Set the API level to 28?

bbqsrc commented 4 hours ago

https://github.com/bbqsrc/cargo-ndk/tree/main/example/openssl