rust-lang / rust-lang/rust

ICE: invalid abi for platform should have reported an error: "efiapi"

Open
#145,370 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-ICE P-medium regression-from-stable-to-stable T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code

I think a cherry-pick into 1.89.0 (7e0eb3bc6df7199c908eb095ff63635e4c2239b0) produces a valid ICE error message due to calling a function with an unsupported abi. Though, the place where the expected error should be generated is only a warning in 1.89. I think the warning will be an error in 1.90.

# Setup rust 1.89.0
git clone https://github.com/rust-osdev/uefi-rs.git
cd uefi-rs/uefi
cargo build

Generates warnings like:

warning: the calling convention "efiapi" is not supported on this target
  --> uefi-raw/src/protocol/acpi.rs:9:29
   |
9  |       pub install_acpi_table: unsafe extern "efiapi" fn(
   |  _____________________________^
10 | |         this: *const Self,
11 | |         acpi_table_buffer: *const c_void,
12 | |         acpi_table_size: usize,
13 | |         table_key: *mut usize,
14 | |     ) -> Status,
   | |_______________^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
   = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default

And if the function is called, generates an ICE:

error: internal compiler error: invalid abi for platform should have reported an error: "efiapi"
  --> uefi/src/proto/acpi.rs:53:13
   |
53 |             (self.0.install_acpi_table)(&self.0, acpi_table_ptr, acpi_table_size, &mut table_key)
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |

And a simplified reproducer:

pub struct Foo {
        x: extern "efiapi" fn(),
}

pub fn foo_func(f: Foo) {
        (f.x)();
}
Meta

rustc --version --verbose:

rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: powerpc64le-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7
Error output
note: delayed at compiler/rustc_hir_typeck/src/callee.rs:162:39 - disabled backtrace
   --> uefi/src/proto/pci/root_bridge.rs:127:13
    |
127 | /             (self.io_access.read)(
128 | |                 self.proto,
129 | |                 width_mode,
130 | |                 addr.into(),
131 | |                 data.len(),
132 | |                 data.as_mut_ptr().cast(),
133 | |             )
    | |_____________^

error: internal compiler error: invalid abi for platform should have reported an error: "efiapi"
   --> uefi/src/proto/pci/root_bridge.rs:150:13
    |
150 | /             (self.io_access.write)(
151 | |                 self.proto,
152 | |                 width_mode,
153 | |                 addr.into(),
154 | |                 data.len(),
155 | |                 data.as_ptr().cast(),
156 | |             )
    | |_____________^
    |

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 ICE with the simplified extern "efiapi" function-pointer example, then compare it with the uefi-rs build cases in uefi-raw/src/protocol/acpi.rs and uefi/src/proto/acpi.rs. Start at the delayed type-checking location in compiler/rustc_hir_typeck/src/callee.rs:162:39; done means the unsupported ABI produces a reported compiler error rather than an ICE.

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.