rust-lang / rust-lang/rust

Most `extern "*-interrupt-*" fn` should enforce 0-sized signatures

Open
#132,837 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ABI A-hardware-interrupts A-LLVM C-bug O-AVR O-msp430 O-riscv T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code with rustc --target riscv64gc-unknown-linux-gnu rust_code.rs:

#![feature(abi_riscv_interrupt)]
pub extern "riscv-interrupt-m" fn interrupt_machine(_a: u8, _b: u8, _c: u8) {
}

pub extern "riscv-interrupt-s" fn interrupt_supervisor(_a: u8, _b: u8, _c: u8) {
}

pub fn main() {
    interrupt_machine(1, 2, 3);
    interrupt_supervisor(4, 5, 6);
}

I expected to see rustc catch this invalid signature.

Instead, this happened:

rustc-LLVM ERROR: Functions with the interrupt attribute cannot have arguments!

My understanding is that the same story applies for non-x86 interrupt ABIs like MSP430's.

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (a0d98ff0e 2024-10-31)
binary: rustc
commit-hash: a0d98ff0e5b6e1f2c63fd26f68484792621b235c
commit-date: 2024-10-31
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

@rustbot label: +A-hardware-interrupts +A-LLVM +O-riscv +O-msp430 +A-ABI +T-compiler

Related Issues

Contributor guide

Open the contributing guide

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

Reproduce the issue with the provided rustc command and the riscv-interrupt-m and riscv-interrupt-s functions, then compare the behavior with the related issues 38487, 111889, 132835, and 132836. Trace how rustc validates extern interrupt ABI signatures and ensure invalid non-zero-sized signatures produce a compiler diagnostic instead of reaching the LLVM error; check the related MSP430 ABI behavior as well.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
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.