Login
You're viewing the techdon.dev public feed.
  • Jan 22, 2026, 4:18 PM

    Neat, `cfg_asm` made it to stable.

    I implemented this somewhere last year. It's a niche feature, but useful when writing assembly with some subtle target-specific variations. The cortex-m crate ran into this and currently uses a hack with a custom macro that duplicates the full assembly call on each condition.

    #rustlang

    exerpt from the rust 1.93.0 release blog post:

cfg attributes on asm! lines

Previously, if individual parts of a section of inline assembly needed to be cfg'd, the full asm! block would need to be repeated with and without that section. In 1.93, cfg can now be applied to individual statements within the asm! block.

```rust
asm!( // or global_asm! or naked_asm!
    "nop",
    #[cfg(target_feature = "sse2")]
    "nop",
    // ...
    #[cfg(target_feature = "sse2")]
    a = const 123, // only used on sse2
);
```
    💬 0🔄 5⭐ 20