-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
SIDE_DEBUG option: emit DWARF in a wasm on the side #10568
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for now, although eventually it would maybe be nicer if the flag were a -gsomething
flag like clang's -gsplit-dwarf
Oh, one other thing I forgot; we should add the external_debug_info section as in https://yurydelendik.github.io/webassembly-dwarf/#external-DWARF (or propose some other way to encode the section). This is probably most easily done by emitting the section data to a file and using +cc @pfaffe |
Thanks, comments addressed, including adding the new section. |
@@ -2821,6 +2821,11 @@ def check_bad_eq(arg): | |||
newargs[i] = '-g' | |||
shared.Settings.FULL_DWARF = 1 | |||
shared.warning('gforce_dwarf is a temporary option that will eventually disappear') | |||
elif requested_level.startswith('side'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this still suffer from the problem that -g after -gside negates the SIDE_DEBUG setting?
Actually looking at the code, I don't really see how that happens. FULL_DWARF will get set to 1, but then nothing unsets it when the -g is later processed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that flag mixup was something else I think. @pfaffe let me know if that's still an issue and if I can help there.
Overall -g
can't override the two new flags we added, so this should be ok.
contents = asbytes(wasm_file_with_dwarf) | ||
section_size = len(section_name) + len(contents) | ||
with open(wasm_file, 'ab') as f: | ||
f.write(b'\0') # user section is code 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit isn't necessary. The section header is created by objcopy. We only need the payload here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(the alternative of course would be to create the header here too and then just directly append to the file rather than using objcopy at all)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't use objcopy
to add the new section - it just appends the bytes itself manually, so we emit all the parts. (We do similar things for a few other custom sections, like the dylink section, see make_shared_library()
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh oops, I didn't read it closely enough :D
I think SIDE_DEBUG is maybe a bit misleading as ppl might thing it relates to SIDE_MODULE. Whats wrong with SPLIT_DEBUG? |
I'm not a huge fan of the term either. Split is good but -gsplit-dwarf exists already and means something a bit different (it leaves the debug info in the object files). |
Perhaps we can stress that the normal usage is |
Yeah, I would say if here is a corresponding regular option we should always prefer settings_internal. How about |
Sounds good, I opened #10588 |
When used, the main wasm file has no dwarf in it, but a
.debug.wasm
file on the side does. This is similar tosplit-dwarf in gcc/clang, but simpler. We may evolve this
further but for now it should be useful.