Skip to content

ICE: Architecture x86_64 does not support GpuKernel calling convention #138738

Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(abi_ptx)]
fn main() {
    let non_secure_function = unsafe {
        core::mem::transmute::<usize, extern "ptx-kernel" fn(i32, i32, i32, i32) -> i32>(0x10000004)
    };
    let mut toto = 5;
    toto += non_secure_function(toto, 2, 3, 5);
}

original:

// gate-test-abi_c_cmse_nonsecure_call
#[allow(unsupported_fn_ptr_calling_conventions)]
fn main() {
    let non_secure_function = unsafe {
        core::mem::transmute::<usize, extern "ptx-kernel" fn(i32, i32, i32, i32) -> i32>(
            //~^ ERROR [E0658]
            0x10000004,
        )
    };
    let mut toto = 5;
    toto += non_secure_function(toto, 2, 3, 5);
}

Version information

rustc 1.87.0-nightly (70237a8cb 2025-03-20)
binary: rustc
commit-hash: 70237a8cb905fc48ed6148d2f2dba756535a5940
commit-date: 2025-03-20
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

Conv::GpuKernel => {
if arch == "amdgpu" {
llvm::AmdgpuKernel
} else if arch == "nvptx64" {
llvm::PtxKernel
} else {
panic!("Architecture {arch} does not support GpuKernel calling convention");
}
}
Conv::AvrInterrupt => llvm::AvrInterrupt,
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
Conv::Msp430Intr => llvm::Msp430Intr,

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(abi_ptx)

Program output

warning: the calling convention "ptx-kernel" is not supported on this target
 --> /tmp/icemaker_global_tempdir.5RiKb1aS18Mo/rustc_testrunner_tmpdir_reporting.vC9uw8ssapd6/mvce.rs:3:39
  |
3 |         core::mem::transmute::<usize, extern "ptx-kernel" fn(i32, i32, i32, i32) -> i32>(0x10000004)
  |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = 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

warning: value assigned to `toto` is never read
 --> /tmp/icemaker_global_tempdir.5RiKb1aS18Mo/rustc_testrunner_tmpdir_reporting.vC9uw8ssapd6/mvce.rs:6:5
  |
6 |     toto += non_secure_function(toto, 2, 3, 5);
  |     ^^^^
  |
  = help: maybe it is overwritten before being read?
  = note: `#[warn(unused_assignments)]` on by default


thread 'rustc' panicked at compiler/rustc_codegen_llvm/src/abi.rs:680:21:
Architecture x86_64 does not support GpuKernel calling convention
stack backtrace:
   0:     0x79ada6830003 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h879fffc75fdea4ca
   1:     0x79ada7005a58 - core::fmt::write::h4872d0510b46ecc6
   2:     0x79ada83c5751 - std::io::Write::write_fmt::hbd981463303fde9c
   3:     0x79ada682fe62 - std::sys::backtrace::BacktraceLock::print::hcf9aac352b7eac82
   4:     0x79ada683271a - std::panicking::default_hook::{{closure}}::hedab5cca755b9743
   5:     0x79ada683229f - std::panicking::default_hook::h1fcdc03d8389a618
   6:     0x79ada589bf20 - std[c9702a20cd481928]::panicking::update_hook::<alloc[49ba14cf04ef8a65]::boxed::Box<rustc_driver_impl[8a35e1c27f9e238f]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x79ada6832f93 - std::panicking::rust_panic_with_hook::ha0e51fe2d11054e2
   8:     0x79ada6832c8a - std::panicking::begin_panic_handler::{{closure}}::hc5cbb737c532592b
   9:     0x79ada68304d9 - std::sys::backtrace::__rust_end_short_backtrace::hf92f52b58bf43613
  10:     0x79ada683294d - __rustc[bd409a3545e2ef9f]::rust_begin_unwind
  11:     0x79ada326b750 - core::panicking::panic_fmt::hfabf34321fa7b35b
  12:     0x79ada72be178 - <rustc_target[4ee8a907d88b8e02]::callconv::FnAbi<rustc_middle[d57d21cb3f97984b]::ty::Ty> as rustc_codegen_llvm[3ffc3f5f98c79521]::abi::FnAbiLlvmExt>::apply_attrs_callsite
  13:     0x79ada72bbcbf - <rustc_codegen_llvm[3ffc3f5f98c79521]::builder::GenericBuilder<rustc_codegen_llvm[3ffc3f5f98c79521]::context::FullCx> as rustc_codegen_ssa[91b4b525e278393]::traits::builder::BuilderMethods>::call
  14:     0x79ada72b521c - <rustc_codegen_ssa[91b4b525e278393]::mir::block::TerminatorCodegenHelper>::do_call::<rustc_codegen_llvm[3ffc3f5f98c79521]::builder::GenericBuilder<rustc_codegen_llvm[3ffc3f5f98c79521]::context::FullCx>>
  15:     0x79ada3f29b53 - <rustc_codegen_ssa[91b4b525e278393]::mir::FunctionCx<rustc_codegen_llvm[3ffc3f5f98c79521]::builder::GenericBuilder<rustc_codegen_llvm[3ffc3f5f98c79521]::context::FullCx>>>::codegen_terminator
  16:     0x79ada80b87a9 - rustc_codegen_ssa[91b4b525e278393]::mir::codegen_mir::<rustc_codegen_llvm[3ffc3f5f98c79521]::builder::GenericBuilder<rustc_codegen_llvm[3ffc3f5f98c79521]::context::FullCx>>
  17:     0x79ada809c351 - rustc_codegen_llvm[3ffc3f5f98c79521]::base::compile_codegen_unit::module_codegen
  18:     0x79ada8165995 - <rustc_codegen_llvm[3ffc3f5f98c79521]::LlvmCodegenBackend as rustc_codegen_ssa[91b4b525e278393]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  19:     0x79ada81622d7 - <rustc_codegen_llvm[3ffc3f5f98c79521]::LlvmCodegenBackend as rustc_codegen_ssa[91b4b525e278393]::traits::backend::CodegenBackend>::codegen_crate
  20:     0x79ada8191405 - <rustc_interface[1dd91e2665f7489c]::queries::Linker>::codegen_and_build_linker
  21:     0x79ada818ecb0 - rustc_interface[1dd91e2665f7489c]::passes::create_and_enter_global_ctxt::<core[fb772cbc65c9782a]::option::Option<rustc_interface[1dd91e2665f7489c]::queries::Linker>, rustc_driver_impl[8a35e1c27f9e238f]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  22:     0x79ada813fcaf - rustc_interface[1dd91e2665f7489c]::interface::run_compiler::<(), rustc_driver_impl[8a35e1c27f9e238f]::run_compiler::{closure#0}>::{closure#1}
  23:     0x79ada7fbbfc8 - std[c9702a20cd481928]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1dd91e2665f7489c]::util::run_in_thread_with_globals<rustc_interface[1dd91e2665f7489c]::util::run_in_thread_pool_with_globals<rustc_interface[1dd91e2665f7489c]::interface::run_compiler<(), rustc_driver_impl[8a35e1c27f9e238f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  24:     0x79ada7fbc8b4 - <<std[c9702a20cd481928]::thread::Builder>::spawn_unchecked_<rustc_interface[1dd91e2665f7489c]::util::run_in_thread_with_globals<rustc_interface[1dd91e2665f7489c]::util::run_in_thread_pool_with_globals<rustc_interface[1dd91e2665f7489c]::interface::run_compiler<(), rustc_driver_impl[8a35e1c27f9e238f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[fb772cbc65c9782a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x79ada7fbdcb7 - std::sys::pal::unix::thread::Thread::new::thread_start::h2500dd9e4f747739
  26:     0x79ada1ea370a - <unknown>
  27:     0x79ada1f27aac - <unknown>
  28:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.87.0-nightly (70237a8cb 2025-03-20) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(abi_ptx) -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 2 warnings emitted


@rustbot label +F-abi_ptx

Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 20, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 20, 2025
  3. matthiaskrgr commented on Mar 20, 2025

    @matthiaskrgr
    MemberAuthor

    bisects to is #136807

  4. Noratrieb commented on Mar 20, 2025

    @Noratrieb
    Member

    @workingjubilee looks like you forgot a check

  5. matthiaskrgr commented on Mar 21, 2025

    @matthiaskrgr
    MemberAuthor

    smaller

    #![feature(abi_ptx)]
    fn main() {
        let a = unsafe { core::mem::transmute::<usize, extern "ptx-kernel" fn(i32)>(4) }(2);
    }
  6. added
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    A-ABIArea: Concerning the application binary interface (ABI)
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 30, 2025
  7. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on May 2, 2025
  8. added a commit that references this issue on Jun 6, 2025
    8b8eff5
  9. added a commit that references this issue on Jun 23, 2025
    ff1636b
  10. added a commit that references this issue on Jun 24, 2025
    b3eccef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-ABIArea: Concerning the application binary interface (ABI)A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.F-abi_ptx`#![feature(abi_ptx)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions