Email me

Rust errors / Everything else

Rust compiler error · checked with rustc 1.99.0

Rust error E0798: arguments for `"cmse-nonsecure-call"` function too large to pass via registers

What it meansFunctions marked as cmse-nonsecure-call place restrictions on their inputs and outputs.

What rustc prints

error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers
 --> main.rs:5:60
  |
5 |     f: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32,
  |                                                            ^^^ does not fit in the available registers
  |
  = note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit argument registers

Real output of rustc 1.99.0 compiling the official example below (2021 edition). Your names and line numbers will differ; the first line is the part to match.

E0798Everything else
Activein rustc 1.99.0
7related errors linked below

The compiler team's explanation

Functions marked as cmse-nonsecure-call place restrictions on their inputs and outputs.

is relevant.

  • inputs must fit in the 4 available 32-bit argument registers. Alignment

size 8 (i64, u64, f64).

  • outputs must either fit in 4 bytes, or be a foundational type of
  • no generics can be used in the signature

For more information, see arm's aapcs32.

Erroneous code example:

#![feature(abi_cmse_nonsecure_call)]

#[no_mangle]
pub fn test(
    f: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32,
) -> u32 {
    f(1, 2, 3, 4, 5)
}

Arguments' alignment is respected. In the example below, padding is inserted so that the u64 argument is passed in registers r2 and r3. There is then no room left for the final f32 argument

#![feature(abi_cmse_nonsecure_call)]

#[no_mangle]
pub fn test(
    f: extern "cmse-nonsecure-call" fn(u32, u64, f32) -> u32,
) -> u32 {
    f(1, 2, 3.0)
}

From rustc --explain E0798 (1.99.0), part of the Rust project, MIT or Apache-2.0. Official page.

Related errors

All 518 Rust error codes · Rust crate data · Glossary

Up next

Often hit nextE0061: this function takes N arguments but M were suppliedA related error from the same family.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ