wasmerio / wasmer-ruby

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

Failed to install this gem #42

Closed namnm1991 closed 3 years ago

namnm1991 commented 3 years ago

Summary

Hi guys, when I install this gem, it said 'could not compile ruby-ext-wasm' with 17 errors. It's all about "not FFI-safe". Could you give me some advice here? (I'm using Ubuntu 20.04, and rbenv)

Additional details

rustc -V
rustc 1.46.0 (04488afe3 2020-08-24)

rustup -V
rustup 1.22.1 (b01adbbc3 2020-07-08)

cargo -V
cargo 1.46.0 (149022b1d 2020-07-17)

ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]

Error log

$ gem install wasmer --verbose                                                                                                                                                                                                                        ⬡ 12.18.3 [±signing ●●]
HEAD https://rubygems.org/api/v1/dependencies
200 OK
GET https://rubygems.org/api/v1/dependencies?gems=wasmer
200 OK
GET https://rubygems.org/api/v1/dependencies?gems=rutie
200 OK
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.cargo/config
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.github/ISSUE_TEMPLATE/---bug-report.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.github/ISSUE_TEMPLATE/---feature-request.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.github/ISSUE_TEMPLATE/--question.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.github/workflows/test.yml
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.gitignore
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/CHANGELOG.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/Cargo.lock
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/Cargo.toml
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/Gemfile
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/LICENSE
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/README.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/Rakefile
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/bors.toml
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/justfile
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/lib/wasmer.rb
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/lib/wasmer/version.rb
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/error.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/instance/exports.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/instance/globals.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/instance/mod.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/lib.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/memory/mod.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/memory/view.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/module.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/wasmer.gemspec
Building native extensions. This could take a while...
current directory: /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0
["/home/nam/.rbenv/versions/2.6.6/bin/ruby", "-rrubygems", "/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake", "RUBYARCHDIR=/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0", "RUBYLIBDIR=/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0"]
bundle install
Fetching gem metadata from https://rubygems.org/...
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 13.0.1
Using ansi 1.5.0
Using builder 3.2.4
Using bundler 2.1.4
Using minitest 5.14.2
Using ruby-progressbar 1.10.1
Using minitest-reporters 1.4.2
Using color_pound_spec_reporter 0.0.9
Using rutie 0.0.4
Using wasmer 0.4.0 from source at `.`
Bundle complete! 6 Gemfile dependencies, 10 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
cargo build --release
   Compiling cfg-if v0.1.10
   Compiling semver-parser v0.7.0
   Compiling autocfg v1.0.0
   Compiling libc v0.2.67
   Compiling proc-macro2 v1.0.9
   Compiling unicode-xid v0.2.0
   Compiling cc v1.0.50
   Compiling syn v1.0.16
   Compiling typenum v1.11.2
   Compiling byteorder v1.3.4
   Compiling lazy_static v1.4.0
   Compiling maybe-uninit v2.0.0
   Compiling cranelift-entity v0.52.0
   Compiling smallvec v1.2.0
   Compiling cranelift-codegen-shared v0.52.0
   Compiling serde v1.0.104
   Compiling scopeguard v1.1.0
   Compiling target-lexicon v0.9.0
   Compiling bitflags v1.2.1
   Compiling log v0.4.8
   Compiling subtle v1.0.0
   Compiling arrayref v0.3.6
   Compiling constant_time_eq v0.1.5
   Compiling arrayvec v0.5.1
   Compiling rayon-core v1.7.0
   Compiling nix v0.15.0
   Compiling void v1.0.2
   Compiling wasmparser v0.45.2
   Compiling hex v0.4.2
   Compiling either v1.5.3
   Compiling rutie v0.7.0
   Compiling semver v0.9.0
   Compiling cranelift-bforest v0.52.0
   Compiling lock_api v0.3.3
   Compiling cranelift-codegen-meta v0.52.0
   Compiling crossbeam-utils v0.7.2
   Compiling crossbeam-epoch v0.8.2
   Compiling indexmap v1.3.2
   Compiling rustc_version v0.2.3
   Compiling quote v1.0.2
   Compiling memoffset v0.5.3
   Compiling generic-array v0.12.3
   Compiling smallvec v0.6.13
   Compiling num_cpus v1.12.0
   Compiling parking_lot_core v0.7.0
   Compiling page_size v0.4.2
   Compiling errno v0.2.4
   Compiling memmap v0.7.0
   Compiling crypto-mac v0.7.0
   Compiling digest v0.8.1
   Compiling blake3 v0.1.5
   Compiling raw-cpuid v7.0.3
   Compiling parking_lot v0.10.0
   Compiling crossbeam-queue v0.2.1
   Compiling serde-bench v0.0.7
   Compiling bincode v1.2.1
   Compiling serde_bytes v0.11.3
   Compiling crossbeam-deque v0.7.3
   Compiling rayon v1.3.0
   Compiling wasmer-runtime-core v0.14.1
   Compiling thiserror-impl v1.0.11
   Compiling serde_derive v1.0.104
   Compiling thiserror v1.0.11
    Building [================================================>      ] 100/112: cranelift-codegen-meta, serde_derive                                                                                                                                                          

   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 (/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/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...]

Tasks: TOP => default => test => build_lib
(See full trace by running task with --trace)
ERROR:  Error installing wasmer:
    ERROR: Failed to build gem native extension.

    current directory: /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0
/home/nam/.rbenv/versions/2.6.6/bin/ruby -rrubygems /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake RUBYARCHDIR\=/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0 RUBYLIBDIR\=/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0
Building has failed. See above output for more information on the failure.
rake failed, exit code 1

Gem files will remain installed in /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0 for inspection.
Results logged to /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0/gem_make.out
Hywan commented 3 years ago

Hmm thanks for raising this issue. And sorry for the late reply!

That's surprising. Maybe Rust has added some rules since our last release, but I'm not aware of anything like that for the moment. I'll check.

Hywan commented 3 years ago

I can reproduce your issue! I'm in the middle of a large rewrite for this project, and this error is not present in the rewrite. Please wait few weeks before the next release. How does it sound to you?

ancorgs commented 3 years ago

Any news? I have just reproduced this error with the currently latest available rubygem. Using ruby-2.7.2 and rust-1.50.0

Hywan commented 3 years ago

Sorry, our agenda has changed a little bit. I'm pinging the team to discuss that in our next agenda meeting. cc @wasmerio/langint

jakub-stastny commented 3 years ago

I'd also appreciate an update on this one please guys 🙏🏼

Hywan commented 3 years ago

Thanks for the heads up :-). I'll try to come back shortly.

Hywan commented 3 years ago

Fixed with the rewrite that happened in #48. Closing the issue!