rust-embedded / rust-embedded/riscv

`riscv-rt`: LLVM raises spurious errors in release mode for instructions of ISA extensions (e.g., M or E)

Open
#175 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.1k
Forks
200
Avg merge
11d 2h
Merged PRs (30d)
2

Description

I found this problem first in https://github.com/daniestevez/galileo-osnma/issues/23, but the following self-contained example replicates the problem: https://github.com/daniestevez/riscv/tree/debug-mul-build/riscv-rt/test-build

When this example is built with cargo build --release, I get the following:

   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling syn v1.0.109
   Compiling riscv-rt v0.12.0 (/home/daniel/riscv/riscv-rt)
   Compiling riscv v0.11.0 (/home/daniel/riscv/riscv)
   Compiling embedded-hal v1.0.0
   Compiling critical-section v1.1.2
   Compiling test-build v0.1.0 (/home/daniel/riscv/riscv-rt/test-build)
   Compiling panic-halt v0.2.0
   Compiling quote v1.0.35
   Compiling riscv-rt-macros v0.2.1 (/home/daniel/riscv/riscv-rt/macros)
error: instruction requires the following: 'M' (Integer Multiplication and Division) or 'Zmmul' (Integer Multiplication)
mul t0, t2, t0
^
error: instruction requires the following: 'M' (Integer Multiplication and Division) or 'Zmmul' (Integer Multiplication)
mul t0, t2, t0
^
    Finished release [optimized] target(s) in 2.11s

Despite the error, an executable is produced.

If I build without --release instead, I get:

   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling syn v1.0.109
   Compiling riscv-rt v0.12.0 (/home/daniel/riscv/riscv-rt)
   Compiling riscv v0.11.0 (/home/daniel/riscv/riscv)
   Compiling critical-section v1.1.2
   Compiling embedded-hal v1.0.0
   Compiling test-build v0.1.0 (/home/daniel/riscv/riscv-rt/test-build)
   Compiling panic-halt v0.2.0
   Compiling quote v1.0.35
   Compiling riscv-rt-macros v0.2.1 (/home/daniel/riscv/riscv-rt/macros)
    Finished dev [unoptimized + debuginfo] target(s) in 2.51s

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the self-contained example in riscv-rt/test-build and compare cargo build --release with the non-release build. Trace the riscv-rt build path involved in assembling instructions from ISA extensions such as M or E. Done means the release build no longer emits the reported spurious LLVM errors while preserving the expected instruction handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.