substrate icon indicating copy to clipboard operation
substrate copied to clipboard

2.0.0-rc5+2 build fails: failed to run custom build command for `node-template-runtime v2.0.0-rc5`

Open yurivict opened this issue 6 years ago • 17 comments

   Compiling node-runtime v2.0.0-rc5 (/usr/ports/security/substrate/work/substrate-2.0.0-rc5-2/bin/node/runtime)
     Running `/usr/local/bin/rustc --crate-name protobuf /usr/ports/security/substrate/work/substrate-2.0.0-rc5-2/cargo-crates/protobuf-2.14.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -Cembed-bitcode=no -C metadata=f5106b5fb846c5a4 -C extra-filename=-f5106b5fb846c5a4 --out-dir /usr/ports/security/substrate/work/target/release/deps -L dependency=/usr/ports/security/substrate/work/target/release/deps --cap-lints allow -C linker=cc -C link-arg=-fstack-protector-strong`
   Compiling substrate-test-runtime v2.0.0-rc5 (/usr/ports/security/substrate/work/substrate-2.0.0-rc5-2/test-utils/runtime)
   Compiling node-template-runtime v2.0.0-rc5 (/usr/ports/security/substrate/work/substrate-2.0.0-rc5-2/bin/node-template/runtime)
   Compiling sp-runtime-interface-test-wasm-deprecated v2.0.0-rc5 (/usr/ports/security/substrate/work/substrate-2.0.0-rc5-2/primitives/runtime-interface/test-wasm-deprecated)
   Compiling sp-runtime-interface-test-wasm v2.0.0-rc5 (/usr/ports/security/substrate/work/substrate-2.0.0-rc5-2/primitives/runtime-interface/test-wasm)
   Compiling sc-runtime-test v2.0.0-rc5 (/usr/ports/security/substrate/work/substrate-2.0.0-rc5-2/client/executor/runtime-test) 
     Running `/usr/ports/security/substrate/work/target/release/build/node-runtime-77f2119c43069082/build-script-build`
     Running `/usr/ports/security/substrate/work/target/release/build/substrate-test-runtime-7157748da21c0058/build-script-build`
     Running `/usr/ports/security/substrate/work/target/release/build/node-template-runtime-4624f3c615303a4a/build-script-build`
     Running `/usr/ports/security/substrate/work/target/release/build/sp-runtime-interface-test-wasm-deprecated-a02e67abefbf96bf/build-script-build`
     Running `/usr/ports/security/substrate/work/target/release/build/sp-runtime-interface-test-wasm-8831cd14097e4af6/build-script-build`
     Running `/usr/ports/security/substrate/work/target/release/build/sc-runtime-test-773230e3de1e6f1e/build-script-build`
error: failed to run custom build command for `node-template-runtime v2.0.0-rc5 (/usr/ports/security/substrate/work/substrate-2.0.0-rc5-2/bin/node-template/runtime)`

Caused by:
  process didn't exit successfully: `/usr/ports/security/substrate/work/target/release/build/node-template-runtime-4624f3c615303a4a/build-script-build` (exit code: 1)
--- stderr
    Blocking waiting for file lock on package cache
error: no matching package named `substrate-wasm-builder` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
required by package `wasm-build-runner-impl v1.0.0 (/usr/ports/security/substrate/work/target/release/wbuild-runner/node-template-runtime17770859208085535118)`

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

OS: FreeBSD 12.1

yurivict avatar Aug 05 '20 23:08 yurivict

change the cargo.toml file to associate with the newest versions of what ever package version your trying to get. I think that could be the rc5 version of something like 'substrate-wasm-builder'

smurf123444 avatar Aug 16 '20 14:08 smurf123444

Can you show your code?

bkchr avatar Aug 17 '20 08:08 bkchr

Same problem on Arch and Ubuntu.

psic4t avatar Aug 17 '20 08:08 psic4t

@mdebus just the default node template?

bkchr avatar Aug 17 '20 10:08 bkchr

Maybe unrelated, but I had issues with this on FreeBSD (and have had for awhile!). No special code, just default node template or substrate. Maybe it is related to #7150, but currently it won't build on FreeBSD using default instructions, i.e. via rustup. I haven't gotten to test it with a clean system yet to reproduce, but the only way of producing a build was by installing rust-nightly via pkg and pointing rustup link to /usr/local.

I tried with rust from ports (1.46.0 stable) and pkg (1.44.1 stable); both of these build wasm target by default, indicated by supporting files in /usr/local/lib/rustlib; lld is only supplied by one. I tried using rustup stable and nightly, but lld (and thus rust-lld) aren't included in stable or nightly when installed via rustup (and subsequently can't compile wasm, errors below). I tried building /usr/ports/lang/rust/nightly but that failed during compilation of llvm.

I've tried some of the instructions in this rustup issue. I'm not sure cargo-bintools ought to be necessary though, since it isn't necessary on macOS. The first error (below) is when cargo-binutils isn't installed, and the second error is when cargo-binutils is installed. Installing cargo-bintools installs a rust-lld binary which wraps another rust-lld binary: rustlib() + self.exe(), which resolves to a file in ~/.rustup/toolchains/_toolchain_/lib/rustlib/x86_64_unknown_freebsd/bin/.

Error when tools aren't installed:

`rust-lld` not found, please install it!

However, it is installed:

$ cargo install cargo-binutils
$ rust-lld
lld is a generic driver.
Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld (WebAssembly) instead
substrate$ cargo build --release
error: failed to run custom build command for `sc-runtime-test v2.0.0 (/usr/home/test/src/substrate/client/executor/runtime-test)`

Caused by:
  process didn't exit successfully: `/usr/home/test/src/substrate/target/release/build/sc-runtime-test-0f7adec70feca13a/build-script-build` (exit code: 1)
--- stderr
   Compiling wasm-build-runner-impl v1.0.0 (/usr/home/test/src/substrate/target/release/wbuild-runner/sc-runtime-test10745382922566810087)
    Finished release [optimized] target(s) in 0.34s
     Running `/usr/home/test/src/substrate/target/release/wbuild-runner/sc-runtime-test10745382922566810087/target/x86_64-unknown-freebsd/release/wasm-build-runner-impl`
Rust WASM toolchain not installed, please install it!

Further error information:
------------------------------------------------------------
   Compiling wasm-test v1.0.0 (/tmp/.tmpkyETWV)
error: linking with `rust-lld` failed: exit code: 101
  |
  = note: "rust-lld" "-flavor" "wasm" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--fatal-warnings" "--no-demangle" "--export-dynamic" "--no-entry" "-L" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib" "-L" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/self-contained" "/tmp/.tmpkyETWV/target/wasm32-unknown-unknown/debug/deps/wasm_test.2xzxszcqzhwohx66.rcgu.o" "-o" "/tmp/.tmpkyETWV/target/wasm32-unknown-unknown/debug/deps/wasm_test.wasm" "--export=__heap_base" "--export=__data_end" "/tmp/.tmpkyETWV/target/wasm32-unknown-unknown/debug/deps/wasm_test.3z7l7jkwlcwefvtt.rcgu.o" "--gc-sections" "--no-entry" "-O0" "-L" "/tmp/.tmpkyETWV/target/wasm32-unknown-unknown/debug/deps" "-L" "/tmp/.tmpkyETWV/target/debug/deps" "-L" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/libstd-38314f0df48bc600.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/libpanic_abort-1e660b451f1274db.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/libdlmalloc-3a9c04af2c6391de.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/librustc_demangle-7f965d3ebaa128bd.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/libhashbrown-5f391b31873711e3.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_alloc-eaf93d56388a266f.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/libunwind-9bca350cb254c7bc.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/libcfg_if-9c56e9188757c03d.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/liblibc-c563bef2563f33ac.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/liballoc-673de98554cd4084.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_core-bfe89f587d3bf9f7.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/libcore-c83074681f2b006a.rlib" "/usr/home/test/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-77317ec807201c9c.rlib"
  = note: Failed to execute tool: lld
          No such file or directory (os error 2)
          

error: aborting due to previous error

error: could not compile `wasm-test`

When building with rust nightly, no cargo-binutils, RUST_BACKTRACE and --verbose:

error: failed to run custom build command for `sp-runtime-interface-test-wasm-deprecated v2.0.0 (/usr/home/test/src/substrate/primitives/runtime-interface/test-wasm-deprecated)`

Caused by:
  process didn't exit successfully: `/usr/home/test/src/substrate/target/release/build/sp-runtime-interface-test-wasm-deprecated-a31a5e16e4deddae/build-script-build` (exit code: 1)
  --- stderr
      Blocking waiting for file lock on package cache
      Blocking waiting for file lock on package cache
      Blocking waiting for file lock on package cache
      Blocking waiting for file lock on package cache
     Compiling wasm-build-runner-impl v1.0.0 (/usr/home/test/src/substrate/target/release/wbuild-runner/sp-runtime-interface-test-wasm-deprecated16373337584875009511)
      Finished release [optimized] target(s) in 0.49s
       Running `/usr/home/test/src/substrate/target/release/wbuild-runner/sp-runtime-interface-test-wasm-deprecated16373337584875009511/target/x86_64-unknown-freebsd/release/wasm-build-runner-impl`
  `rust-lld` not found, please install it!

subtly avatar Oct 03 '20 05:10 subtly

note: Failed to execute tool: lld

Did you see this? This is clearly some Rust issue. Did you tried to compile some library manually to wasm?

bkchr avatar Oct 04 '20 07:10 bkchr

@bkchr Compiling a separate project to wasm32 gives the same error (with rustup stable or nightly). I'm not sure where to report it upstream, as I'm not quite sure what's broken. It appears that compiling for the wasm32 target requires that the host toolchain have rustlib/...toolchain.../bin/lld. I think rust compiles its own lld for this, or, it could forego that and use the host lld, but, whatever is creating the rust-lld file doesn't actually support using host lld.

So I guess the 'please install it!' messages aren't always accurate, in that wasm support from rust isn't stable unless the rust toolchain was compiled with lld/rust-lld.

subtly avatar Oct 05 '20 07:10 subtly

hmm, did you install rustup component add llvm-tools-preview?

niklasad1 avatar Oct 05 '20 07:10 niklasad1

@niklasad1 yes, and get the same error, rust-lld not found

subtly avatar Oct 05 '20 13:10 subtly

Assuming that compiling from rust source should be supported, or having a locally installed rust ('link' toolchain), I think this is indeed an issue with wasm builder docs and/or config.

  • only nightly is supported
  • linked toolchains aren't supported
  • WASM_BUILD_TOOLCHAIN only works for '-nightly' builds, doesn't work for -dev or otherwise
  • error messages wrap error messages that conceal the actual error

I didn't realize that wasm builder was manually looking to run nightly even if stable is used to compile everything else. I always had nightly installed, so never saw the 'please install nightly'. Afaik from rust docs, -dev and -nightly builds are the same. WASM_BUILD_TOOLCHAIN, and the toolchain used, must always point to a toolchain where rustc version output ends in '-nightly'. This was a problem here because after compiling rust from source the version is -dev instead.

The builder creates a wrapper 'wasm-build-runner-impl' that calls build_project_with_default_rustflags which calls prerequisites::check() which then checks crate::get_nightly_cargo().is_nightly(). This will return false unless the rustc version is -nightly.

Should WASM_BUILD_TOOLCHAIN support non-nightly builds? Can -dev be supported the same as -nightly?

subtly avatar Oct 06 '20 06:10 subtly

We are using nightly features, if -dev is also having support for nightly features you can create a pr to support it. (I assume that the -dev also has nightly features enabled, but I'm not 100% sure)

bkchr avatar Oct 06 '20 07:10 bkchr

It would also be useful if WASM_BUILD_TOOLCHAIN wasn't constrained to nightly.

For this issue, wasmtime fails to compile on FreeBSD (12.1) so I opened issue 2269.

Documentation in config.toml.example for building from source says that -dev and -nightly are the same:

# The "channel" for the Rust build to produce. The stable/beta channels only
# allow using stable features, whereas the nightly and dev channels allow using
# nightly features

subtly avatar Oct 06 '20 08:10 subtly

Perfect, yeah than please open a pr.

bkchr avatar Oct 06 '20 08:10 bkchr

I will check FreeBSD again, but afraid its still broken, but due to a different issue (as discussed; I've been trying to get polkadot running on Alpine Linux and FreeBSD).

What is the appropriate process here; can the title of this be changed to a request for stable support for FreeBSD, or, close this and open a new issue to support for FreeBSD?

On FreeBSD and Alpine Linux: I think BSD is a great OS to test with. First, it supports QEMU as host or guest, and second it is lightweight and supports from-scratch builds similar to gentoo. The authors of these operating systems seem to have some similar sentiments as Rust, in that there is support (and often preference) for static binaries. Personally, I tried to get this working but pthread stuff isn't documented well and recent rust nightly have had related changes (as well as w/llvm).

Tangently, Alpine Linux doesn't work, as it has musl, and librocksdb isn't compiling statically. However I think it might alos have issues w/pthread/tracing for wasmtime, resulting in a similar issue as FreeBSD.

subtly avatar Oct 31 '20 05:10 subtly

@subtly would be nice if you open a new issue with our current findings :)

bkchr avatar Nov 01 '20 12:11 bkchr

How can I get notified when this is fixed on FreeBSD?

I would like to create a FreeBSD port for substrate.

yurivict avatar Nov 01 '20 17:11 yurivict

Maybe the best is to team up with @subtly

bkchr avatar Nov 01 '20 19:11 bkchr