wasmerio / wasmer-ruby

💎🕸 WebAssembly runtime for Ruby
https://wasmer.io
MIT License
465 stars 18 forks source link

gem install fails with Rust 1.46.0 #43

Closed turboladen closed 3 years ago

turboladen commented 3 years ago

Thanks for the bug report!

Describe the bug

I'm trying to install wasmer with Ruby 2.6.3 and Rust 1.46.0, but install fails with a bunch of errors like error:externfn uses typeinstance::RubyInstance, which is not FFI-safe (rutie issue #128. I have a number of other rutie projects and those are fine (I started getting the same issue when Rust 1.46 came out).

Steps to reproduce

  1. gem install wasmer
  2. See error

Expected behavior

Successful install.

Actual behavior

current directory: /Users/sloveless/.gem/ruby/2.6.3/gems/wasmer-0.4.0
/Users/sloveless/.rubies/ruby-2.6.3/bin/ruby -I/Users/sloveless/.rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems -rrubygems /Users/sloveless/.gem/ruby/2.6.3/gems/rake-13.0.1/exe/rake RUBYARCHDIR\=/Users/sloveless/.gem/ruby/2.6.3/extensions/x86_64-darwin-19/2.6.0/wasmer-0.4.0 RUBYLIBDIR\=/Users/sloveless/.gem/ruby/2.6.3/extensions/x86_64-darwin-19/2.6.0/wasmer-0.4.0
fatal: not a git repository (or any of the parent directories): .git
bundle install
fatal: not a git repository (or any of the parent directories): .git
Fetching gem metadata from https://rubygems.org/...
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 13.0.1
Using builder 3.2.4
Using bundler 2.1.4
Using minitest 5.14.2
Using ruby-progressbar 1.10.1
Using rutie 0.0.4
Fetching ansi 1.5.0
Using wasmer 0.4.0 from source at `.`
ctags: Warning: -f option specified more than once, last value used
ctags: Warning: cannot open source file "../extensions/x86_64-darwin-19/2.6.0/wasmer-0.4.0" : No such file or directory
Installing ansi 1.5.0
ctags: Warning: -f option specified more than once, last value used
Fetching minitest-reporters 1.4.2
Installing minitest-reporters 1.4.2
ctags: Warning: -f option specified more than once, last value used
Fetching color_pound_spec_reporter 0.0.9
Installing color_pound_spec_reporter 0.0.9
ctags: Warning: -f option specified more than once, last value used
Bundle complete! 6 Gemfile dependencies, 10 gems now installed.
Gems in the group production were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
cargo build --release
 Downloading crates ...
  Downloaded cranelift-codegen-shared v0.52.0
  Downloaded wasmer-clif-fork-frontend v0.52.0
  Downloaded wasmparser v0.45.2
  Downloaded cranelift-codegen v0.52.0
  Downloaded wasmer-runtime-core v0.14.1
  Downloaded wasmer-clif-backend v0.14.1
  Downloaded serde-bench v0.0.7
  Downloaded page_size v0.4.2
  Downloaded wasmer-runtime v0.14.1
  Downloaded cranelift-codegen-meta v0.52.0
  Downloaded cranelift-entity v0.52.0
  Downloaded cranelift-native v0.52.0
  Downloaded cranelift-bforest v0.52.0
  Downloaded blake3 v0.1.5
  Downloaded wasmer-clif-fork-wasm v0.52.0
   Compiling semver-parser v0.7.0
   Compiling cfg-if v0.1.10
   Compiling typenum v1.11.2
   Compiling autocfg v1.0.0
   Compiling libc v0.2.67
   Compiling cc v1.0.50
   Compiling proc-macro2 v1.0.9
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.16
   Compiling byteorder v1.3.4
   Compiling lazy_static v1.4.0
   Compiling maybe-uninit v2.0.0
   Compiling smallvec v1.2.0
   Compiling serde v1.0.104
   Compiling cranelift-codegen-shared v0.52.0
   Compiling cranelift-entity v0.52.0
   Compiling scopeguard v1.1.0
   Compiling target-lexicon v0.9.0
   Compiling log v0.4.8
   Compiling bitflags v1.2.1
   Compiling subtle v1.0.0
   Compiling constant_time_eq v0.1.5
   Compiling arrayref v0.3.6
   Compiling arrayvec v0.5.1
   Compiling nix v0.15.0
   Compiling rayon-core v1.7.0
   Compiling wasmparser v0.45.2
   Compiling void v1.0.2
   Compiling either v1.5.3
   Compiling hex v0.4.2
   Compiling rutie v0.7.0
   Compiling semver v0.9.0
   Compiling crossbeam-utils v0.7.2
   Compiling crossbeam-epoch v0.8.2
   Compiling indexmap v1.3.2
   Compiling lock_api v0.3.3
   Compiling cranelift-codegen-meta v0.52.0
   Compiling cranelift-bforest v0.52.0
   Compiling rustc_version v0.2.3
   Compiling blake3 v0.1.5
   Compiling memoffset v0.5.3
   Compiling raw-cpuid v7.0.3
   Compiling quote v1.0.2
   Compiling smallvec v0.6.13
   Compiling generic-array v0.12.3
   Compiling num_cpus v1.12.0
   Compiling parking_lot_core v0.7.0
   Compiling errno v0.2.4
   Compiling page_size v0.4.2
   Compiling memmap v0.7.0
   Compiling crossbeam-queue v0.2.1
   Compiling digest v0.8.1
   Compiling crypto-mac v0.7.0
   Compiling parking_lot v0.10.0
   Compiling crossbeam-deque v0.7.3
   Compiling wasmer-runtime-core v0.14.1
   Compiling rayon v1.3.0
   Compiling thiserror-impl v1.0.11
   Compiling serde_derive v1.0.104
   Compiling bincode v1.2.1
   Compiling serde-bench v0.0.7
   Compiling serde_bytes v0.11.3
   Compiling thiserror v1.0.11
   Compiling cranelift-codegen v0.52.0
   Compiling wasmer-clif-fork-frontend v0.52.0
   Compiling cranelift-native v0.52.0
   Compiling wasmer-clif-fork-wasm v0.52.0
   Compiling wasmer-clif-backend v0.14.1
   Compiling wasmer-runtime v0.14.1
   Compiling ruby-ext-wasm v0.4.0 (/Users/sloveless/.gem/ruby/2.6.3/gems/wasmer-0.4.0)
error: `extern` fn uses type `instance::RubyInstance`, which is not FFI-safe
  --> src/instance/mod.rs:51:5
   |
51 |     RubyInstance,
   |     ^^^^^^^^^^^^ not FFI-safe
   |
note: the lint level is defined here
  --> src/lib.rs:1:9
   |
1  | #![deny(warnings)]
   |         ^^^^^^^^
   = note: `#[deny(improper_ctypes_definitions)]` implied by `#[deny(warnings)]`
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
note: the type is defined here
  --> src/instance/mod.rs:47:1
   |
47 | class!(RubyInstance);
   | ^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `instance::RubyInstance`, which is not FFI-safe
  --> src/instance/mod.rs:51:5
   |
51 |     RubyInstance,
   |     ^^^^^^^^^^^^ not FFI-safe
   |
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
note: the type is defined here
  --> src/instance/mod.rs:47:1
   |
47 | class!(RubyInstance);
   | ^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `instance::exports::RubyExportedFunctions`, which is not FFI-safe
   --> src/instance/exports.rs:178:5
    |
178 |     RubyExportedFunctions,
    |     ^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/instance/exports.rs:174:1
    |
174 | class!(RubyExportedFunctions);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `instance::exports::RubyExportedFunctions`, which is not FFI-safe
   --> src/instance/exports.rs:196:13
    |
196 |     itself: RubyExportedFunctions,
    |             ^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/instance/exports.rs:174:1
    |
174 | class!(RubyExportedFunctions);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `rutie::AnyObject`, which is not FFI-safe
   --> src/instance/exports.rs:197:6
    |
197 | ) -> AnyObject {
    |      ^^^^^^^^^ not FFI-safe
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout

error: `extern` fn uses type `instance::globals::RubyExportedGlobals`, which is not FFI-safe
  --> src/instance/globals.rs:77:5
   |
77 |     RubyExportedGlobals,
   |     ^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
note: the type is defined here
  --> src/instance/globals.rs:73:1
   |
73 | class!(RubyExportedGlobals);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `instance::globals::RubyExportedGlobals`, which is not FFI-safe
  --> src/instance/globals.rs:95:13
   |
95 |     itself: RubyExportedGlobals,
   |             ^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
note: the type is defined here
  --> src/instance/globals.rs:73:1
   |
73 | class!(RubyExportedGlobals);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `instance::globals::RubyExportedGlobal`, which is not FFI-safe
   --> src/instance/globals.rs:96:6
    |
96  | ) -> RubyExportedGlobal {
    |      ^^^^^^^^^^^^^^^^^^ not FFI-safe
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/instance/globals.rs:155:1
    |
155 | class!(RubyExportedGlobal);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `instance::globals::RubyExportedGlobal`, which is not FFI-safe
   --> src/instance/globals.rs:159:5
    |
159 |     RubyExportedGlobal,
    |     ^^^^^^^^^^^^^^^^^^ not FFI-safe
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/instance/globals.rs:155:1
    |
155 | class!(RubyExportedGlobal);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `memory::RubyMemory`, which is not FFI-safe
  --> src/memory/mod.rs:77:5
   |
77 |     RubyMemory,
   |     ^^^^^^^^^^ not FFI-safe
   |
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
note: the type is defined here
  --> src/memory/mod.rs:73:1
   |
73 | class!(RubyMemory);
   | ^^^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `module::Module`, which is not FFI-safe
 --> src/module.rs:7:5
  |
7 |     Module,
  |     ^^^^^^ not FFI-safe
  |
  = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
  = note: this struct has unspecified layout
note: the type is defined here
 --> src/module.rs:4:1
  |
4 | class!(Module);
  | ^^^^^^^^^^^^^^^
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `memory::view::uint8array::RubyMemoryView`, which is not FFI-safe
   --> src/memory/view.rs:90:17
    |
90  |                 RubyMemoryView,
    |                 ^^^^^^^^^^^^^^ not FFI-safe
...
140 | memory_view!(uint8array over u8|1);
    | ----------------------------------- in this macro invocation
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/memory/view.rs:140:1
    |
140 | memory_view!(uint8array over u8|1);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `memory::view::int8array::RubyMemoryView`, which is not FFI-safe
   --> src/memory/view.rs:90:17
    |
90  |                 RubyMemoryView,
    |                 ^^^^^^^^^^^^^^ not FFI-safe
...
141 | memory_view!(int8array over i8|1);
    | ---------------------------------- in this macro invocation
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/memory/view.rs:141:1
    |
141 | memory_view!(int8array over i8|1);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `memory::view::uint16array::RubyMemoryView`, which is not FFI-safe
   --> src/memory/view.rs:90:17
    |
90  |                 RubyMemoryView,
    |                 ^^^^^^^^^^^^^^ not FFI-safe
...
142 | memory_view!(uint16array over u16|2);
    | ------------------------------------- in this macro invocation
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/memory/view.rs:142:1
    |
142 | memory_view!(uint16array over u16|2);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `memory::view::int16array::RubyMemoryView`, which is not FFI-safe
   --> src/memory/view.rs:90:17
    |
90  |                 RubyMemoryView,
    |                 ^^^^^^^^^^^^^^ not FFI-safe
...
143 | memory_view!(int16array over i16|2);
    | ------------------------------------ in this macro invocation
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/memory/view.rs:143:1
    |
143 | memory_view!(int16array over i16|2);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `memory::view::uint32array::RubyMemoryView`, which is not FFI-safe
   --> src/memory/view.rs:90:17
    |
90  |                 RubyMemoryView,
    |                 ^^^^^^^^^^^^^^ not FFI-safe
...
144 | memory_view!(uint32array over u32|4);
    | ------------------------------------- in this macro invocation
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/memory/view.rs:144:1
    |
144 | memory_view!(uint32array over u32|4);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `extern` fn uses type `memory::view::int32array::RubyMemoryView`, which is not FFI-safe
   --> src/memory/view.rs:90:17
    |
90  |                 RubyMemoryView,
    |                 ^^^^^^^^^^^^^^ not FFI-safe
...
145 | memory_view!(int32array over i32|4);
    | ------------------------------------ in this macro invocation
    |
    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
    = note: this struct has unspecified layout
note: the type is defined here
   --> src/memory/view.rs:145:1
    |
145 | memory_view!(int32array over i32|4);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 17 previous errors

error: could not compile `ruby-ext-wasm`.

To learn more, run the command again with --verbose.
rake aborted!
Command failed with status (101): [cargo build --release...]
/Users/sloveless/.gem/ruby/2.6.3/gems/wasmer-0.4.0/Rakefile:7:in `block in <top (required)>'
/Users/sloveless/.gem/ruby/2.6.3/gems/rake-13.0.1/exe/rake:27:in `<main>'
Tasks: TOP => default => test => build_lib
(See full trace by running task with --trace)

rake failed, exit code 1
ghost commented 3 years ago

any news ?

ancorgs commented 3 years ago

Same (or very similar) failure here with ruby-2.7.2 and rust-1.50.0

Hywan commented 3 years ago

Problem fixed with the rewrite (from #48) :-).