kanaka / wac

WebAssembly interpreter in C
Other
473 stars 46 forks source link

Any plans to allow x64 (amd64) builds? #12

Closed vshymanskyy closed 5 years ago

vshymanskyy commented 5 years ago

It would make it easier to use and start working with. And also improve portability. Thanks!

kanaka commented 5 years ago

The reason that wac and wace only support 32-bit builds is because the current WebAssembly standard only supports 32-bit memory addressing (wasm32). Since wac/wace support transparent calling into native libraries, this means that the memory addressing needs to match. There are ways to call across this boundary but that introduces a significant amount of complexity and another goal of wac/wace is simplicity.

If/when WebAssembly supports 64-bit addressing (wasm64) then we can support 64-bit builds for wac/wace. But if that happens, it will probably be several years in the future. There are other options for non-web WebAssembly embeddings such as wasmtime and wasmer and those default to 64-bit builds. However, they don't provide calling into arbitrary into system libraries. The ABI that is supported is explicitly defined with memory addressing conversion defined for each function call that is supported.

Direct dlsym/dlopen style calling is fairly unique to wac/wace, but the downside is that it ties wac/wace to the same memory addressing mode(s) supported by WebAssembly.

I'm going to close this ticket, but if you see any movement on wasm64 please feel to post here and I'll re-open.

Regarding the build difficulties, I do provide a docker image with everything needed to build wac/wace and also to compile C to wasm modules. Do you have specific issues that you ran into in terms of build/starting? Are there documentation improvements that you could suggest that might help?

vshymanskyy commented 5 years ago

Thanks for explanation, it makes sense btw!

vshymanskyy commented 5 years ago

But wac, wax should work in x64 build mode? All least wac works for me ;)

tommythorn commented 5 years ago

Ah interesting, but that seems to imply that it will never work on architectures that doesn’t support a 32-bit mode, like RISC-V? (No shipping silicon supports both RV64 and RV32, and no Linux distro supports 32-bit).

kanaka commented 5 years ago

@vshymanskyy I suspect you're either not importing/using libc functions or you are using them but you're just getting lucky that calling frame alignment is happening to work out. The fact that many calling conventions pass the first few function arguments as registers and the fact that 16-bit/32-bit/64-bit registers are aliases on x86 is probably working out in your favor here.

wax could certainly be modified to properly support 64-bit compilation without relying on luck to get the argument passing correct because the set of functions available is limited to a specific set which we know the argument before hand.

vshymanskyy commented 5 years ago

Obviously not importing/using native functions! ;) Pure WASM code.

On Mon, May 13, 2019 at 8:23 PM Joel Martin notifications@github.com wrote:

@vshymanskyy https://github.com/vshymanskyy I suspect you're either not importing/using libc functions or you are using them but you're just getting lucky that calling frame alignment is happening to work out. The fact that many calling conventions pass the first few function arguments as registers and the fact that 16-bit/32-bit/64-bit registers are aliases on x86 is probably working out in your favor here.

wax could certainly be modified to properly support 64-bit compilation without relying on luck to get the argument passing correct because the set of functions available is limited to a specific set which we know the argument before hand.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kanaka/wac/issues/12?email_source=notifications&email_token=AALP3FCCILFIG7PNRX7L7ELPVGPZFA5CNFSM4G622XJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVI7YOQ#issuecomment-491912250, or mute the thread https://github.com/notifications/unsubscribe-auth/AALP3FHG2QI76LZ6CBTYX4DPVGPZFANCNFSM4G622XJQ .

-- Kindest regards, Volodymyr Shymanskyy