Stream: rust-toolchain

Topic: Rust compilation issues


view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:35):

Is anyone experiencing this or am I having something broken on my setup? https://github.com/rust-lang/rust/issues/73278

Hello, I may just miss-understand how this is supposed to be used, but I cannot find a way to get a simple rust program to open a file in wasm32-wasi (tried a few VMs and at this point I am almost ...

view this post on Zulip Alex Crichton (Jul 30 2020 at 15:41):

@Alexandru Ene does the same issue happen with other runtimes? or just WAMR?

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:41):

Yes, any runtime has that issue, as basically the generated wasm binary doesn't import the things it should import for File::open() to work.

If I build it on OSX fd_prestat_get and another method is missing from the imports list (same build with wasm32-wasi as a target. On windows it generates the correct thing. I didn't try linux as I didn't have a machine, but it looks like cargo build --target wasm32-wasi generates different things on windows/osx at least.

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:44):

My follow-up comment has some more things I uncovered as I was debugging this.

view this post on Zulip Alex Crichton (Jul 30 2020 at 15:44):

hm so the platform differences are unexpected, but I'm otherwise a bit confused as to what the issue is

view this post on Zulip Alex Crichton (Jul 30 2020 at 15:45):

is file opening not working or is it just pulling in unexpected imports?

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:46):

No, so the generated file doesn't have the imports that it needs to have when building on OSX (the broken version). When building on windows, it imports as expected fd_prestat_get for the wasm32-wasi target

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:47):

I don't think the platforms should generate different binaries, at least not with regards to the WASI-related imports

view this post on Zulip Alex Crichton (Jul 30 2020 at 15:47):

so only if you compile the program from macos does the wasm not work?

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:47):

Yup

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:48):

Compiling the same exact code with the same compiler version on windows does work and generate the code that has the correct import fields on windows but not osx

view this post on Zulip Alex Crichton (Jul 30 2020 at 15:49):

ok I'll try to dig in

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:50):

Yeah if you have these in the generated .wasm then it means that it correctly compiled .

  (import "wasi_snapshot_preview1" "fd_prestat_get" (func $__wasi_fd_prestat_get (type $t2)))
  (import "wasi_snapshot_preview1" "fd_prestat_dir_name" (func $__wasi_fd_prestat_dir_name (type $t8)))

view this post on Zulip Alex Crichton (Jul 30 2020 at 15:52):

that program works for me when compiled from macos/linux/windows

view this post on Zulip Alex Crichton (Jul 30 2020 at 15:53):

all three platforms produce the same exact wasm file byte-for-byte

view this post on Zulip Alex Crichton (Jul 30 2020 at 15:54):

so I can't reproduce?

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:55):

:frown: I did suspect something's strange on my setup then

view this post on Zulip Alexandru Ene (Jul 30 2020 at 15:55):

Might as well close the issue I think if nobody else can repro it

view this post on Zulip Alexandru Ene (Jul 30 2020 at 16:04):

Thanks for the help and test @Alex Crichton


Last updated: Dec 23 2024 at 14:03 UTC