wasmerio / wasmer-ruby

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

Export Wasm globals ? #30

Closed ljulliar closed 4 years ago

ljulliar commented 4 years ago

Hi there,

It is unclear to me whether one can access exported Wasm globals with ruby-ext-wasm. I tried and I got some kind of weird errors when instatiating a wasm module with exported globals like "global must be a const" (although the wasm code was perfectly valid) Thanks!

Hywan commented 4 years ago

I can implement that quickly, as I did for python-ext-wasm in https://github.com/wasmerio/python-ext-wasm/pull/120. Would it fit your needs?

ljulliar commented 4 years ago

That would be great! In the meantime I put a workaround in place but not very elegant (basically I export a function that returns the value of the global).

Side question too: is there a way from the Ruby extension to import a function in the wasm module that you can then call from the wasm code ?

Thanks!

Laurent

On Wed, Feb 5, 2020, 17:14 Ivan Enderlin notifications@github.com wrote:

I can implement that quickly, as I did for python-ext-wasm in wasmerio/python-ext-wasm#120 https://github.com/wasmerio/python-ext-wasm/pull/120. Would it fit your needs?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wasmerio/ruby-ext-wasm/issues/30?email_source=notifications&email_token=AAAED4KV4FWXYMDX2U4CZPDRBLQVFA5CNFSM4KONNBE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK4AFNI#issuecomment-582484661, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAED4PQ3NCGWMXVQN3JOELRBLQVFANCNFSM4KONNBEQ .

Hywan commented 4 years ago

See #32 for the Global API.

To answzer your side question: For the moment, no, we need to support polymorphic host functions in Wasmer (the Wasmer runtime) directly. I'm working on it, since it will unblock host functions support in Ruby.

ljulliar commented 4 years ago

Hi Ivan,

Are you thinking of releasing the wasmer rubygem 0.3.1 with this new feature for globals or there is just no need for it ?

Thanks!

On Fri, Feb 7, 2020 at 3:20 PM Ivan Enderlin notifications@github.com wrote:

Closed #30 https://github.com/wasmerio/ruby-ext-wasm/issues/30 via #32 https://github.com/wasmerio/ruby-ext-wasm/pull/32.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wasmerio/ruby-ext-wasm/issues/30?email_source=notifications&email_token=AAAED4PCMMSGXZ6P3ELSO23RBVU3VA5CNFSM4KONNBE2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWPQCK5Y#event-3017811319, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAED4NISBAHNNAK6275L5LRBVU3VANCNFSM4KONNBEQ .