Skip to content

build: release build fails on esp toolchains 1.94.0.0+ (LLVM 21 "Cannot select" regression) #16

Description

@rkuester

Summary

cargo build --release fails during LLVM instruction selection on the
current esp Rust toolchains (1.94.0.0 through 1.95.0.0). The build aborts
before linking with:

rustc-LLVM ERROR: Cannot select: ... i32 = XtensaISD::PCREL_WRAPPER
  TargetConstantPool:i32<@anon... = private unnamed_addr constant
  [14 x i8] c"ADC Read Error", align 1> 0
In function: ..._usb_task_task0...poll

The Xtensa backend can't lower a PC-relative reference to an aggregate
constant in the constant pool. Here that's the "ADC Read Error" string
literal in src/control/adc.rs, pulled into the USB task by inlining.

Details

  • Only optimized codegen is affected. cargo check and cargo clippy
    pass; debug builds (opt-level 0) get through codegen and only fail at
    link for unrelated reasons.
  • Independent of the release profile knobs: reproduces with lto set to
    fat, thin, or off, and at opt-level 2, 3, and s.
  • Target: xtensa-esp32s3-none-elf (our no_std firmware).

Toolchain bisect

esp toolchain bundled LLVM result
1.93.0.0 20.1.1 builds
1.94.0.2 21.1.3 fails
1.95.0.0 21.1.3 fails

The regression tracks the esp-rs fork's LLVM 20 to 21 bump.

Known upstream regression

Workaround

Pin the esp toolchain to the last good version:

espup install --toolchain-version 1.93.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions