The `gpu-kernel` calling convention has several restrictions that were not enforced by the compiler until now. Add the following restrictions: 1. Cannot be async 2. Cannot be called 3. Cannot return values, return type must be `()` or `!` 4. Arguments should be primitives, i.e. passed by value. More complicated types can work when you know what you are doing, but it is rather unintuitive, one needs to know ABI/compiler internals. 5. Export name should be unmangled, either through `no_mangle` or `export_name`. Kernels are searched by name on the CPU side, having a mangled name makes it hard to find and probably almost always unintentional.
64 lines
2.3 KiB
Rust
64 lines
2.3 KiB
Rust
//@ add-minicore
|
|
//@ edition: 2021
|
|
//@ revisions: x64 x64_win i686 riscv32 riscv64 avr msp430 amdgpu nvptx
|
|
//
|
|
//@ [x64] needs-llvm-components: x86
|
|
//@ [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib
|
|
//@ [x64_win] needs-llvm-components: x86
|
|
//@ [x64_win] compile-flags: --target=x86_64-pc-windows-msvc --crate-type=rlib
|
|
//@ [i686] needs-llvm-components: x86
|
|
//@ [i686] compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib
|
|
//@ [riscv32] needs-llvm-components: riscv
|
|
//@ [riscv32] compile-flags: --target=riscv32i-unknown-none-elf --crate-type=rlib
|
|
//@ [riscv64] needs-llvm-components: riscv
|
|
//@ [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf --crate-type=rlib
|
|
//@ [avr] needs-llvm-components: avr
|
|
//@ [avr] compile-flags: --target=avr-none -C target-cpu=atmega328p --crate-type=rlib
|
|
//@ [msp430] needs-llvm-components: msp430
|
|
//@ [msp430] compile-flags: --target=msp430-none-elf --crate-type=rlib
|
|
//@ [amdgpu] needs-llvm-components: amdgpu
|
|
//@ [amdgpu] compile-flags: --target amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 --crate-type=rlib
|
|
//@ [nvptx] needs-llvm-components: nvptx
|
|
//@ [nvptx] compile-flags: --target nvptx64-nvidia-cuda --crate-type=rlib
|
|
//@ ignore-backends: gcc
|
|
#![no_core]
|
|
#![feature(
|
|
no_core,
|
|
abi_msp430_interrupt,
|
|
abi_avr_interrupt,
|
|
abi_x86_interrupt,
|
|
abi_riscv_interrupt,
|
|
abi_gpu_kernel
|
|
)]
|
|
|
|
extern crate minicore;
|
|
use minicore::*;
|
|
|
|
// We ignore this error; implementing all of the async-related lang items is not worth it.
|
|
async fn vanilla(){
|
|
//~^ ERROR requires `ResumeTy` lang_item
|
|
}
|
|
|
|
async extern "avr-interrupt" fn avr() {
|
|
//[avr]~^ ERROR functions with the "avr-interrupt" ABI cannot be `async`
|
|
}
|
|
|
|
async extern "msp430-interrupt" fn msp430() {
|
|
//[msp430]~^ ERROR functions with the "msp430-interrupt" ABI cannot be `async`
|
|
}
|
|
|
|
async extern "riscv-interrupt-m" fn riscv_m() {
|
|
//[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-m" ABI cannot be `async`
|
|
}
|
|
|
|
async extern "riscv-interrupt-s" fn riscv_s() {
|
|
//[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-s" ABI cannot be `async`
|
|
}
|
|
|
|
async extern "x86-interrupt" fn x86(_p: *mut ()) {
|
|
//[x64,x64_win,i686]~^ ERROR functions with the "x86-interrupt" ABI cannot be `async`
|
|
}
|
|
|
|
async extern "gpu-kernel" fn async_kernel() {
|
|
//[amdgpu,nvptx]~^ ERROR functions with the "gpu-kernel" ABI cannot be `async`
|
|
}
|