MISSING_GPU_KERNEL_EXPORT_NAME

Static MISSING_GPU_KERNEL_EXPORT_NAME 

Source
static MISSING_GPU_KERNEL_EXPORT_NAME: &Lint
Expand description

The missing_gpu_kernel_export_name lint detects gpu-kernel functions that have a mangled name.

§Example

extern "gpu-kernel" fn kernel() { }

This will produce:

warning: function with the "gpu-kernel" ABI has a mangled name
 --> t.rs:1:1
  |
1 | extern "gpu-kernel" fn kernel() {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: use `unsafe(no_mangle)` or `unsafe(export_name = "<name>")`
  = note: mangled names make it hard to find the kernel, this is usually not intended
  = note: `#[warn(missing_gpu_kernel_export_name)]` on by default

§Explanation

gpu-kernel functions are usually searched by name in the compiled file. A mangled name is usually unintentional as it would need to be searched by the mangled name.

To use an unmangled name for the kernel, either no_mangle or export_name can be used.

// Can be found by the name "kernel"
#[unsafe(no_mangle)]
extern "gpu-kernel" fn kernel() { }

// Can be found by the name "new_name"
#[unsafe(export_name = "new_name")]
extern "gpu-kernel" fn other_kernel() { }