avr-hal: LLVM ERROR: Not supported instr

I am using this example: https://github.com/Rahix/avr-hal/tree/d17a441a667dd65e5a9be75b0e71d1beadf93e84/boards/arduino-uno

I have also executed rustup component add rust-src

And it fails to compile with this error:

» cargo +nightly build --example uno-blink
   Compiling compiler_builtins v0.1.39
   Compiling nb v1.0.0
   Compiling cfg-if v0.1.10
   Compiling bare-metal v0.2.5
   Compiling void v1.0.2
   Compiling vcell v0.1.3
   Compiling ufmt-write v0.1.0 (https://github.com/Rahix/ufmt.git?rev=12225dc1678e42fecb0e8635bf80f501e24817d9#12225dc1)
   Compiling panic-halt v0.2.0
   Compiling nb v0.1.3
   Compiling avr-device v0.2.3
   Compiling ufmt v0.1.0 (https://github.com/Rahix/ufmt.git?rev=12225dc1678e42fecb0e8635bf80f501e24817d9#12225dc1)
   Compiling embedded-hal v0.2.4
LLVM ERROR: Not supported instr: <MCInst 258 <MCOperand Reg:1> <MCOperand Imm:15> <MCOperand Reg:40>>
error: could not compile `compiler_builtins`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

My versions:

  • rust
» rustup --version
rustup 1.23.1 (2020-12-03)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.51.0-nightly (c8915eebe 2021-01-07)`
  • avr
» avr-gcc --version
avr-gcc (Homebrew AVR GCC 9.3.0) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • And macos 10.14

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 23 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I found it’s easiest to create a file called rust-toolchain in your projects directory with following content

[toolchain]
channel = "nightly-2021-01-07"
components = ["rust-src"]

afterwards you can simply run cargo build and all is fine 😃

We have identified the problem, let’s see how it will be solved. In the meantime, for anyone stumbling upon this issue: Just use an older toolchain like nightly-2021-01-07 for now. With rustup, installing and using it will be as easy as:

rustup toolchain install nightly-2021-01-07
# ...
cargo +nightly-2021-01-07 build

This is huge, thank you so much for your efforts here @Patryk27!

For anyone that needs this information:

Rust nightly-2020-11-20 is the last version that was built that both doesn’t have this issue, and had a successful rls build.

So, if you are (for example) looking for a release where you can work with avr-hal and have VSCode give you useful autocomplete and highlighting, 2020-11-20 is the version to use.

Sources: toolsuite build info and rustdatehash

One more solution to rls problem (2021-01-07 does not have rls component): rls can be replaced with https://github.com/rust-analyzer/rust-analyzer

@ssmgcode you need to add the rust-src component for the particular toolchain. I believe you can use the same +«toolchain-version» trick you can use with other Rust commands.