paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

Latest node template fails to build #14335

Closed deepink-mas closed 1 year ago

deepink-mas commented 1 year ago

Is there an existing issue?

Experiencing problems? Have you tried our Stack Exchange first?

Description of bug

Compiling the current main tip (commit 87b1b4728e29f68c6b2bafde7f3d0f4c8af9b302) of the node template results in this error:

   Compiling node-template-runtime v4.0.0-dev (/home/werk/Code/substrate-node-template/runtime)
error: failed to run custom build command for `node-template-runtime v4.0.0-dev (/home/werk/Code/substrate-node-template/runtime)`

Caused by:
  process didn't exit successfully: `/home/werk/Code/substrate-node-template/target/debug/build/node-template-runtime-5ecf88b7b75beaf9/build-script-build` (exit status: 1)
  --- stderr
  Cannot compile the WASM runtime: no compatible Rust compiler found!
  Install at least Rust 1.68.0 or a recent nightly version.

Steps to reproduce

substrate-node-template> git checkout 87b1b4728e29f68c6b2bafde7f3d0f4c8af9b302 substrate-node-template> cargo c

deepink-mas commented 1 year ago

Some similar reports seem to be made here: https://github.com/paritytech/substrate/issues/12791

deepink-mas commented 1 year ago

In case this failure is related to https://github.com/paritytech/substrate/pull/13580:

deepink-mas commented 1 year ago

Version::extract("cargo 1.69.0-nightly").unwrap(); // panicked at 'called Option::unwrap() on a None value'

deepink-mas commented 1 year ago

Since the checking code accepts any nightly a workaround is to: export RUSTC_BOOTSTRAP=1

jasl commented 1 year ago

I got the same error, but the root cause may be different.

  The following warnings were emitted during compilation:

  warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  warning: 1 error generated.

  error: failed to run custom build command for `secp256k1-sys v0.6.1`

  Caused by:
    process didn't exit successfully: `/Users/jasl/Workspaces/BlockChain/cybros-network/target/release/wbuild/cybros-primal-runtime/target/release/build/secp256k1-sys-9d0d23adcf50967f/build-script-build` (exit status: 1)
    --- stdout
    TARGET = Some("wasm32-unknown-unknown")
    OPT_LEVEL = Some("3")
    HOST = Some("aarch64-apple-darwin")
    cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
    CC_wasm32-unknown-unknown = None
    cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
    CC_wasm32_unknown_unknown = None
    cargo:rerun-if-env-changed=TARGET_CC
    TARGET_CC = None
    cargo:rerun-if-env-changed=CC
    CC = None
    cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
    CFLAGS_wasm32-unknown-unknown = None
    cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
    CFLAGS_wasm32_unknown_unknown = None
    cargo:rerun-if-env-changed=TARGET_CFLAGS
    TARGET_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")
    cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
    CC_wasm32-unknown-unknown = None
    cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
    CC_wasm32_unknown_unknown = None
    cargo:rerun-if-env-changed=TARGET_CC
    TARGET_CC = None
    cargo:rerun-if-env-changed=CC
    CC = None
    cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
    CFLAGS_wasm32-unknown-unknown = None
    cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
    CFLAGS_wasm32_unknown_unknown = None
    cargo:rerun-if-env-changed=TARGET_CFLAGS
    TARGET_CFLAGS = None
    cargo:rerun-if-env-changed=CFLAGS
    CFLAGS = None
    cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
    CRATE_CC_NO_DEFAULTS = None
    running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm/wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_API=" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_GEN_PREC_BITS=4" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-o" "/Users/jasl/Workspaces/BlockChain/cybros-network/target/release/wbuild/cybros-primal-runtime/target/wasm32-unknown-unknown/release/build/secp256k1-sys-1854092b76a525fb/out/wasm/wasm.o" "-c" "wasm/wasm.c"
    cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
    cargo:warning=1 error generated.
    exit status: 1

    --- stderr

    error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm/wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_API=" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_GEN_PREC_BITS=4" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-o" "/Users/jasl/Workspaces/BlockChain/cybros-network/target/release/wbuild/cybros-primal-runtime/target/wasm32-unknown-unknown/release/build/secp256k1-sys-1854092b76a525fb/out/wasm/wasm.o" "-c" "wasm/wasm.c" with args "clang" did not execute successfully (status code exit status: 1).

  warning: build failed, waiting for other jobs to finish...
warning: build failed, waiting for other jobs to finish...

I know the error. It only occurs on macOS with Xcode bundled LLVM, and the WASM target has C binding crates. Changing to the Homebrew LLVM will solve the problem. It's just annoying.

The problem introduced to node-template from https://github.com/paritytech/substrate/pull/14452

bkchr commented 1 year ago

@jasl yes this is not related and is caused by the pr you linked.