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 · 6 comments
Closed

TargetConditionals.h not found building on MacOS #1942

tmpfs opened this issue Feb 11, 2024 · 6 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: ring@0.17.7: In file included from crypto/curve25519/curve25519.c:22:
warning: ring@0.17.7: In file included from include/ring-core/mem.h:60:
warning: ring@0.17.7: include/ring-core/base.h:71:10: fatal error: 'TargetConditionals.h' file not found
warning: ring@0.17.7: #include <TargetConditionals.h>
warning: ring@0.17.7:          ^~~~~~~~~~~~~~~~~~~~~~
warning: ring@0.17.7: 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 ring@0.17.5 and have tried updating to ring@0.17.7 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 🙏

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