Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM Runtime build fails with latest rust nightly #495

Closed
mnaamani opened this issue May 28, 2020 · 8 comments
Closed

WASM Runtime build fails with latest rust nightly #495

mnaamani opened this issue May 28, 2020 · 8 comments

Comments

@mnaamani
Copy link
Member

Discovered while working on #464:

srml-support runtime module breaks when built for wasm target, which is done by the nightly toolchain. The latest nightly toolchain as of this date was 2020-05-26

If you have recently updated your toolchain with rustup update nightly or perhaps just setup rust development system with rustup and got the latest nightly you will probably see below compiler error when building:

   Compiling srml-support v2.0.0 (https://github.com/paritytech/substrate.git?rev=c37bb08535c49a12320af7facfd555ce05cce2e8#c37bb085)

error[E0424]: expected value, found module `self`
   --> /home/travis/.cargo/git/checkouts/substrate-7e08433d4c370a21/c37bb08/srml/support/src/traits.rs:593:11
    |
591 | / bitmask! {
592 | |     /// Reasons for moving funds out of an account.
593 | |     #[derive(Encode, Decode)]
    | |              ^^^^^^ `self` value is a keyword only available in methods with a `self` parameter
594 | |     pub mask WithdrawReasons: i8 where
...   |
609 | |     }
610 | | }

    | |_- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
    |
    = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0424`.

error: could not compile `srml-support`.

You can check the version you have:

rustc +nightly --version

You should be able to install an older version of nightly with:

# on Linux
rustup install nightly-2020-05-23
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-23

and specify the toolchain when building joystream-node

WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release

You may have to install something older depending on what components are installed.
So if you see something like:

MokoBook:joystream mokhtar$ rustup toolchain install nightly-2020-05-23
info: syncing channel updates for 'nightly-2020-05-23-x86_64-apple-darwin'
449.3 KiB / 449.3 KiB (100 %) 432.1 KiB/s in  1s ETA:  0s
info: latest update on 2020-05-23, rust version 1.45.0-nightly (215f2d329 2020-05-22)
error: component 'rustfmt' for target 'x86_64-apple-darwin' is unavailable for download for channel nightly-2020-05-23
Sometimes not all components are available in any given nightly.

On OSX try nightly-2020-05-15

You can always see what version you have installed with:

rustup show

@mnaamani
Copy link
Member Author

This is also an issue in upstream substrate:

paritytech/substrate#6167
paritytech/polkadot#1163

Hopefully soon the wasm target will be possible to build with stable toolchain.. paritytech/substrate#1252

@mnaamani
Copy link
Member Author

Currently in our travis CI file we are forcing use of nightly-2020-05-23 on ubuntu.

@traumschule
Copy link
Contributor

Similar but not the same, note the path: frame/support/src/traits.rs:1172:11. Shall i create a new issue?

$ WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release
...
   Compiling sp-block-builder v2.0.0-rc4 (https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f)
error[E0424]: expected value, found module `self`
    --> ~/.cargo/git/checkouts/substrate-7e08433d4c370a21/00768a1/frame/support/src/traits.rs:1172:11
     |
1170 | / bitmask! {
1171 | |     /// Reasons for moving funds out of an account.
1172 | |     #[derive(Encode, Decode)]
     | |              ^^^^^^ `self` value is a keyword only available in methods with a `self` parameter
1173 | |     pub mask WithdrawReasons: i8 where
...    |
1188 | |     }
1189 | | }
     | |_- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
     |
     = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0424]: expected value, found module `self`
    --> ~/.cargo/git/checkouts/substrate-7e08433d4c370a21/00768a1/frame/support/src/traits.rs:1172:11
     |
1170 | / bitmask! {
1171 | |     /// Reasons for moving funds out of an account.
1172 | |     #[derive(Encode, Decode)]
     | |              ^^^^^^ `self` value is a keyword only available in methods with a `self` parameter
1173 | |     pub mask WithdrawReasons: i8 where
...    |
1188 | |     }
1189 | | }
     | |_- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
     |
     = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

   Compiling sc-executor v0.8.0-rc4 (https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f)
   Compiling sp-timestamp v2.0.0-rc4 (https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f)
   Compiling sp-session v2.0.0-rc4 (https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f)
error: aborting due to previous error

@bedeho bedeho reopened this Oct 27, 2020
@mnaamani
Copy link
Member Author

Thanks @traumschule I will try to replicate it and if I can confirm its happening for me also maybe we will open another issue.

@traumschule
Copy link
Contributor

I was able to build using nightly-2020-07-12 applying recommendations in paritytech/substrate#6167:

rustup toolchain install nightly-2020-07-12
rustup default nightly-2020-07-12-x86_64-unknown-linux-gnu
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-07-12
cargo update -p parity-scale-codec-derive
WASM_BUILD_TOOLCHAIN=nightly-2020-07-12 cargo build --release --verbose

@mnaamani
Copy link
Member Author

So I wasn't able to replicate the build error. I made sure to clear my ~/.cargo/git and ~/.cargo/registry as well as doing cargo clean to start fresh. I tested on Mac, will try on linux as you seem to be seeing this issue on linux?

@mnaamani
Copy link
Member Author

mnaamani commented Nov 6, 2020

Although I have not been able to replicate this on linux before I am also now seeing it on mac, and there has been more reports of this build issue. Here is the suggested workaround based on @traumschule recommendation above (just fixed one line to work for all platforms)

rustup toolchain install nightly-2020-07-12
rustup default nightly-2020-07-12
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-07-12
cargo update -p parity-scale-codec-derive
WASM_BUILD_TOOLCHAIN=nightly-2020-07-12 cargo build --release --verbose

I will prepare a PR to update master branch with these build steps.

@mnaamani
Copy link
Member Author

mnaamani commented Nov 7, 2020

Fixed in #1655

@mnaamani mnaamani closed this as completed Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants