Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid spurious errors from LLVM #176

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions riscv-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- Patch in assembly code to avoid spurious errors from LLVM

## [v0.12.0] - 2024-01-14

Expand Down
4 changes: 2 additions & 2 deletions riscv-rt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fn parse_target(target: &str, cargo_flags: &str) -> (u32, HashSet<char>) {
.unwrap();

let mut extensions: HashSet<char> = arch.chars().skip_while(|c| c.is_ascii_digit()).collect();
// get rid of the 'g' shorthand extension
if extensions.remove(&'g') {
// expand the 'g' shorthand extension
if extensions.contains(&'g') {
extensions.insert('i');
extensions.insert('m');
extensions.insert('a');
Expand Down
19 changes: 19 additions & 0 deletions riscv-rt/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ macro_rules! cfg_global_asm {
};
}

// Provisional patch to avoid LLVM spurious errors when compiling in release mode.
// This patch is somewhat hardcoded and relies on the fact that the rustc compiler
// only supports a limited combination of ISA extensions. This patch should be
// removed when LLVM fixes the issue. Alternatively, it must be updated when rustc
// supports more ISA extension combinations.
//
// Related issues:
// - https://github.com/rust-embedded/riscv/issues/175
// - https://github.com/rust-lang/rust/issues/80608
// - https://github.com/llvm/llvm-project/issues/61991
cfg_global_asm!(
#[cfg(all(riscv32, riscvm))]
".attribute arch, \"rv32im\"",
#[cfg(all(riscv64, riscvm, not(riscvg)))]
".attribute arch, \"rv64im\"",
#[cfg(all(riscv64, riscvg))]
".attribute arch, \"rv64g\"",
);

// Entry point of all programs (_start). It initializes DWARF call frame information,
// the stack pointer, the frame pointer (needed for closures to work in start_rust)
// and the global pointer. Then it calls _start_rust.
Expand Down
Loading