rustwasm / walrus

Walrus is a WebAssembly transformation library šŸŒŠšŸ˜
https://docs.rs/walrus
Apache License 2.0
391 stars 62 forks source link

How to output an object file which can be linked with other .o files? #279

Open Germ210 opened 2 days ago

Germ210 commented 2 days ago

Could you provide detailed guidance on how to generate an object file (.o) from a WebAssembly compilation process, specifically focusing on producing a .o file instead of a .wasm file? Iā€™m particularly interested in understanding how to modify the compilation pipeline or use specific tools (such as clang++, wasm-ld, or the WASI SDK) to ensure that the output is an object file suitable for further linking with other .o files. What flags, tools, or configurations are required for this, and how does this affect the compilation process in terms of producing a linkable WebAssembly module? Additionally, how can one ensure that the resulting .o file retains compatibility for cross-language linking, especially in cases where it will be linked with other .o files produced from languages like C++ or Rust? Any recommendations on handling platform-specific considerations or toolchain adjustments for generating .o files would be valuable as well.

sunfishcode commented 18 hours ago

A ".o" file is a Wasm binary that incudes a "linking" custom section, and supporting sections, which are documented here.