I am not able to build Duniter v2s with Rust stable (v1.66.1) available on Fedora:
duniter-v2s> cargo build
[…]
Compiling wasmtime-cache v0.38.3
Compiling wasmtime v0.38.3
error: failed to run custom build command for `gdev-runtime v3.0.0 (/home/moul/projects/ML/duniter-v2s/runtime/gdev)`
Caused by:
process didn't exit successfully: `/home/moul/projects/ML/duniter-v2s/target/release/build/gdev-runtime-b664c5228b8de23e/build-script-build` (exit status: 1)
--- stderr
Rust nightly not installed, please install it!
warning: build failed, waiting for other jobs to finish...
I am reproducing same error while building the image with the provided Dockerfile:
Compiling gdev-runtime v3.0.0 (/root/runtime/gdev)
error: failed to run custom build command for `gdev-runtime v3.0.0 (/root/runtime/gdev)`
Caused by:
process didn't exit successfully: `/root/target/release/build/gdev-runtime-5f73f36b51d8970b/build-script-build` (exit status: 1)
--- stderr
Rust nightly not installed, please install it!
warning: build failed, waiting for other jobs to finish...
Error: building at STEP "RUN test -x build/duniter || ( CARGO_PROFILE_RELEASE_LTO="true" cargo build --release -j $threads && mkdir -p build && mv target/release/duniter build/ )": while running runtime: exit status 101
I do not find what should be changed to allow to build with Rust stable.
I changed in rust-toolchain file channel to stable, but it does not seem to change a thing.
Any idea what could be done?
You have to use the nightly. It should install automatically the right toolchain according to the rust-toolchain file.
And it’s better to install rustup via rustup.rs than via the distro’s package manager.
Edit: We use the same rust version as Parity to be sure it works correctly (because nightly sometimes has regressions). I think we still use nightly features that are not yet available in stable. (notably for wasm)
As an exercice I tried to disable the ‘nightly’ requirement. I forked the duniter/substrate repo, made the change, and pushed it into a new branch.
In my local duniter-v2s repo I updated the ‘Cargo.toml’ files accordingly.
But the build fails with:
error[E0554]: `#![feature]` may not be used on the stable release channel
--> /usr/local/cargo/git/checkouts/duniter-substrate-0ec28e693220dd60/4f30542/primitives/io/src/lib.rs:22:35
|
22 | #![cfg_attr(not(feature = "std"), feature(alloc_error_handler))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0554`.
error: could not compile `sp-io` due to previous error
The related source file has:
//! I/O host interface for substrate runtime.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc_error_handler))]
#![cfg_attr(
feature = "std",
doc = "Substrate runtime standard library as compiled when linked with Rust's standard library."
)]
#![cfg_attr(
not(feature = "std"),
doc = "Substrate's runtime standard library as compiled without Rust's standard library."
)]
I guess there is nothing related to a bleeding edge rust nightly release feature, but the chosen syntax is accepted by rust-nightly only.
Is there an alternative syntax that would be accepted by rust-stable? Just curious…
If we switch to stable, we’ll need to rewrite a lot of code, and do it again for each Substrate upgrade… Maybe it’s not even possible yet. I guess Substrate will switch to stable as soon as it contains all the needed features.
Edit: feature(foo) is not the same as cfg(feature="foo") or cfg_attr(feature="foo", [...]) which test a cargo feature defined in the Cargo.toml.
Edit 2: If you want to try further, maybe you can just remove this function.