w2c2: DWARF doesn't work
I tried with a minimal file:
#include <stdio.h>
int a() {
return 42;
}
int b() {
return a();
}
int c() {
return b();
}
int main() {
printf("%d\n", c());
}
built with WASI SDK with debug info and regenerated via w2c2 with debug info:
$ /opt/wasi-sdk/bin/clang mini.cpp -o mini.wasm -g
$ ~/w2c2/w2c2/build/w2c2 -g mini.wasm mini.c
I checked that mini.wasm has DWARF info as expected via llvm-dwarfdump, but the resulting mini.c doesn’t have any #line directives that w2c2 -h says would be emitted.
Regular names are still emitted via __asm__, but the 2nd problem is that one of them looks corrupted (?):
...
U32 wasi_snapshot_preview1__fd_write(struct miniInstance*,U32,U32,U32,U32);
void wasi_snapshot_preview1__proc_exit(struct miniInstance*,U32);
void f5(miniInstance*) __asm__("mini_�{��mU");
void f6(miniInstance*) __asm__("mini___imported_wasi_snapshot_preview1_fd_fdstat_get");
U32 f7(miniInstance*) __asm__("mini___imported_wasi_snapshot_preview1_fd_seek");
U32 f8(miniInstance*) __asm__("mini___imported_wasi_snapshot_preview1_fd_write");
...
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 23 (8 by maintainers)
Yay, with manual config +
-DDWARF_OLD=1it finally worked, thanks!At least I can confirm the corrupted names issue is gone.
Ah no, I don’t have libdwarf installed and didn’t know it’s necessary, that’s probably it for
#line:Might be useful to add this as a requirement to README, I don’t think it’s mentioned.
I’ll install and recheck now.
Here’s mini.wasm (zipped as Github doesn’t like Wasm directly): mini.zip
Sorry, away from computer but the mini sample above + command for WASI SDK 19.0 should result in the same binary.
If not, I can rebuild one myself and share a bit later.