Skip to content

Conversation

@Flakebi
Copy link
Contributor

@Flakebi Flakebi commented Dec 14, 2025

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 simple, 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.

Tracking issue: #135467
amdgpu target tracking issue: #135024

@workingjubilee, these should be all the restrictions we talked about a year ago.

cc @RDambrosio016 @kjetilkjeka for nvptx

@rustbot
Copy link
Collaborator

rustbot commented Dec 14, 2025

r? @WaffleLapkin

rustbot has assigned @WaffleLapkin.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 14, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

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 simple, 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.
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/abi/cannot-return.rs#amdgpu stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/abi/cannot-return.amdgpu/cannot-return.amdgpu.stderr`
diff of stderr:

1 error: invalid signature for `extern "gpu-kernel"` function
-   --> $DIR/cannot-return.rs:16:37
+   --> $DIR/cannot-return.rs:17:37
3    |
4 LL | extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
5    |                                     ^^^

6    |
7    = note: functions with the "gpu-kernel" ABI cannot have a return type
8 help: remove the return type
-   --> $DIR/cannot-return.rs:16:37
+   --> $DIR/cannot-return.rs:17:37
10    |
11 LL | extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
12    |                                     ^^^

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/abi/cannot-return.rs:17:37
-   --> /checkout/tests/ui/abi/cannot-return.rs:17:37
---
The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args abi/cannot-return.rs`

error in revision `amdgpu`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/abi/cannot-return.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--cfg" "amdgpu" "--check-cfg" "cfg(test,FALSE,amdgpu,nvptx)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/abi/cannot-return.amdgpu" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Cpanic=abort" "-Cforce-unwind-tables=yes" "--edition=2024" "--target" "amdgcn-amd-amdhsa" "-Ctarget-cpu=gfx900" "--crate-type=rlib" "--extern" "minicore=/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/abi/cannot-return.amdgpu/libminicore.rlib"
stdout: none
--- stderr -------------------------------
error: invalid signature for `extern "gpu-kernel"` function
##[error]  --> /checkout/tests/ui/abi/cannot-return.rs:17:37
   |
LL | extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
   |                                     ^^^
   |
   = note: functions with the "gpu-kernel" ABI cannot have a return type
help: remove the return type
  --> /checkout/tests/ui/abi/cannot-return.rs:17:37
   |
LL | extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
   |                                     ^^^

error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/abi/cannot-return.rs#amdgpu stdout end ----
---- [ui] tests/ui/abi/cannot-return.rs#nvptx stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/abi/cannot-return.nvptx/cannot-return.nvptx.stderr`
diff of stderr:

1 error: invalid signature for `extern "gpu-kernel"` function
-   --> $DIR/cannot-return.rs:16:37
+   --> $DIR/cannot-return.rs:17:37
3    |
4 LL | extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
5    |                                     ^^^

6    |
7    = note: functions with the "gpu-kernel" ABI cannot have a return type
8 help: remove the return type
-   --> $DIR/cannot-return.rs:16:37
+   --> $DIR/cannot-return.rs:17:37
10    |
11 LL | extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
12    |                                     ^^^

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/abi/cannot-return.rs:17:37
-   --> /checkout/tests/ui/abi/cannot-return.rs:17:37
---
The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args abi/cannot-return.rs`

error in revision `nvptx`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/abi/cannot-return.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--cfg" "nvptx" "--check-cfg" "cfg(test,FALSE,amdgpu,nvptx)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/abi/cannot-return.nvptx" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Cpanic=abort" "-Cforce-unwind-tables=yes" "--edition=2024" "--target" "nvptx64-nvidia-cuda" "--crate-type=rlib" "--extern" "minicore=/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/abi/cannot-return.nvptx/libminicore.rlib"
stdout: none
--- stderr -------------------------------
error: invalid signature for `extern "gpu-kernel"` function
##[error]  --> /checkout/tests/ui/abi/cannot-return.rs:17:37
   |
LL | extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
   |                                     ^^^
   |
   = note: functions with the "gpu-kernel" ABI cannot have a return type
help: remove the return type
  --> /checkout/tests/ui/abi/cannot-return.rs:17:37
   |
LL | extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
   |                                     ^^^

error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/abi/cannot-return.rs#nvptx stdout end ----
---- [ui] tests/ui/lint/lint-gpu-kernel.rs#amdgpu stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/lint-gpu-kernel.amdgpu/lint-gpu-kernel.amdgpu.stderr`
diff of stderr:

1 warning: `extern` fn uses type `()`, which is not FFI-safe
-   --> $DIR/lint-gpu-kernel.rs:35:35
+   --> $DIR/lint-gpu-kernel.rs:36:35
3    |
4 LL | extern "gpu-kernel" fn arg_zst(_: ()) { }
5    |                                   ^^ not FFI-safe

9    = note: `#[warn(improper_ctypes_definitions)]` on by default
10 
11 warning: passing type `()` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:35:35
+   --> $DIR/lint-gpu-kernel.rs:36:35
13    |
14 LL | extern "gpu-kernel" fn arg_zst(_: ()) { }
15    |                                   ^^

18    = note: `#[warn(improper_gpu_kernel_arg)]` on by default
19 
20 warning: passing type `&i32` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:40:35
+   --> $DIR/lint-gpu-kernel.rs:41:35
22    |
23 LL | extern "gpu-kernel" fn arg_ref(_: &i32) { }
24    |                                   ^^^^

26    = help: use primitive types and raw pointers to get reliable behavior
27 
28 warning: passing type `&mut i32` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:43:39
+   --> $DIR/lint-gpu-kernel.rs:44:39
30    |
31 LL | extern "gpu-kernel" fn arg_ref_mut(_: &mut i32) { }
32    |                                       ^^^^^^^^

34    = help: use primitive types and raw pointers to get reliable behavior
35 
36 warning: `extern` fn uses type `S`, which is not FFI-safe
-   --> $DIR/lint-gpu-kernel.rs:48:38
+   --> $DIR/lint-gpu-kernel.rs:49:38
38    |
39 LL | extern "gpu-kernel" fn arg_struct(_: S) { }
40    |                                      ^ not FFI-safe

42    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
43    = note: this struct has unspecified layout
44 note: the type is defined here
-   --> $DIR/lint-gpu-kernel.rs:46:1
+   --> $DIR/lint-gpu-kernel.rs:47:1
46    |
47 LL | struct S { a: i32, b: i32 }
48    | ^^^^^^^^

49 
50 warning: passing type `S` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:48:38
+   --> $DIR/lint-gpu-kernel.rs:49:38
52    |
53 LL | extern "gpu-kernel" fn arg_struct(_: S) { }
54    |                                      ^

56    = help: use primitive types and raw pointers to get reliable behavior
57 
58 warning: `extern` fn uses type `(i32, i32)`, which is not FFI-safe
-   --> $DIR/lint-gpu-kernel.rs:53:35
+   --> $DIR/lint-gpu-kernel.rs:54:35
60    |
61 LL | extern "gpu-kernel" fn arg_tup(_: (i32, i32)) { }
62    |                                   ^^^^^^^^^^ not FFI-safe

65    = note: tuples have unspecified layout
66 
67 warning: passing type `(i32, i32)` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:53:35
+   --> $DIR/lint-gpu-kernel.rs:54:35
69    |
70 LL | extern "gpu-kernel" fn arg_tup(_: (i32, i32)) { }
71    |                                   ^^^^^^^^^^

73    = help: use primitive types and raw pointers to get reliable behavior
74 
75 warning: function with the "gpu-kernel" ABI has a mangled name
-   --> $DIR/lint-gpu-kernel.rs:60:1
+   --> $DIR/lint-gpu-kernel.rs:61:1
77    |
78 LL | pub extern "gpu-kernel" fn mangled_kernel() { }
79    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:36:35
-   --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:36:35
---
The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args lint/lint-gpu-kernel.rs`

error in revision `amdgpu`: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/lint/lint-gpu-kernel.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--cfg" "amdgpu" "--check-cfg" "cfg(test,FALSE,amdgpu,nvptx)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/lint-gpu-kernel.amdgpu" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Cpanic=abort" "-Cforce-unwind-tables=yes" "--edition=2024" "--target" "amdgcn-amd-amdhsa" "-Ctarget-cpu=gfx900" "--extern" "minicore=/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/lint-gpu-kernel.amdgpu/libminicore.rlib"
stdout: none
--- stderr -------------------------------
warning: `extern` fn uses type `()`, which is not FFI-safe
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:36:35
   |
LL | extern "gpu-kernel" fn arg_zst(_: ()) { }
   |                                   ^^ not FFI-safe
   |
   = help: consider using a struct instead
   = note: tuples have unspecified layout
   = note: `#[warn(improper_ctypes_definitions)]` on by default

warning: passing type `()` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:36:35
   |
LL | extern "gpu-kernel" fn arg_zst(_: ()) { }
   |                                   ^^
   |
   = help: use primitive types and raw pointers to get reliable behavior
   = note: `#[warn(improper_gpu_kernel_arg)]` on by default

warning: passing type `&i32` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:41:35
   |
LL | extern "gpu-kernel" fn arg_ref(_: &i32) { }
   |                                   ^^^^
   |
   = help: use primitive types and raw pointers to get reliable behavior

warning: passing type `&mut i32` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:44:39
   |
LL | extern "gpu-kernel" fn arg_ref_mut(_: &mut i32) { }
   |                                       ^^^^^^^^
   |
   = help: use primitive types and raw pointers to get reliable behavior

warning: `extern` fn uses type `S`, which is not FFI-safe
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:49:38
   |
LL | extern "gpu-kernel" fn arg_struct(_: S) { }
   |                                      ^ not FFI-safe
   |
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
note: the type is defined here
  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:47:1
   |
LL | struct S { a: i32, b: i32 }
   | ^^^^^^^^

warning: passing type `S` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:49:38
   |
LL | extern "gpu-kernel" fn arg_struct(_: S) { }
   |                                      ^
   |
   = help: use primitive types and raw pointers to get reliable behavior

warning: `extern` fn uses type `(i32, i32)`, which is not FFI-safe
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:54:35
   |
LL | extern "gpu-kernel" fn arg_tup(_: (i32, i32)) { }
   |                                   ^^^^^^^^^^ not FFI-safe
   |
   = help: consider using a struct instead
   = note: tuples have unspecified layout

warning: passing type `(i32, i32)` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:54:35
   |
LL | extern "gpu-kernel" fn arg_tup(_: (i32, i32)) { }
   |                                   ^^^^^^^^^^
   |
   = help: use primitive types and raw pointers to get reliable behavior

warning: function with the "gpu-kernel" ABI has a mangled name
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:61:1
   |
LL | pub extern "gpu-kernel" fn mangled_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

warning: 9 warnings emitted
------------------------------------------

---- [ui] tests/ui/lint/lint-gpu-kernel.rs#amdgpu stdout end ----
---- [ui] tests/ui/lint/lint-gpu-kernel.rs#nvptx stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/lint-gpu-kernel.nvptx/lint-gpu-kernel.nvptx.stderr`
diff of stderr:

1 warning: `extern` fn uses type `()`, which is not FFI-safe
-   --> $DIR/lint-gpu-kernel.rs:35:35
+   --> $DIR/lint-gpu-kernel.rs:36:35
3    |
4 LL | extern "gpu-kernel" fn arg_zst(_: ()) { }
5    |                                   ^^ not FFI-safe

9    = note: `#[warn(improper_ctypes_definitions)]` on by default
10 
11 warning: passing type `()` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:35:35
+   --> $DIR/lint-gpu-kernel.rs:36:35
13    |
14 LL | extern "gpu-kernel" fn arg_zst(_: ()) { }
15    |                                   ^^

18    = note: `#[warn(improper_gpu_kernel_arg)]` on by default
19 
20 warning: passing type `&i32` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:40:35
+   --> $DIR/lint-gpu-kernel.rs:41:35
22    |
23 LL | extern "gpu-kernel" fn arg_ref(_: &i32) { }
24    |                                   ^^^^

26    = help: use primitive types and raw pointers to get reliable behavior
27 
28 warning: passing type `&mut i32` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:43:39
+   --> $DIR/lint-gpu-kernel.rs:44:39
30    |
31 LL | extern "gpu-kernel" fn arg_ref_mut(_: &mut i32) { }
32    |                                       ^^^^^^^^

34    = help: use primitive types and raw pointers to get reliable behavior
35 
36 warning: `extern` fn uses type `S`, which is not FFI-safe
-   --> $DIR/lint-gpu-kernel.rs:48:38
+   --> $DIR/lint-gpu-kernel.rs:49:38
38    |
39 LL | extern "gpu-kernel" fn arg_struct(_: S) { }
40    |                                      ^ not FFI-safe

42    = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
43    = note: this struct has unspecified layout
44 note: the type is defined here
-   --> $DIR/lint-gpu-kernel.rs:46:1
+   --> $DIR/lint-gpu-kernel.rs:47:1
46    |
47 LL | struct S { a: i32, b: i32 }
48    | ^^^^^^^^

49 
50 warning: passing type `S` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:48:38
+   --> $DIR/lint-gpu-kernel.rs:49:38
52    |
53 LL | extern "gpu-kernel" fn arg_struct(_: S) { }
54    |                                      ^

56    = help: use primitive types and raw pointers to get reliable behavior
57 
58 warning: `extern` fn uses type `(i32, i32)`, which is not FFI-safe
-   --> $DIR/lint-gpu-kernel.rs:53:35
+   --> $DIR/lint-gpu-kernel.rs:54:35
60    |
61 LL | extern "gpu-kernel" fn arg_tup(_: (i32, i32)) { }
62    |                                   ^^^^^^^^^^ not FFI-safe

65    = note: tuples have unspecified layout
66 
67 warning: passing type `(i32, i32)` to a function with "gpu-kernel" ABI may have unexpected behavior
-   --> $DIR/lint-gpu-kernel.rs:53:35
+   --> $DIR/lint-gpu-kernel.rs:54:35
69    |
70 LL | extern "gpu-kernel" fn arg_tup(_: (i32, i32)) { }
71    |                                   ^^^^^^^^^^

73    = help: use primitive types and raw pointers to get reliable behavior
74 
75 warning: function with the "gpu-kernel" ABI has a mangled name
-   --> $DIR/lint-gpu-kernel.rs:60:1
+   --> $DIR/lint-gpu-kernel.rs:61:1
77    |
78 LL | pub extern "gpu-kernel" fn mangled_kernel() { }
79    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:36:35
-   --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:36:35
---
The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args lint/lint-gpu-kernel.rs`

error in revision `nvptx`: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/lint/lint-gpu-kernel.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--cfg" "nvptx" "--check-cfg" "cfg(test,FALSE,amdgpu,nvptx)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/lint-gpu-kernel.nvptx" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Cpanic=abort" "-Cforce-unwind-tables=yes" "--edition=2024" "--target" "nvptx64-nvidia-cuda" "--extern" "minicore=/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/lint-gpu-kernel.nvptx/libminicore.rlib"
stdout: none
--- stderr -------------------------------
warning: `extern` fn uses type `()`, which is not FFI-safe
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:36:35
   |
LL | extern "gpu-kernel" fn arg_zst(_: ()) { }
   |                                   ^^ not FFI-safe
   |
   = help: consider using a struct instead
   = note: tuples have unspecified layout
   = note: `#[warn(improper_ctypes_definitions)]` on by default

warning: passing type `()` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:36:35
   |
LL | extern "gpu-kernel" fn arg_zst(_: ()) { }
   |                                   ^^
   |
   = help: use primitive types and raw pointers to get reliable behavior
   = note: `#[warn(improper_gpu_kernel_arg)]` on by default

warning: passing type `&i32` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:41:35
   |
LL | extern "gpu-kernel" fn arg_ref(_: &i32) { }
   |                                   ^^^^
   |
   = help: use primitive types and raw pointers to get reliable behavior

warning: passing type `&mut i32` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:44:39
   |
LL | extern "gpu-kernel" fn arg_ref_mut(_: &mut i32) { }
   |                                       ^^^^^^^^
   |
   = help: use primitive types and raw pointers to get reliable behavior

warning: `extern` fn uses type `S`, which is not FFI-safe
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:49:38
   |
LL | extern "gpu-kernel" fn arg_struct(_: S) { }
   |                                      ^ not FFI-safe
   |
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
note: the type is defined here
  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:47:1
   |
LL | struct S { a: i32, b: i32 }
   | ^^^^^^^^

warning: passing type `S` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:49:38
   |
LL | extern "gpu-kernel" fn arg_struct(_: S) { }
   |                                      ^
   |
   = help: use primitive types and raw pointers to get reliable behavior

warning: `extern` fn uses type `(i32, i32)`, which is not FFI-safe
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:54:35
   |
LL | extern "gpu-kernel" fn arg_tup(_: (i32, i32)) { }
   |                                   ^^^^^^^^^^ not FFI-safe
   |
   = help: consider using a struct instead
   = note: tuples have unspecified layout

warning: passing type `(i32, i32)` to a function with "gpu-kernel" ABI may have unexpected behavior
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:54:35
   |
LL | extern "gpu-kernel" fn arg_tup(_: (i32, i32)) { }
   |                                   ^^^^^^^^^^
   |
   = help: use primitive types and raw pointers to get reliable behavior

warning: function with the "gpu-kernel" ABI has a mangled name
##[warning]  --> /checkout/tests/ui/lint/lint-gpu-kernel.rs:61:1
   |
LL | pub extern "gpu-kernel" fn mangled_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

warning: 9 warnings emitted
------------------------------------------

---- [ui] tests/ui/lint/lint-gpu-kernel.rs#nvptx stdout end ----

failures:
    [ui] tests/ui/abi/cannot-return.rs#amdgpu
    [ui] tests/ui/abi/cannot-return.rs#nvptx
    [ui] tests/ui/lint/lint-gpu-kernel.rs#amdgpu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants