What Is New in Rust 1.93
| Category | Highlights |
|---|---|
| New Features | cfg attributes on individual asm! statements; global allocator can safely use thread-local storage |
| Improvements | Bundled musl upgraded to 1.2.5, bringing a more robust DNS resolver for static Linux binaries |
| Breaking Changes | musl 1.2.4 removed legacy compatibility symbols; projects must use libc ≥ 0.2.146 for static musl builds |
How does Rust 1.93 improve static linking on musl targets?
Rust 1.93 updates the bundled musl library to version 1.2.5, which includes a modern DNS resolver and several stability fixes.
- Static binaries built for
x86_64-linux-musl,aarch64-linux-musl, andpowerpc64le-linux-muslnow benefit from faster and more reliable name resolution, especially with large DNS records. - The upgrade also removes legacy compatibility symbols that older libc versions relied on; the fix landed in
libc0.2.146. - Most teams will see no source-level changes, but CI pipelines that pin
libcbelow 0.2.146 must be updated.
Can I use thread-local storage in a global allocator in Rust 1.93?
Yes, the standard library now permits global allocators written in Rust to call thread_local! and std::thread::current without risking re-entrancy.
- The change works by routing those calls through the system allocator, eliminating the previous deadlock risk.
- This matters if you implement a custom global allocator that needs per-thread caches or thread-specific bookkeeping.
- Documentation has been updated with migration guidance; existing allocators continue to work unchanged.
How can I conditionally include inline-assembly instructions in Rust 1.93?
In Rust 1.93 you can attach #[cfg] attributes to individual statements inside an asm! block.
asm!(
"nop",
#[cfg(target_feature = "sse2")]
"nop",
#[cfg(target_feature = "sse2")]
a = const 123,
);
- This eliminates the need to duplicate entire
asm!blocks for each configuration. - It works with
global_asm!andnaked_asm!as well. - Watch out for macro hygiene when mixing cfg-enabled operands and regular inputs.
What steps are required to migrate projects after the musl breaking change?
Projects that produce static musl binaries must ensure they depend on libc 0.2.146 or newer.
- Update the
libccrate version inCargo.toml(e.g.,libc = "0.2.146"). - Run
cargo cleanand rebuild to pick up the new symbols. - Verify that any downstream crates also respect the updated
libcversion; most have already migrated.
Frequently Asked Questions
Do I need to change my code to benefit from the musl 1.2.5 DNS improvements?
No code changes are required; the improvements are baked into the bundled musl library.
Is the new thread-local support in global allocators stable?
Yes, it is a stable API change in the standard library.
Can I still use #[cfg] on whole asm! blocks as before?
Yes, the previous behavior remains unchanged; you now have the additional option to target individual statements.
What command updates Rust to the 1.93 release?
Run rustup update stable in your terminal.
Will older crates that depend on legacy musl symbols fail to compile?
They will fail unless they have already upgraded to libc 0.2.146 or later.
Is there an example of using thread_local! inside a global allocator?
The documentation shows a custom allocator that declares thread_local! static buffers and calls std::thread::current safely.