Skip to content

abi: Emit a clean error for non-pointer x86-interrupt first argument#893

Open
Dnreikronos wants to merge 6 commits into
rust-lang:masterfrom
Dnreikronos:x86-interrupt-non-pointer-first-arg
Open

abi: Emit a clean error for non-pointer x86-interrupt first argument#893
Dnreikronos wants to merge 6 commits into
rust-lang:masterfrom
Dnreikronos:x86-interrupt-non-pointer-first-arg

Conversation

@Dnreikronos
Copy link
Copy Markdown
Contributor

@Dnreikronos Dnreikronos commented May 30, 2026

Fixes #833

An x86-interrupt function whose first argument isn't a pointer (a scalar like i64, or a by-value struct) trips GCC's interrupt attribute: libgccjit aborts with an internal error and writes no object file, which then surfaces as a baffling linker failure. LLVM only warns on the same code.

Detect the case and report it from predefine_fn as a normal compiler error, and drop the calling-convention attribute in declare_fn so libgccjit doesn't abort. The check runs on the already-lowered GCC argument types, so declare_fn reuses the ABI lowering it already does instead of computing it twice.

…st argument

GCC's `interrupt` attribute requires the first parameter of an
`x86-interrupt` function to be a pointer. When it is not (for example a
scalar `i64` or a by-value struct), libgccjit aborts codegen with an
internal error and leaves no object file behind, which then surfaces as a
confusing linker failure.

Detect that case and emit a clear diagnostic from `predefine_fn`, while
dropping the calling-convention attribute in `declare_fn` so libgccjit
does not abort. The detection runs on the already-lowered GCC argument
types, so `declare_fn` reuses the single ABI lowering it already performs
instead of computing it twice.
Check that an `x86-interrupt` function whose first argument is not a
pointer produces a clean compiler error instead of an internal libgccjit
error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

interrupt service routine should have a pointer as the first argument

1 participant