Stream: general

Topic: ✔ why would the `name` custom section be missing?


view this post on Zulip Andrew Brown (Jan 09 2023 at 17:56):

I recently ran into a toolchain issue, I believe with wasm-ld, where the name custom section was not emitted in the linked WebAssembly module. My current understanding is that the name custom section is added by the LLVM toolchain so that one can easily identify which function is which, instead of getting Wasm backtraces containing uninformative lines like <unknown>!<wasm function 23>. I believe wasm2wat also uses the name custom section to use named IDs (e.g., $foo) for the function names in the translated WAT. In a small example where I -c compile two Wasm object files, I can see that they contain linking custom sections with name information and, when I link these files together, I do see the expected name custom section. But in a larger project, the name section is missing--does anyone know why this would be the case?

view this post on Zulip Andrew Brown (Jan 09 2023 at 17:57):

cc: @Sam Clegg, who probably could give me a hint at what is going on here...

view this post on Zulip Alex Crichton (Jan 09 2023 at 17:57):

If you have wasm-opt in PATH then I think trecent clang toolchains run it by default and I believe by-default it strips the name section

view this post on Zulip Cheng Shao (Jan 09 2023 at 18:05):

And it's sad that there's no way to control the clang driver what flags to pass to wasm-opt, or whether to invoke wasm-opt at all. I've submitted https://github.com/llvm/llvm-project/issues/55781 some time ago for this

Currently, when linking wasm, clang attempts to detect wasm-opt in the environment, and invokes it with certain flags based on current optimization level. source This behavior is undesirable when u...

view this post on Zulip Andrew Brown (Jan 10 2023 at 00:34):

Thanks, wasm-opt is the culprit! Once I removed that from my PATH, wasm-ld emitted the name custom section. @Cheng Shao, I'll comment on the issue you linked to.

view this post on Zulip Notification Bot (Jan 10 2023 at 00:34):

Andrew Brown has marked this topic as resolved.


Last updated: Dec 23 2024 at 12:05 UTC