RE: https://hachyderm.io/@folkertdev/117637096813697288
In light of this, I'm looking for code bases (that compile to binaries) that make serious use of `dyn Trait` to benchmark the LLVM changes with.
So, if you have any of those, let me know
RE: https://hachyderm.io/@folkertdev/117637096813697288
In light of this, I'm looking for code bases (that compile to binaries) that make serious use of `dyn Trait` to benchmark the LLVM changes with.
So, if you have any of those, let me know
I wrote up an update on the virtual function elimination feature
https://github.com/rust-lang/rust/issues/68262#issuecomment-6930708339
When using `&dyn Trait`, this feature removes virtual functions that never get called, and may turn virtual calls back into direct calls if there is only one possible option. The idea is that you get the upsides of `dyn Trait` with less of the downsides.
But, rustc currently gives incomplete information to LLVM, causing it to miscompile. The LLVM implementation is also clearly meant for C++, and doesn't handle what rust gives it well in all cases.
So, let's fix that!
Something that wasn't in the release blog post (I forgot), but is stable in Rust 1.100 is `extern "custom"`.
These are functions with a calling convention (the details of where the arguments go in registers/on the stack) that rust does not know about, hence these functions can't be called, except via inline assembly.
and at long last target features now work on naked functions.
https://github.com/rust-lang/rust/pull/137720
This will have to remain unstable while we support LLVM versions lower than 23 though, so it'll be a while before it hits stable.
A long-standing (embedded) rust bug has finally been fixed: global assembly now knows about globally-enabled target features
https://github.com/rust-lang/rust/pull/160594
Before you could get weird LLVM errors saying that a target feature was not enabled while it clearly was.
@nikic added the ability to attach target features to assembly blocks in LLVM 23, and now it's been hooked up in rustc.
I'm working on a rust complex number type that is ABI-compatible with its C counterpart. Here is an initial status update:
https://github.com/rust-lang/goals/issues/761#issuecomment-5387788008
If that's something you have a use for, please reach out.
Now you might wonder what could be so hard about this, it's just a struct with two fields. True, but many ABIs have come up with some creative ways of passing these things around. And clang and gcc sometimes disagree(d) on how to do this. The clang powerpc implementation still miscompiles...
anyway, I'm getting good usage out of my cross-compiling abi-cafe https://github.com/folkertdev/abi-cafe#cross-compilation
For instance it catches this 2018 sparc64 bug passing a packed { f32, i32 } between clang and gcc
https://github.com/rust-lang/rust/issues/57103
rust generally follows the clang abi, so we inherit the bug.
My weekend project: a version of abi-cafe (by @Gankra) that can cross-compile and run under qemu. That makes it much easier to find ABI-bugs across targets:
https://github.com/folkertdev/abi-cafe#cross-compilation
This is a bit of a "disappointing facts about clang" generator, but hopefully we can get the ABI bugs fixed. Several fixes for mips and sparc have already been merged.
I'd also love it if someone more competent at CI stuff could make some sort of report out of the json it spits out (and have that run rust stable, rust nightly, clang nightly, etc.)
Finally, it's done! C-variadic function definitions will be in rust 1.99.0
https://github.com/rust-lang/rust/pull/155697
I started working on this ~ a year ago, it tooks dozens of PRs and many hours of staring at Clang/LLVM source and assembly. The tracking issue is from 2017, and now it's finally here.
RE: https://hachyderm.io/@emmatyping/116856747913279299
zlib-rs mentioned!
Overall I'm very excited about this initiative!
a big step for f128: we fixed the windows ABI to match GCC:
https://github.com/llvm/llvm-project/pull/204887
Clang and LLVM now return f128 via the stack (with an sret), just like GCC.
This should unblock f128 as a storage-only type in rust, the actual operations still run into target feature/ABI issues on (at least) powerpc.
Zlib-rs is now used for gzip en/decoding in Firefox:
https://trifectatech.org/blog/zlib-rs-in-firefox/
This has safety and performance advantages. We also ran into a CPU bug that the Mozilla engineers ultimately found a workaround for.
I too will be at #RustWeek
Come watch my talk on stabilizing features:
https://2026.rustweek.org/talks/folkert/
And I'm happy to chat about my work on c-variadic functions, guaranteed tail calls, zlib-rs, SIMD, and any other low-level shenanigans
The `cfg_select` macro is finally stable in today's rust 1.95 release
https://blog.rust-lang.org/2026/04/16/Rust-1.95.0/
It's a flexible way of picking an implementation based on information known at compile time, like the current target or a cargo feature.
I worked on the implementation of this macro in the compiler and pushing for its stabilization (updating tests, docs, the reference, etc.)
On rust nightly you can now cfg on the current object format
https://github.com/rust-lang/rust/pull/155126
This is useful for e.g. selecting the right section name for #[link_section = "..."] and more generally for inline assembly and linker shenanigans.
The rust flate2 crate will make zlib-rs the default soon
https://github.com/rust-lang/flate2-rs/pull/542
Making zlib-rs the default is a free performance boost for the rust ecosystem. You can always switch back to the old default of miniz_oxide if you do encounter issues (though please let us know if you do, we should fix those!)
I wrote about some rustc compiler contributions that derive from our low-level systems work
https://trifectatech.org/blog/fixing-our-own-problems-in-the-rust-compiler/
Also it's already out of date, because with https://github.com/rust-lang/miri/pull/4912 that got merged earlier today we will soon be able to run our AArch64 SIMD tests with miri.
The message on an invalid target feature now suggests the most similar valid target feature names, for when it's been a while and you can't quite remember the exact target feature name.
https://github.com/rust-lang/rust/pull/153966
You can often make improvements like this by pattern matching on the surrounding code, you should give it a go when there are errors you run into that could be more helpful.
We're trying to change the f16 ABI on i386
https://groups.google.com/g/ia32-abi/c/sfytw3LHS7I
Currently the ABI says to return _Float16 in a register that does not exist (on the baseline), forcing hacks on either compilers or users.
The cfg_select! macro is now stable, and will be part of rust 1.95.
https://github.com/rust-lang/rust/pull/149783
This is a builtin replacement for cfg_if, and is really effective at cleaning up complex configuration logic.