6

I seem to be having trouble building a Solana program with CLI version 1.16 on macOS Ventura 13.4.1. It appears I have some kind of clang linker issue, but I have not been able to debug just yet.

This issue is new as of release 1.16.0 of platform-tools.

The following warnings were emitted during compilation:

warning: In file included from c/blake3_neon.c:1:
warning: c/blake3_impl.h:4:10: fatal error: 'assert.h' file not found
warning: #include <assert.h>
warning:          ^~~~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `blake3 v1.4.0`

Caused by:
  process didn't exit successfully: `/Users/joesol/Desktop/labs/keyring-program/target/release/build/blake3-39323e39efaeadbe/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
  cargo:rerun-if-env-changed=CARGO_FEATURE_NO_NEON
  cargo:rerun-if-env-changed=CARGO_FEATURE_NEON
  cargo:rerun-if-env-changed=CARGO_FEATURE_NO_NEON
  cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
  cargo:rustc-cfg=blake3_neon
  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/joesol/.local/share/solana/install/releases/1.16.1/solana-release/bin/sdk/sbf/dependencies/platform-tools/llvm/bin/clang")
  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:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  running: "/Users/joesol/.local/share/solana/install/releases/1.16.1/solana-release/bin/sdk/sbf/dependencies/platform-tools/llvm/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-Wall" "-Wextra" "-std=c11" "-o" "/Users/joesol/Desktop/labs/keyring-program/target/release/build/blake3-12de8fac38a452a2/out/c/blake3_neon.o" "-c" "c/blake3_neon.c"
  cargo:warning=In file included from c/blake3_neon.c:1:
  cargo:warning=c/blake3_impl.h:4:10: fatal error: 'assert.h' file not found
  cargo:warning=#include <assert.h>
  cargo:warning=         ^~~~~~~~~~
  cargo:warning=1 error generated.
  exit status: 1

  --- stderr


  error occurred: Command "/Users/joesol/.local/share/solana/install/releases/1.16.1/solana-release/bin/sdk/sbf/dependencies/platform-tools/llvm/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-Wall" "-Wextra" "-std=c11" "-o" "/Users/joesol/Desktop/labs/keyring-program/target/release/build/blake3-12de8fac38a452a2/out/c/blake3_neon.o" "-c" "c/blake3_neon.c" with args "clang" did not execute successfully (status code exit status: 1).

1 Answer 1

7

If you're on Mac and also running into this issue, you basically need to add a compiler flag for $HOME/.local/share/solana/install/releases/1.16.1/solana-release/bin/sdk/sbf/dependencies/platform-tools/llvm/bin/clang.

You can see from the debug output I posted above, the compiler is designed to look for many different C* options/flags. The one that fixed it for me isn't listed in the debug output, even if you use --verbose.

In my case, I solved this issue by:

  • Making sure I had Xcode installed - either through the CLI with xcode-select --install or the AppStore - setting `
  • Installing gcc-12 with brew install gcc@12
  • Setting CPATH to the right location for include files (detailed below)

I did some digging around my machine and found that the typical /usr/include directory was missing from my Mac, and /usr/local/include only had NodeJS items. However, I was able to find a ton of header files inside of /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include.

Viola!

export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"

Or, more permanently:

sudo echo 'export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"' >> ~/.zshrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.