This is a PR to add setjmp/longjmp exception handling to libzigunwind. Fixes #2.
feat: add sjlj exception handling #3
abm-77/libzigunwind:port-sjlj into main 3c42c2efc7
to 547ad1b3b2
547ad1b3b2
to a301da65ae
a301da65ae
to c44307a242
Hi @tensorush, this is my first long-form Zig contribution, so I am sure there are many mistakes. Happy to work together to get this into a state you envision for the project. I had a couple of questions about the SJLJ port:
- How should we be referencing
longjmpinunwindPhase2andunwindPhase2Forced? Currently, I declare it as an external symbol. - How should we handle the
__ve__configuration? Right now, I default to 64-bit pointers for theresumeLocationandresumeParameters, but it seems like we should only do this when__ve__is defined 32-bit pointers otherwise. Is this something we can get frombuiltinor the config? - How do you envision we switch between exception handling implementations?
- Do you intend to port over the tests defined in the original libunwind, or should we look to create more comprehensive tests?
Hi, thanks for taking this on, here're my thoughts:
- Yes, that's fine. That function is implemented in
libc, so it will have (or maybe already has) a Zig implementation as part oflibzigc. #if defined(__ve__)translates to Zig asif (builtin.cpu.arch == .ve). So, in that instance it means that on the Ve architecture those fields should beu64, otherwise, they should beu32.- That one's tricky, it mostly depends on the ABI (
builtin.abi). As Alex pointed out, it's worth looking at how Clang defines those macros, like__USING_SJLJ_EXCEPTIONS__or__SEH__. Although, I haven't looked too much into it yet, I doubt it'll be as straightforward to do in Zig, so I think we might have to add another config option to switch on manually, at least for now. - Yep, I intend to incorporate them as test functions at the end of respective implementation files. More tests are definitely welcome.
c44307a242
to 8f9f251c2c
- Gotcha, I'll leave as is for now.
- Cool, just made that change.
- I see. I will add a build option like
use_sjlj_exceptions. We can use this to conditionally link libc (unless we need it for anything else) and eventually conditionally enabling SJLJ exception handling when we decide on how we expose the functionality to users. - Great, makes sense.
8f9f251c2c
to ee9cc36beb
ee9cc36beb
to 045b502966
I think at this point I have faithfully ported over the original C file. I am currently looking to create functional tests for validating the implementation.
LGTM. Don't forget to change the PR from Draft when you're ready to have it merged.
I think I'll go ahead and merge it with the rest now. Feel free to contribute more in another PR. Thanks again!
Great, no worries. Sorry about the delayed communication!
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?