openethereum / pwasm-tutorial

A step-by-step tutorial on how to write contracts in Wasm for Kovan
GNU General Public License v3.0
229 stars 34 forks source link

Step0 does not compile on 1.27 nightly #19

Closed Pzixel closed 6 years ago

Pzixel commented 6 years ago

I'm building tutorial with nightly-x86_64-pc-windows-gnu (cargo 1.27.0-nightly (9e53ac6e6 2018-05-07)).

However, it doesn't compile.

My output:

cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling winapi-x86_64-pc-windows-gnu v0.4.0
   Compiling winapi v0.3.4
   Compiling crunchy v0.1.6
   Compiling bigint v4.3.0
   Compiling memory_units v0.4.0
   Compiling byteorder v1.2.2
   Compiling cfg-if v0.1.3
   Compiling rustc-hex v1.0.0
   Compiling rlibc v1.0.0
   Compiling pwasm-libc v0.2.0
   Compiling tiny-keccak v1.4.1
   Compiling wee_alloc v0.2.0
error[E0053]: method `alloc` has an incompatible type for trait
    --> C:\Users\Alex\.cargo\registry\src\github.com-1ecc6299db9ec823\wee_alloc-0.2.0\src\lib.rs:1028:5
     |
1028 |     unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `core::ptr::NonNull`, found *-ptr
     |
     = note: expected type `unsafe fn(&mut &'a WeeAlloc, core::alloc::Layout) -> core::result::Result<core::ptr::NonNull<core::alloc::Opaque>, core::alloc::AllocErr>`
                found type `unsafe fn(&mut &'a WeeAlloc, core::alloc::Layout) -> core::result::Result<*mut u8, core::alloc::AllocErr>`

error[E0053]: method `dealloc` has an incompatible type for trait
    --> C:\Users\Alex\.cargo\registry\src\github.com-1ecc6299db9ec823\wee_alloc-0.2.0\src\lib.rs:1051:5
     |
1051 |     unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `core::ptr::NonNull`, found *-ptr
     |
     = note: expected type `unsafe fn(&mut &'a WeeAlloc, core::ptr::NonNull<core::alloc::Opaque>, core::alloc::Layout)`
                found type `unsafe fn(&mut &'a WeeAlloc, *mut u8, core::alloc::Layout)`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0053`.
error: Could not compile `wee_alloc`.
warning: build failed, waiting for other jobs to finish...
error: build failed
lexfrl commented 6 years ago

Thanks for the report, @Pzixel ! First of all we should make sure that cargo build (on Windows) obeys the rust-toolchain file where the concrete version of rustc is specified (https://github.com/paritytech/pwasm-tutorial/blob/master/step-0/rust-toolchain). Have you tired cargo build --release --target wasm32-unknown-unknown ?

Pzixel commented 6 years ago

I specifically removed rust-toolchain from the directory because I must obey company rules that makes me to use the latest compiler only, so I had to do it.

Yes, I tried this command as well, it doesn't work. It also doesn't work on my linux machine. I suspect that there is some breaking change in the compiler that the old dependency doesn't build: wee_alloc used by this create is 0.2.0 while its actual version is 0.4.0 and builds fine.

Pzixel commented 6 years ago

I've just checked, pwasm-std doesn't compile with persisted rust-toolchain file. I've just cloned the repo and ran cargo build and get this error.

With wee-alloc version setted to 0.4.0 it does compile, but it fails when building std:

$ cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling wee_alloc v0.4.0
   Compiling void v1.0.2
   Compiling parity-hash v1.1.0
   Compiling unreachable v1.0.0
   Compiling pwasm-alloc v0.3.0 (file:///C:/Users/Alex/Documents/Rust/pwasm-std/alloc)
   Compiling pwasm-std v0.6.0 (file:///C:/Users/Alex/Documents/Rust/pwasm-std)
error[E0557]: feature has been removed
 --> src\lib.rs:9:12
  |
9 | #![feature(macro_reexport)]
  |            ^^^^^^^^^^^^^^
  |
note: subsumed by `#![feature(use_extern_macros)]` and `pub use`
 --> src\lib.rs:9:12
  |
9 | #![feature(macro_reexport)]
  |            ^^^^^^^^^^^^^^

error[E0658]: The attribute `macro_reexport` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
  --> src\lib.rs:29:3
   |
29 |         #[macro_reexport(vec, format)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: add #![feature(custom_attribute)] to the crate attributes to enable

error: aborting due to 2 previous errors

Some errors occurred: E0557, E0658.
For more information about an error, try `rustc --explain E0557`.
error: Could not compile `pwasm-std`.
lexfrl commented 6 years ago

yeah, it's a known issue. It's not our top priority here, but it would be nice to migrate on the newest nightly and upgrade everything. We have to use rust-toolchain with the concrete version, to have guaranties we use the same compiler because it's nightly.

lexfrl commented 6 years ago

Btw, if you would like to help, it would be a good contribution to the project, @Pzixel

lexfrl commented 6 years ago

So now pwasm-std compiles with the nightly-2018-05-10. Good job, @Pzixel!

lexfrl commented 6 years ago

I'd like to close this issue as soon we update pwasm-std in the tutorial(s)

Pzixel commented 6 years ago

I'd like to close this issue as soon we update pwasm-std in the tutorial(s)

Looking forward to see it implemented. AFAIK we need to bump version here, then in pwasm-ethereum, and only then it would be possible to update the tutorial.

NikVolf commented 6 years ago

pwasm-std & pwasm-ethereum updated and published