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

TargetConditionals.h not found building on MacOS #1942

Closed
tmpfs opened this issue Feb 11, 2024 · 10 comments
Closed

TargetConditionals.h not found building on MacOS #1942

tmpfs opened this issue Feb 11, 2024 · 10 comments

Comments

@tmpfs
Copy link

tmpfs commented Feb 11, 2024

Hi,

I recently upgraded to XCode 15 and suddenly ring stops compiling for MacOS targets (both aarch64 and x86_64) here is the output:

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]: #include <TargetConditionals.h>
warning: [email protected]:          ^~~~~~~~~~~~~~~~~~~~~~
warning: [email protected]: 1 error generated.

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

Caused by:
  process didn't exit successfully: `/Users/muji/git/sos/gui/target/debug/build/ring-fb6cf29cc4ff5269/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_7_
  OPT_LEVEL = Some("0")
  TARGET = Some("aarch64-apple-darwin")
  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("/opt/homebrew/opt/llvm/bin/clang")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  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
  running: env -u IPHONEOS_DEPLOYMENT_TARGET "/opt/homebrew/opt/llvm/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=arm64-apple-darwin" "-I" "include" "-I" "/Users/muji/git/sos/gui/target/aarch64-apple-darwin/debug/build/ring-6a83fcdec0c56460/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/Users/muji/git/sos/gui/target/aarch64-apple-darwin/debug/build/ring-6a83fcdec0c56460/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c"
  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=#include <TargetConditionals.h>

  cargo:warning=         ^~~~~~~~~~~~~~~~~~~~~~

  cargo:warning=1 error generated.

  exit status: 1

  --- stderr


  error occurred: Command env -u IPHONEOS_DEPLOYMENT_TARGET "/opt/homebrew/opt/llvm/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=arm64-apple-darwin" "-I" "include" "-I" "/Users/muji/git/sos/gui/target/aarch64-apple-darwin/debug/build/ring-6a83fcdec0c56460/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/Users/muji/git/sos/gui/target/aarch64-apple-darwin/debug/build/ring-6a83fcdec0c56460/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args "clang" did not execute successfully (status code exit status: 1).

I was compiling against [email protected] and have tried updating to [email protected] and the problem still happens.

I have checked against 6762d65 and I get the same error with either of:

cargo check --all --target aarch64-apple-darwin
cargo check --all --target x86_64-apple-darwin

Any idea how I can resolve this please?

@tmpfs
Copy link
Author

tmpfs commented Feb 11, 2024

I think it's a problem with the Xcode installation, checking now.

@tmpfs
Copy link
Author

tmpfs commented Feb 11, 2024

I had forgotten to also update the command line tools but that didn't fix it.

The file exists here: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/TargetConditionals.h

So I will try to add that include path and see what happens.

@tmpfs
Copy link
Author

tmpfs commented Feb 11, 2024

This hack fixes the problem right now:

export C_INCLUDE_PATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/:$C_INCLUDE_PATH"

But I am curious what the proper fix would be.

@briansmith
Copy link
Owner

Based on reading rust-lang/cc-rs#902 it looks like the issue could be related to IPHONEOS_DEPLOYMENT_TARGET/MACOS_DEPLOYMENT_TARGET/etc and/or the version of cc-rs in use.

@briansmith
Copy link
Owner

@tmpfs It seems like cc-rs has had a lot of issues recently regarding Apple targets, and I think this is likely due to them. I think the later cc-rs versions have rectified things. Are things working for you now? If not, please reopen this.

@tmpfs
Copy link
Author

tmpfs commented May 20, 2024

Can confirm compilation working for me again on e943bfc, thank you @briansmith 🙏

@cyanic-selkie
Copy link

cyanic-selkie commented Oct 26, 2024

Hi, I'm on Sequoia 15.0.1 using Xcode 16.0. I am trying to cross build for android (any target) with cargo-ndk. When building for the MacOS target, it works fine.

I have another mac running Xcode 15.4 and it's working fine. I've also opened an issue on cargo-ndk, but honestly I have no idea with whom the issue actually lies.

The crucial part is that this happens only when ring is a build dependency, not when it's a regular dependency.

Here is the full error:

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: `/Users/sven/code/repetitio/app/core/target/debug/build/ring-3b476072a8e2d683/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(/Users/sven/code/repetitio/app/core/target/debug/build/ring-0e1701895b60269e/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/sven/Library/Android/sdk/ndk/27.0.12077973/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(true)
  cargo:rerun-if-env-changed=MACOSX_DEPLOYMENT_TARGET
  MACOSX_DEPLOYMENT_TARGET = None
  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/sven/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=arm64-apple-darwin" "-mmacosx-version-min=15.0" "-I" "include" "-I" "/Users/sven/code/repetitio/app/core/target/debug/build/ring-0e1701895b60269e/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" "/Users/sven/code/repetitio/app/core/target/debug/build/ring-0e1701895b60269e/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args clang did not execute successfully (status code exit status: 1).

@eareimu
Copy link

eareimu commented Nov 5, 2024

Same problem too

@dignifiedquire
Copy link

Just started getting this error, everything worked fine yesterday. Sorry for posting here, I don't think it is a ring issue, but it is the one that surfaces the issue.

stack

  • building on macos m1
  • using xcode 16.1

@dignifiedquire
Copy link

This is a cc regression: rust-lang/cc-rs#1278
For anyone running into this, force downgrade cc to 1.1.31 and you should be good

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

5 participants