Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"invalid linking metadata version: 3" when running against Rust-generated WASM #842

Open
shepmaster opened this issue May 16, 2018 · 11 comments

Comments

@shepmaster
Copy link

When running wasm2wat on Rust-generated WASM, I get an error:

wasm2wat --fold-exprs --generate-names --inline-exports --ignore-custom-section-errors --no-check -o /tmp/out.wat target/wasm32-unknown-unknown/release/playground.wasm.gc
002e818: error: invalid linking metadata version: 3

playground.wasm.zip

The --ignore-custom-section-errors flag doesn't seem to take effect; perhaps I'm doing something wrong?

I'm using:

  • rustc 1.27.0-nightly (f0fdaba04 2018-05-15)
  • Commit dd7663d

(moved from comments on #841)

@shepmaster
Copy link
Author

In case it matters, we don't normally use the --no-check option.

@shepmaster shepmaster changed the title "invalid linking metadata version: 3" when running agains Rust-generated WASM "invalid linking metadata version: 3" when running against Rust-generated WASM May 16, 2018
@binji
Copy link
Member

binji commented May 16, 2018

I just tried this out with HEAD (dd7663d) and I see the same error message, but it does produce output:

$ wasm2wat playground.wasm --ignore --fold --gen --inline-export --no-check
000004d: error: invalid linking metadata version: 3
(module
  (type $t0 (func (param i32 i32) (result i32)))
  (func $example (export "example") (type $t0) (param $p0 i32) (param $p1 i32) (result i32)
    (i32.add
      (get_local $p1)
      (get_local $p0)))
  (table $T0 1 1 anyfunc)
  (memory $memory (export "memory") 17))
$ echo $?
0

Perhaps we should replace the message with a warning instead.

@shepmaster
Copy link
Author

but it does produce output

Heh, I never even looked because of the error message. 😊

Since this is targeted for the Rust Playground, I'd rather users not see that text, but I could always munge it out somehow.

@binji
Copy link
Member

binji commented May 16, 2018

@sbc100 and I were discussing this. We're curious how you're using the tool. I assume the Rust Playground allows you to write rust and you're going to show the wat output, is that right? (n/m @jgravelle-google just showed me the actual output running :-))

If you run wasm2wat on the output of the linker (wasm lld) you won't have this issue, since there will be no linking section. But it's reasonable to show the output of the wasm object files too, I suppose.

In any case, this issue (the extra error mesage) should be resolved as soon as LLVM is updated to the new format.

@shepmaster
Copy link
Author

For reference, here's the full invocation we do on the backend.

shepmaster added a commit to rust-lang/rust-playground that referenced this issue May 16, 2018
@shepmaster
Copy link
Author

I think that everything is square for me now. I would agree that it should say "warning" instead of "error" to help prevent poor sods like me from being confused.

@sbc100
Copy link
Member

sbc100 commented May 16, 2018

do you happen to know what the $(find target/ -name '*wasm' -not -path '*/deps/*') command finds? Is it finding the output of the compiler or just the linker? i.e. i cargo using .wasm for object files as well as for
the final output?

@alexcrichton
Copy link
Contributor

@sbc100 oh the wasm artifact that Cargo emits is the output of LLD, all intermediate artifacts are stuffed away in rlibs (rust versions of *.a files) and are named after object files (*.o)

@sbc100
Copy link
Member

sbc100 commented May 16, 2018

OIC.. I think lld used to always write the linking section and now it doesn't. https://reviews.llvm.org/D42869.

So, I guess the problem will doubly go away when you update because the final output should not have a linking section at all.

@autodidaddict
Copy link

I get this same error message. I was once able to get it to go away after running wasm-gc on the wasm file. If I don't use the below syntax, I get no output:

wasm2wat mem.wasm --ignore --fold --gen --inline-export --no-check -o test.wat

@binji
Copy link
Member

binji commented Jun 14, 2018

@autodidaddict I suppose the --ignore-custom-section-errors flag seems to be required still. Perhaps I should have made it the default instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants