Progress report on rustc_codegen_cranelift (April 2024)
There has been a fair bit of progress since the last progress report! There have been 342 commits since the last progress report.
You can find a precompiled version of cg_clif at https://github.com/bjorn3/rustc_codegen_cranelift/releases/tag/dev or in the rustc-codegen-cranelift-preview rustup component if you want to try it out.
Achievements in the past five months
SIMD
A ton of missing SIMD intrinsics got reported over the past couple of months. Most intrinsics that people have reported missing are now implemented.
- #1416: Implement AArch64 intrinsics necessary for simd-json (thanks @afonso360!)
- #1417: Implement a lot of SIMD intrinsics
- #1425: Implement AES-NI and SHA256 crypto intrinsics using inline asm
- #1431: Implement another batch of vendor intrinsics
- 45d8c12: Return architecturally mandated target features to rustc
- #1443: Restructure x86 signed pack instructions (thanks @Noratrieb!)
- 0dc13d7: Implement _mm_prefetch as nop
- 24361a1: Fix portable-simd tests
- 604c8a7: Accept [u8; N] bitmasks in simd_select_bitmask
- cdae185: Implement SHA-1 x86 vendor intrinsics
- 1ace86e: Implement all x86 vendor intrinsics used by glam
Debuginfo
I’ve started implementing debuginfo support beyond the already existing line table support. Most primitive types are now described in the debuginfo tables. And the locations and types of statics are now encoded. For unsupported types [u8; size_of::<T>()]
will be used as type instead. While debuginfo for statics may not be all that useful for most use cases, describing types is a prerequisite for debuginfo describing the locations of locals, which is very useful for debugging.
- #1470: Various small debuginfo improvements
- #1472: Add debuginfo for statics
- issue #166: DWARF support
s390x support
A couple of fixes to the s390x support now allows compiling and testing cg_clif on s390x.
- #1457: Fix simd_select_bitmask on big-endian systems (thanks @uweigand!)
- #1458: Fix download hash check on big-endian systems (thanks @uweigand!)
- b03b414: Fix stack alignment problem on s390x
Challenges
SIMD
While core::simd
is fully supported through emulation using scalar operations, many platform specific vendor intrinsics in core::arch
are not supported. This has been improving though with the most important x86_64 and arm64 vendor intrinsics implemented.
If your program uses any unsupported vendor intrinsics you will get a compile time warning and if it actually gets reached, the program will abort with an error message indicating which intrinsic is unimplemented. Please open an issue if this happens.
- issue #171: std::arch SIMD intrinsics
Cleanup during stack unwinding on panics
Cranelift currently doesn’t have support for cleanup during stack unwinding. I’m working on implementing this and integrating it with cg_clif.
Until this is fixed panic::catch_unwind()
will not work and panicking in a single thread will abort the entire process just like panic=abort
would. This also means you will have to use -Zpanic-abort-tests
in combination with setting panic = "abort"
if you want a test failure to not bring down the entire test harness.
- issue wasmtime#1677: Support cleanup during unwinding
Contributing
Contributions are always appreciated. Feel free to take a look at good first issues and ping me (@bjorn3) for help on either the relevant github issue or preferably on the rust lang zulip if you get stuck.