Error: failed to run cargo-build-bpf for `ring v0.17.8`

Hi, guys. I've been trying to compile a program using cargo-build-bpf for hours and I get this error. I still don't know what could be wrong with this crate. My CPU is x86_64

The following warnings were emitted during compilation:

warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:22:
warning: ring@0.17.8: In file included from include/ring-core/mem.h:60:
warning: ring@0.17.8: In file included from include/ring-core/base.h:74:
warning: ring@0.17.8: include/ring-core/target.h:64:2: error: "Unknown target CPU"
warning: ring@0.17.8:    64 | #error "Unknown target CPU"
warning: ring@0.17.8:       |  ^
warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:22:
warning: ring@0.17.8: In file included from include/ring-core/mem.h:60:
warning: ring@0.17.8: include/ring-core/base.h:100:23: error: static assertion failed due to requirement 'sizeof(unsigned long) == sizeof(unsigned int)': uintptr_t and size_t differ.
warning: ring@0.17.8:   100 | OPENSSL_STATIC_ASSERT(sizeof(size_t) == sizeof(uintptr_t), "uintptr_t and size_t differ.");
warning: ring@0.17.8:       |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: ring@0.17.8: include/ring-core/type_check.h:71:57: note: expanded from macro 'OPENSSL_STATIC_ASSERT'
warning: ring@0.17.8:    71 | #define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
warning: ring@0.17.8:       |                                                         ^~~~
warning: ring@0.17.8: include/ring-core/base.h:100:38: note: expression evaluates to '8 == 4'
warning: ring@0.17.8:   100 | OPENSSL_STATIC_ASSERT(sizeof(size_t) == sizeof(uintptr_t), "uintptr_t and size_t differ.");
warning: ring@0.17.8:       |                       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
warning: ring@0.17.8: include/ring-core/type_check.h:71:57: note: expanded from macro 'OPENSSL_STATIC_ASSERT'
warning: ring@0.17.8:    71 | #define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
warning: ring@0.17.8:       |                                                         ^~~~
warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:24:
warning: ring@0.17.8: In file included from crypto/curve25519/internal.h:20:
warning: ring@0.17.8: crypto/curve25519/../internal.h:171:19: warning: cast to smaller integer type 'uintptr_t' (aka 'unsigned int') from 'const void *' [-Wvoid-pointer-to-int-cast]
warning: ring@0.17.8:   171 |   uintptr_t a_u = (uintptr_t)a;
warning: ring@0.17.8:       |                   ^~~~~~~~~~~~
warning: ring@0.17.8: crypto/curve25519/../internal.h:172:19: warning: cast to smaller integer type 'uintptr_t' (aka 'unsigned int') from 'const void *' [-Wvoid-pointer-to-int-cast]
warning: ring@0.17.8:   172 |   uintptr_t b_u = (uintptr_t)b;
warning: ring@0.17.8:       |                   ^~~~~~~~~~~~
warning: ring@0.17.8: 2 warnings and 2 errors generated.

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

Caused by:
  process didn't exit successfully: `/home/gabriel/sempiterno/solana-yellowstone-blocklist/target/release/build/ring-292e5575c420d1a7/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(3)
  TARGET = Some(sbf-solana-solana)
  OUT_DIR = Some(/home/gabriel/sempiterno/solana-yellowstone-blocklist/target/sbf-solana-solana/release/build/ring-3344e4c8c7d193c1/out)
  HOST = Some(x86_64-unknown-linux-gnu)
  cargo:rerun-if-env-changed=CC_sbf-solana-solana
  CC_sbf-solana-solana = None
  cargo:rerun-if-env-changed=CC_sbf_solana_solana
  CC_sbf_solana_solana = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = Some(/home/gabriel/.local/share/solana/install/releases/1.18.18/solana-release/bin/sdk/sbf/dependencies/platform-tools/llvm/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=CFLAGS_sbf-solana-solana
  CFLAGS_sbf-solana-solana = None
  cargo:rerun-if-env-changed=CFLAGS_sbf_solana_solana
  CFLAGS_sbf_solana_solana = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = Some(-DOPENSSL_64_BIT)
  cargo:rerun-if-env-changed=CC_SHELL_ESCAPED_FLAGS
  CC_SHELL_ESCAPED_FLAGS = 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=In file included from include/ring-core/base.h:74:
  cargo:warning=include/ring-core/target.h:64:2: error: "Unknown target CPU"
  cargo:warning=   64 | #error "Unknown target CPU"
  cargo:warning=      |  ^
  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:100:23: error: static assertion failed due to requirement 'sizeof(unsigned long) == sizeof(unsigned int)': uintptr_t and size_t differ.
  cargo:warning=  100 | OPENSSL_STATIC_ASSERT(sizeof(size_t) == sizeof(uintptr_t), "uintptr_t and size_t differ.");
  cargo:warning=      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=include/ring-core/type_check.h:71:57: note: expanded from macro 'OPENSSL_STATIC_ASSERT'
  cargo:warning=   71 | #define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
  cargo:warning=      |                                                         ^~~~
  cargo:warning=include/ring-core/base.h:100:38: note: expression evaluates to '8 == 4'
  cargo:warning=  100 | OPENSSL_STATIC_ASSERT(sizeof(size_t) == sizeof(uintptr_t), "uintptr_t and size_t differ.");
  cargo:warning=      |                       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
  cargo:warning=include/ring-core/type_check.h:71:57: note: expanded from macro 'OPENSSL_STATIC_ASSERT'
  cargo:warning=   71 | #define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
  cargo:warning=      |                                                         ^~~~
  cargo:warning=In file included from crypto/curve25519/curve25519.c:24:
  cargo:warning=In file included from crypto/curve25519/internal.h:20:
  cargo:warning=crypto/curve25519/../internal.h:171:19: warning: cast to smaller integer type 'uintptr_t' (aka 'unsigned int') from 'const void *' [-Wvoid-pointer-to-int-cast]
  cargo:warning=  171 |   uintptr_t a_u = (uintptr_t)a;
  cargo:warning=      |                   ^~~~~~~~~~~~
  cargo:warning=crypto/curve25519/../internal.h:172:19: warning: cast to smaller integer type 'uintptr_t' (aka 'unsigned int') from 'const void *' [-Wvoid-pointer-to-int-cast]
  cargo:warning=  172 |   uintptr_t b_u = (uintptr_t)b;
  cargo:warning=      |                   ^~~~~~~~~~~~
  cargo:warning=2 warnings and 2 errors generated.

  --- stderr


  error occurred: Command "/home/gabriel/.local/share/solana/install/releases/1.18.18/solana-release/bin/sdk/sbf/dependencies/platform-tools/llvm/bin/clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=sbf-solana-solana" "-I" "include" "-I" "/home/gabriel/sempiterno/solana-yellowstone-blocklist/target/sbf-solana-solana/release/build/ring-3344e4c8c7d193c1/out" "-DOPENSSL_64_BIT" "-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" "-g3" "-DNDEBUG" "-o" "/home/gabriel/sempiterno/solana-yellowstone-blocklist/target/sbf-solana-solana/release/build/ring-3344e4c8c7d193c1/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args clang did not execute successfully (status code exit status: 1).

I suspect ring being one of the crates that fall under the restrictions of the solana bpf target. There might be other crates providing the cryptographic algorithms you need and work on the target though.

The problem here is that I don't use ring directly, I think the crate solana-config-program uses it under the hood. I removed the crate and it compiled, but there're some functions that I'd like to implement in my smart contract.

This is my cargo.toml

[features]

no-entrypoint = []

[dependencies]

solana-program = "2.0.9"

borsh = "1.5.1"

thiserror = "1.0.63"

serde = { version = "1.0.145" }

getrandom = { version = "0.1.14", features = ["dummy"] }

solana-config-program = "2.0.9"

[lib]

crate-type = ["cdylib", "lib"]

I'm pretty sure solana-config-program (which depends on solana-sdk) is meant for off-chain stuff and not for your on-chain program you compile for BPF:

This is the base library for all off-chain programs that interact with Solana or otherwise operate on Solana data structures. On-chain programs instead use the solana-program crate...

1 Like

Got it, thank u

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.