Skip to content

Merge into main branch rust-lang/rust? #89

Open

Description

@luojia65

By now developers have to compile whole custom Rust toolchain to work with xtensa isa. Is there any possibility to merge xtensa instruction set support into main branch Rust? Then developers can install them easily by using rustup toolchain add command.

Activity

  1. mcilloni commented on Oct 28, 2021

    @mcilloni

    I don't think this can be done until the Xtensa backend is merged into upstream LLVM, but I could be wrong.

  2. MabezDev commented on Oct 28, 2021

    @MabezDev
    Member

    @mcilloni is correct, Rust won't accept Xtensa support upstream without atleast an experimental backend in LLVM upstream.

    With the riscv chips, we've already upstreamed everything we can.

  3. stappersg commented on Apr 24, 2022

    @stappersg

    Where to check the status?

    URLs that I'm missing:

    • LLVM xtensa branch
    • issue that describes the merge of xtensa into LLVM
    • issue that describes the merge of "LLVM xtensa" into Rust
  4. MabezDev commented on Apr 26, 2022

    @MabezDev
    Member
  5. paulocsanz commented on Feb 12, 2023

    @paulocsanz

    espressif/llvm-project#4 implies that all of the repo's changes have been merged to upstream LLVM, although the PR hasn't been closed yet.

    What are the next steps?

  6. igrr commented on Feb 12, 2023

    @igrr

    We have indeed got the first patch set merged into LLVM, however that set of patches is not yet sufficient for a working Rust compiler.
    We will update the tracking issue with the next series of patches as soon as we post them for review. You can find the entire set of Xtensa patches here: espressif/llvm-project#62.

  7. noahbliss commented on Mar 1, 2024

    @noahbliss

    Hey guys, just wanted to ping this as it seems there is some new traction over at the tracking issue espressif/llvm-project#4 seems this might be coming pretty close

  8. jessebraham commented on Mar 1, 2024

    @jessebraham
    Member

    seems this might be coming pretty close

    My understanding (somebody can correct me if I'm wrong) is that there are still a large number of patches which need to be merged into LLVM before full Xtensa support is realized. Once this is complete, it will take time for these changes to propagate into Rust as well.

  9. SergioGasquez commented on Mar 5, 2025

    @SergioGasquez
    Member

    Quick update as we've made some progress about upstreaming our Rust patches, the following PRs were merged:

    We are still awaiting on the LLVM upstreaming effort to be able to continue upstreaming our Rust patches.

  10. Skgland commented on Aug 12, 2025

    @Skgland

    In the latest comment on the llvm upstreaming tracking issue there are no open llvm tasks only some clang task. Does that mean the LLVM upstreaming is now no longer a blocker? Or what is missing now?

  11. SergioGasquez commented on Aug 12, 2025

    @SergioGasquez
    Member

    I'm not sure if all the required functionality of LLVM is already merged upstream, but we would still need to wait for Rust to use the LLVM release that includes the Xtensa changes, which is about 6 months after release iirc

  12. 823984418 commented on Aug 22, 2025

    @823984418

    As of now, I have been trying to compile ESP32 code using the nightly compiler and have encountered the following issues:

    Directly use the xtensa-esp32-none-elf target

    [build]
    target = "xtensa-esp32-none-elf"
    

    I got

    data-layout for target `xtensa-esp32-none-elf-4712693060684062482`, `e-m:e-p:32:32-v8:8:8-i8:8:32-i16:16:32-i64:64-n32`, differs from LLVM target's `xtensa-none-elf` default layout, `
    2e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32`
    

    Use custom_target.json

    [build]
    target = "xtensa-esp32-none-elf.json"
    

    Due to the fact that some commit of LLVM (add esp32 CPU and atomic access) has not been obtained by rust/llvm yet:
    "cpu": "generic",
    -fp
    -s32c1i
    -highpriinterruptslevel7
    "max-atomic-width": 0,

    xtensa-esp32-none-elf.json:

    {
      "arch": "xtensa",
      "cpu": "generic",
      "crt-objects-fallback": "false",
      "data-layout": "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32",
      "features": "+density,+loop,+mac16,+windowed,+bool,+sext,+nsa,+clamps,+minmax,+mul32,+mul32high,+mul16,+dfpaccel,+threadptr,+div32,+dcache,+debug,+exception,+highpriinterrupts,+coprocessor,+interrupt,+rvector,+timers3,+prid,+regprotect,+miscsr",
      "emit-debug-gdb-scripts": false,
      "linker": "xtensa-esp32-elf-gcc",
      "linker-flavor": "gnu-cc",
      "llvm-target": "xtensa-none-elf",
      "max-atomic-width": 0,
      "metadata": {
        "description": "Xtensa ESP32",
        "host_tools": false,
        "std": false,
        "tier": 3
      },
      "panic-strategy": "abort",
      "relocation-model": "static",
      "target-pointer-width": "32",
      "vendor": "espressif"
    }
    

    Cannot use inline assembly

    xtensa-lx inline assembly is unsupported on this target

    This seems to be because the commit has not yet been sent upstream:

    Some other issues, but I think this is because I turned off all atomic types


    core/alloc was compiled normally, so I think we are very close to using the default compiler directly!

  13. MabezDev commented on Oct 2, 2025

    @MabezDev
    Member

    @823984418 it is indeed close, at least for building simple programs. Thanks for hint about the asm patch, I need to find some time to clean up the asm patch and submit it upstream. I'll do that soon.

  14. MabezDev commented on Oct 3, 2025

    @MabezDev
    Member

    I've opened a condensed asm! PR upstream: rust-lang#147302

  15. A-UNDERSCORE-D commented on Jun 10, 2026

    @A-UNDERSCORE-D

    so that PR was merged!

  16. MabezDev commented on Jun 12, 2026

    @MabezDev
    Member

    Last nights nightly can now build core, but to build anything useful (anything using asm) there is a further few bug fixes coming into LLVM - the good news is that almost all the changes on the Rust side are done! So we're just waiting on the some more LLVM patches now.

  17. A-UNDERSCORE-D commented on Jun 12, 2026

    @A-UNDERSCORE-D

    Is the LLVM tracking issue a good place to watch that?

  18. SergioGasquez commented on Jun 15, 2026

    @SergioGasquez
    Member

    Is the LLVM tracking issue a good place to watch that?

    Yes, see espressif/llvm-project#4 to be updated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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