Migrated from: https://github.com/ziglang/zig/issues/23560
In our vendored libunwind, there are approximately 15k lines of implementation code. We have to keep the headers for C/C++ code that uses them, but it seems quite feasible to rewrite the implementation in Zig.
This could even be done incrementally following a similar model to #30978.
High-level list of tasks to be done:
- Port the libunwind test suite to the Zig build system and make sure that it passes as a baseline.
- Set up frontend logic to build libzigunwind (alongside libunwind for now; see libzigc logic).
- Scaffold the Zig implementation with weak exports matching the full libunwind ABI.
- Mainly to get an overview of what needs doing; each function can
@trap() initially.
- Each function should be turned into a strong export once the corresponding libunwind function has been fully ported and deleted.
- Port all the personality function implementations to Zig.
- Get stack unwinding for x86_64, aarch64, arm, and wasm working:
- Implement DWARF unwinding.
- Implement Darwin unwinding (DWARF + compact info).
- Implement Windows SEH unwinding.
- Implement Arm EHABI unwinding (32-bit Arm only).
- Implement WASM unwinding.
- Thoroughly fill in all the arch/OS-specific details in the implementations above.
- Extremely low priority: Implement SjLj-based unwinding.
- I doubt anyone even uses this?
- Finally, delete the vendored libunwind so that the frontend only builds libzigunwind.
Feel free to ignore CET support and other such mitigations.
Migrated from: https://github.com/ziglang/zig/issues/23560
In our [vendored libunwind](https://codeberg.org/ziglang/zig/src/branch/master/lib/libunwind), there are approximately 15k lines of implementation code. We have to keep the headers for C/C++ code that uses them, but it seems quite feasible to rewrite the implementation in Zig.
This could even be done incrementally following a similar model to https://codeberg.org/ziglang/zig/issues/30978.
High-level list of tasks to be done:
* Port the libunwind test suite to the Zig build system and make sure that it passes as a baseline.
* Set up frontend logic to build libzigunwind (alongside libunwind for now; see libzigc logic).
* Scaffold the Zig implementation with weak exports matching the full libunwind ABI.
* Mainly to get an overview of what needs doing; each function can `@trap()` initially.
* Each function should be turned into a strong export once the corresponding libunwind function has been fully ported and deleted.
* Port all the personality function implementations to Zig.
* Get stack unwinding for x86_64, aarch64, arm, and wasm working:
* Implement DWARF unwinding.
* Implement Darwin unwinding (DWARF + compact info).
* Implement Windows SEH unwinding.
* Implement Arm EHABI unwinding (32-bit Arm only).
* Implement WASM unwinding.
* Thoroughly fill in all the arch/OS-specific details in the implementations above.
* Extremely low priority: Implement SjLj-based unwinding.
* I doubt anyone even uses this?
* Finally, delete the vendored libunwind so that the frontend only builds libzigunwind.
Feel free to ignore CET support and other such mitigations.