-
Notifications
You must be signed in to change notification settings - Fork 725
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
Wat to Asm linker ? #1133
Comments
If you generate wasm object files, you can link them with LLVM's You may also want to look at Lobster's single-file wasm binary writer, which can generate object files too. And LLVM can generate wasm object files too, if you compile your code with
Concatenating all the files might work, as long as you are careful that you don't reuse names, and that you don't reference anything by index (since those will need to be remapped). |
I went to wasm-ld straigth ahead :-) and got the following error when trying to link wasm object file
I don't quite understand why those 2 symbols are undefined (note: whether I name the start function $start or $_start doesn't change a thing). And it certainly doesn't explain why the square function is not recognized. Any idea ? |
Hm, it looks like the You may want to try using the LLVM assembler (or clang) to generate object files instead. It would be nice to add this functionality to |
I have tried using clang already but it doesn' seem to recognize the wat format:
May be I should try llvm-as |
LLVM and its associated tools do not recognize the standard WebAssembly text formats. They instead use their own .s format that is much closer to traditional assembly languages. Binaryen used to have a |
There's a fair bit of complexity in Wasm modules that are linkable, in particular as it relates to relocation, since so much in the module format is indices that all need to change once merged. So using LLD to do this for you is the way to go, trying to merge in any other way will likely end in tears :) If you want to write small linkable modules by hand, using llvm Note that assembly assumes you know what you're doing, for example it won't stop you from writing instruction sequences that produce illegal arguments on the stack. You'll need to run the result thru Frankly, you're better off writing your linkable modules in C. I agree that we should add features to the .wat format to exactly represent the sections in https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md |
`wasm-link` is deprecated and it's not possible to support multi-value functions. And `--relocatable` option is broken so we can't link wasm files with `wasm-ld` too. See: WebAssembly/wabt#1133
At this point I think this bug can be closed. With the latest bug-fixes in #1537 in theory |
Sounds good, we likely will want to add other features to make relocations nicer later (e.g. WebAssembly/design#1368), but that's unrelated to this issue. |
As far as i can see, wat2wasm can only take a single WAT file as input. Are you aware of any tool that would take several wasm file as input (each of them being a module) and assemble them into a single wasm file ?
Or would concatenating all the wat files together before invoking wat2wasm do the trick ?
The text was updated successfully, but these errors were encountered: