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

[wasm2wat] Nicer error for known but disabled feature #1197

Open
godmar opened this issue Oct 24, 2019 · 2 comments
Open

[wasm2wat] Nicer error for known but disabled feature #1197

godmar opened this issue Oct 24, 2019 · 2 comments

Comments

@godmar
Copy link

godmar commented Oct 24, 2019

Hi, I'm new to WASM.

I've installed emscripten using the installation instructions and tried it out on a simple program:

#include <cstdlib>
#include <cstring>

char *
malloc_demo()
{
    char *p = (char *)malloc(20);
    strcpy(p, "Hello, World\n");
    return p;
}

this is with

$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.0
clang version 10.0.0 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project e44524736c4a97ae4fb37193e58647f838f6d36a)

when I run wabt on it (the current build), I see:

$ wasm2wat malloc.wasm 
000009d: error: invalid section code: 12

I googled the specification - indeed, section numbers don't extend past 11.

However, I also found an issue in the LLVM Phabricator that introduced a DataCount section, which tools such as binaryen apparently support.

The Phabricator issue notes that:
Engines that don't support bulk memory operations will not recognize the DataCount section and will report validation errors, but that's ok because object files aren't supposed to be run directly anyway.

I suppose my confusion is why I tapped into something that's apparently in development. Does wabt tracked 'tagged releases' of emscripten? Should wabt be able to convert files containing such "linking sections" to the .wat format, and this particular feature just has not been implemented? Or am I mistaken in the idea to be able to convert files written by emscripten using wabt?

Thank you.

@godmar
Copy link
Author

godmar commented Oct 24, 2019

PS: running wasm2wat -v, I found:

$ wasm2wat --enable-bulk-memory malloc.wasm -o malloc.wat

or

$ wasm2wat --enable-all malloc.wasm -o malloc.wat

which make it parse this file.

I suppose this makes my issue a usability suggestion. How about instead of outputting invalid section code, output invalid section code - did you forget to enable a feature you want?

@binji
Copy link
Member

binji commented Oct 26, 2019

Agreed, that would be a nice fix. It would be even nicer to look for these known but disabled features and mentions the flag explicitly.

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

No branches or pull requests

2 participants