Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to build ring and SQLite due to missing headers #150

Closed
cyanic-selkie opened this issue Oct 19, 2024 · 6 comments
Closed

Failed to build ring and SQLite due to missing headers #150

cyanic-selkie opened this issue Oct 19, 2024 · 6 comments

Comments

@cyanic-selkie
Copy link

cyanic-selkie commented Oct 19, 2024

Hi, I'm trying to build my project, but I'm getting errors about missing TargetConditionals.h and stdio.h.

Here is the command I'm using:

cargo ndk -t arm64-v8a -p 28 -o ./sdk/src/main/jniLibs build --release -p core

I'm using XCode 16 and MacOS 14.6.1.

The following warnings were emitted during compilation:

warning: [email protected]: In file included from crypto/curve25519/curve25519.c:22:
warning: [email protected]: In file included from include/ring-core/mem.h:60:
warning: [email protected]: include/ring-core/base.h:71:10: fatal error: 'TargetConditionals.h' file not found
warning: [email protected]:    71 | #include <TargetConditionals.h>
warning: [email protected]:       |          ^~~~~~~~~~~~~~~~~~~~~~
warning: [email protected]: 1 error generated.

error: failed to run custom build command for `ring v0.17.8`

Caused by:
  process didn't exit successfully: `path/to/lib/core/target/release/build/ring-931795b8a6798899/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_8_
  OPT_LEVEL = Some(0)
  TARGET = Some(aarch64-apple-darwin)
  OUT_DIR = Some(path/to/lib/core/target/release/build/ring-93f974981ae1b2f1/out)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CC_aarch64-apple-darwin
  CC_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CC_aarch64_apple_darwin
  CC_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = Some(/Users/user/Library/Android/sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang)
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  cargo:rerun-if-env-changed=MACOSX_DEPLOYMENT_TARGET
  MACOSX_DEPLOYMENT_TARGET = Some(14.0)
  cargo:rerun-if-env-changed=CFLAGS_aarch64-apple-darwin
  CFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_apple_darwin
  CFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=In file included from crypto/curve25519/curve25519.c:22:
  cargo:warning=In file included from include/ring-core/mem.h:60:
  cargo:warning=include/ring-core/base.h:71:10: fatal error: 'TargetConditionals.h' file not found
  cargo:warning=   71 | #include <TargetConditionals.h>
  cargo:warning=      |          ^~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=1 error generated.

  --- stderr


  error occurred: Command env -u IPHONEOS_DEPLOYMENT_TARGET "/Users/user/Library/Android/sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-mmacosx-version-min=14.0" "-I" "include" "-I" "path/to/lib/core/target/release/build/ring-93f974981ae1b2f1/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-Wall" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-gfull" "-DNDEBUG" "-o" "path/to/lib/core/target/release/build/ring-93f974981ae1b2f1/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args clang did not execute successfully (status code exit status: 1).


warning: build failed, waiting for other jobs to finish...
The following warnings were emitted during compilation:

warning: [email protected]: sqlite3/sqlite3.c:14678:10: fatal error: 'stdio.h' file not found
warning: [email protected]:  14678 | #include <stdio.h>
warning: [email protected]:        |          ^~~~~~~~~
warning: [email protected]: 1 error generated.

error: failed to run custom build command for `libsqlite3-sys v0.30.1`

Caused by:
  process didn't exit successfully: `path/to/lib/core/target/release/build/libsqlite3-sys-743144836199667c/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=LIBSQLITE3_SYS_USE_PKG_CONFIG
  cargo:include=/Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsqlite3-sys-0.30.1/sqlite3
  cargo:rerun-if-changed=sqlite3/sqlite3.c
  cargo:rerun-if-changed=sqlite3/wasm32-wasi-vfs.c
  cargo:rerun-if-env-changed=SQLITE_MAX_VARIABLE_NUMBER
  cargo:rerun-if-env-changed=SQLITE_MAX_EXPR_DEPTH
  cargo:rerun-if-env-changed=SQLITE_MAX_COLUMN
  cargo:rerun-if-env-changed=LIBSQLITE3_FLAGS
  OUT_DIR = Some(path/to/lib/core/target/release/build/libsqlite3-sys-bb648973692c4028/out)
  TARGET = Some(aarch64-apple-darwin)
  OPT_LEVEL = Some(0)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CC_aarch64-apple-darwin
  CC_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CC_aarch64_apple_darwin
  CC_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = Some(/Users/user/Library/Android/sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang)
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  cargo:rerun-if-env-changed=MACOSX_DEPLOYMENT_TARGET
  MACOSX_DEPLOYMENT_TARGET = Some(14.0)
  cargo:rerun-if-env-changed=CFLAGS_aarch64-apple-darwin
  CFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_apple_darwin
  CFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=sqlite3/sqlite3.c:14678:10: fatal error: 'stdio.h' file not found
  cargo:warning= 14678 | #include <stdio.h>
  cargo:warning=       |          ^~~~~~~~~
  cargo:warning=1 error generated.

  --- stderr


  error occurred: Command env -u IPHONEOS_DEPLOYMENT_TARGET "/Users/user/Library/Android/sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-mmacosx-version-min=14.0" "-DSQLITE_CORE" "-DSQLITE_DEFAULT_FOREIGN_KEYS=1" "-DSQLITE_ENABLE_API_ARMOR" "-DSQLITE_ENABLE_COLUMN_METADATA" "-DSQLITE_ENABLE_DBSTAT_VTAB" "-DSQLITE_ENABLE_FTS3" "-DSQLITE_ENABLE_FTS3_PARENTHESIS" "-DSQLITE_ENABLE_FTS5" "-DSQLITE_ENABLE_JSON1" "-DSQLITE_ENABLE_LOAD_EXTENSION=1" "-DSQLITE_ENABLE_MEMORY_MANAGEMENT" "-DSQLITE_ENABLE_RTREE" "-DSQLITE_ENABLE_STAT4" "-DSQLITE_SOUNDEX" "-DSQLITE_THREADSAFE=1" "-DSQLITE_USE_URI" "-DHAVE_USLEEP=1" "-DHAVE_ISNAN" "-D_POSIX_THREAD_SAFE_FUNCTIONS" "-DHAVE_LOCALTIME_R" "-DSQLITE_ENABLE_UNLOCK_NOTIFY" "-o" "path/to/lib/core/target/release/build/libsqlite3-sys-bb648973692c4028/out/0343851c9008f270-sqlite3.o" "-c" "sqlite3/sqlite3.c" with args clang did not execute successfully (status code exit status: 1).


note: If the build failed due to a missing target, you can run this command:
note:
note:     rustup target install aarch64-linux-android
@bbqsrc
Copy link
Owner

bbqsrc commented Oct 25, 2024

Are you building this inside of Xcode? I'm curious why it would be trying to pull iOS headers in.

@cyanic-selkie
Copy link
Author

cyanic-selkie commented Oct 26, 2024

By inside, do you mean inside the IDE? No. This is just straight up on the command line. I also tried downgrading XCode to 15.3, but it didn't help.

I mean, what stands out to me is TARGET = Some(aarch64-apple-darwin), isn't this wrong since I am building for the arm64 android target?

P.S. I have access to another macbook without XCode 16 installed and it works fine. Again, I have no idea if that matters at all. I would imagine not since downgrading doesn't help.

@cyanic-selkie
Copy link
Author

cyanic-selkie commented Oct 26, 2024

I just realized the ring dependency comes from a build dependency, which is presumably why it's building against the aarch64-apple-darwin target.

The libsqlite3 is from a regular dependency however, and still has the wrong target.

@bbqsrc
Copy link
Owner

bbqsrc commented Nov 7, 2024

Going to assume this is an upstream issue for now.

@bbqsrc bbqsrc closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2024
@cyanic-selkie
Copy link
Author

You're right, turns out this is a cc regression rust-lang/cc-rs#1278.

@bbqsrc
Copy link
Owner

bbqsrc commented Nov 7, 2024

Excellent to know, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants