Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dd684bb
update rustc dev guide example
Sa4dUs May 25, 2026
9818317
show success message
Sa4dUs May 26, 2026
0bb5758
minor fixes
Sa4dUs May 27, 2026
9dc513d
add docs
Sa4dUs May 29, 2026
3cb1c43
Rollup merge of #157126 - Dnreikronos:avoid-redundant-derive-note-on-…
JonathanBrouwer May 30, 2026
9623f17
Rollup merge of #151690 - xtqqczze:env-var, r=jhpratt
JonathanBrouwer May 30, 2026
bac1f0b
Rollup merge of #155826 - devnexen:uefi_stdio_fix, r=jhpratt
JonathanBrouwer May 30, 2026
59903bc
Rollup merge of #156109 - Paladynee:lib/cast-slice-improvements, r=jh…
JonathanBrouwer May 30, 2026
9cdabae
Rollup merge of #156642 - Sa4dUs:offload-macro, r=ZuseZ4
JonathanBrouwer May 30, 2026
5ec44e9
Rollup merge of #156823 - ajasad25:rustdoc-self-submodule-tests-84827…
JonathanBrouwer May 30, 2026
af29750
Rollup merge of #157162 - cjgillot:as_mut_unwrap, r=mejrs
JonathanBrouwer May 30, 2026
7975b94
Auto merge of #157174 - JonathanBrouwer:rollup-XgLtev4, r=JonathanBro…
bors May 30, 2026
c372723
Auto merge of #157160 - pbkx:issue-87290-closure-lifetime-test, r=Kiv…
bors May 31, 2026
4773de1
Auto merge of #157175 - Unique-Usman:ua/syntatic, r=JonathanBrouwer,K…
bors May 31, 2026
30397a3
Auto merge of #157179 - nnethercote:compare_names, r=GuillaumeGomez
bors May 31, 2026
9d3a5e7
Auto merge of #155336 - Walnut356:lldb_init_module, r=jieyouxu
bors Jun 1, 2026
9b701f6
Auto merge of #153957 - xonx4l:stdarch-verify, r=Kobzol,bjorn3
bors Jun 1, 2026
9026b30
Auto merge of #156649 - cjgillot:move-async-expand, r=nnethercote
bors Jun 1, 2026
ace5a6e
Auto merge of #157094 - khyperia:UnevaluatedConstKind, r=BoxyUwU
bors Jun 1, 2026
3a3fee0
Remove `#[skip_arg]` references from rustc-dev-guide
GuillaumeGomez May 28, 2026
1046e6c
Rollup merge of #157035 - amandasystems:region-values-either, r=jackh726
JonathanBrouwer Jun 2, 2026
bf4dd8e
Rollup merge of #157070 - GuillaumeGomez:rm-skip_arg, r=JonathanBrouwer
JonathanBrouwer Jun 2, 2026
6b7100e
Rollup merge of #157137 - taiki-e:powerpcspe, r=RalfJung
JonathanBrouwer Jun 2, 2026
e6a73c8
Rollup merge of #157215 - JonathanBrouwer:repr-target-checking3, r=mejrs
JonathanBrouwer Jun 2, 2026
eaf6625
Rollup merge of #157235 - bb1yd:improve-colon-suggestion, r=mejrs
JonathanBrouwer Jun 2, 2026
6fb6243
Rollup merge of #157321 - mu001999-contrib:nit, r=JonathanBrouwer
JonathanBrouwer Jun 2, 2026
aae6e7a
Rollup merge of #157324 - bjorn3:eii_error_test, r=jdonszelmann
JonathanBrouwer Jun 2, 2026
867b069
Auto merge of #157329 - JonathanBrouwer:rollup-DyoIgRF, r=JonathanBro…
bors Jun 2, 2026
efafa3b
Auto merge of #154144 - Human9000-bit:const-prop-transmute-async-fix,…
bors Jun 3, 2026
4ea6622
Auto merge of #157349 - weihanglo:update-cargo, r=weihanglo
bors Jun 3, 2026
5b4eab9
Auto merge of #148799 - ohadravid:windows-thread-local-dtors-using-fl…
bors Jun 3, 2026
1602179
Prepare for merging from rust-lang/rust
tshepang Jun 4, 2026
727bce5
Merge ref '49b19d32b9f0' from rust-lang/rust
tshepang Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c58275e0369d09fc3959b8ba87dcbcbe73797465
49b19d32b9f01a5aa606f3bf2e90e6e0aa462c03
8 changes: 0 additions & 8 deletions src/diagnostics/diagnostic-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ translatable error messages are written and how they are generated.

Every field of the `Diagnostic` which does not have an annotation is
available in Fluent messages as a variable, like `field_name` in the example above.
Fields can be annotated `#[skip_arg]` if this is undesired.

Using the `#[primary_span]` attribute on a field (that has type `Span`)
indicates the primary span of the diagnostic which will have the main message of the diagnostic.
Expand Down Expand Up @@ -172,9 +171,6 @@ tcx.dcx().emit_err(FieldAlreadyDeclared {
- `#[primary_span]` (_Optional_)
- _Applied to `Span` fields on `Subdiagnostic`s.
- Indicates the primary span of the diagnostic.
- `#[skip_arg]` (_Optional_)
- _Applied to any field._
- Prevents the field from being provided as a diagnostic argument.

## `#[derive(Subdiagnostic)]`
It is common in the compiler to write a function that conditionally adds a
Expand Down Expand Up @@ -225,7 +221,6 @@ A primary span is only necessary for a label or suggestion, which can not be spa

Every field of the type/variant which does not have an annotation is available
in Fluent messages as a variable.
Fields can be annotated `#[skip_arg]` if this is undesired.

Like `Diagnostic`, `Subdiagnostic` supports `Option<T>` and `Vec<T>` fields.

Expand Down Expand Up @@ -348,9 +343,6 @@ to multipart suggestions)
- `#[applicability]` (_Optional_; only applicable to (simple and multipart) suggestions)
- _Applied to `Applicability` fields._
- Indicates the applicability of the suggestion.
- `#[skip_arg]` (_Optional_)
- _Applied to any field._
- Prevents the field from being provided as a diagnostic argument.

[defn]: https://github.com/rust-lang/rust/blob/6201eabde85db854c1ebb57624be5ec699246b50/compiler/rustc_hir_analysis/src/errors.rs#L68-L77
[use]: https://github.com/rust-lang/rust/blob/f1112099eba41abadb6f921df7edba70affe92c5/compiler/rustc_hir_analysis/src/collect.rs#L823-L827
Expand Down
83 changes: 29 additions & 54 deletions src/offload/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,50 @@ We currently work on launching the following Rust kernel on the GPU.
To follow along, copy it to a `src/lib.rs` file.

```rust
#![feature(abi_gpu_kernel)]
#![feature(rustc_attrs)]
#![feature(core_intrinsics)]
#![allow(internal_features)]
#![feature(gpu_offload)]
#![cfg_attr(target_os = "linux", feature(core_intrinsics))]
#![cfg_attr(target_arch = "amdgpu", feature(stdarch_amdgpu, abi_gpu_kernel))]
#![cfg_attr(target_arch = "nvptx64", feature(stdarch_nvptx, abi_gpu_kernel))]
#![no_std]

#[cfg(target_os = "linux")]
extern crate libc;
#[cfg(target_os = "linux")]
use libc::c_char;

#[cfg(target_os = "linux")]
use core::mem;
use core::offload::offload_kernel;

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
loop {}
}

#[cfg(target_os = "linux")]
#[unsafe(no_mangle)]
#[inline(never)]
fn main() {
let array_c: *mut [f64; 256] =
unsafe { libc::calloc(256, (mem::size_of::<f64>()) as libc::size_t) as *mut [f64; 256] };
let output = c"The first element is zero %f\n";
let output2 = c"The first element is NOT zero %f\n";
let output3 = c"The second element is %f\n";
unsafe {
let val: *const c_char = if (*array_c)[0] < 0.1 {
output.as_ptr()
} else {
output2.as_ptr()
};
libc::printf(val, (*array_c)[0]);
}
#[cfg(target_arch = "amdgpu")]
use core::arch::amdgpu::{workgroup_id_x as block_idx_x, workitem_id_x as thread_idx_x};
#[cfg(target_arch = "nvptx64")]
use core::arch::nvptx::{
_block_dim_x as block_dim_x, _block_idx_x as block_idx_x, _thread_idx_x as thread_idx_x,
};

#[offload_kernel]
fn kernel(x: *mut [f64; 256]) {
unsafe {
kernel(array_c);
}
core::hint::black_box(&array_c);
unsafe {
let val: *const c_char = if (*array_c)[0] < 0.1 {
output.as_ptr()
} else {
output2.as_ptr()
};
libc::printf(val, (*array_c)[0]);
libc::printf(output3.as_ptr(), (*array_c)[1]);
let n = (*x).len();
let i = (thread_idx_x() + block_idx_x() * block_dim_x()) as usize;
if i < n {
(*x)[i] = i as f64;
}
}
}

#[inline(never)]
unsafe fn kernel(x: *mut [f64; 256]) {
core::intrinsics::offload(kernel_1, [256, 1, 1], [32, 1, 1], (x,))
}

#[cfg(target_os = "linux")]
unsafe extern "C" {
pub fn kernel_1(array_b: *mut [f64; 256]);
}

#[cfg(not(target_os = "linux"))]
#[unsafe(no_mangle)]
#[inline(never)]
#[rustc_offload_kernel]
pub extern "gpu-kernel" fn kernel_1(x: *mut [f64; 256]) {
unsafe { (*x)[0] = 21.0 };
fn main() {
let mut x = [0.0f64; 256];
core::intrinsics::offload::<_, _, ()>(kernel, [256, 1, 1], [1, 1, 1], (&mut x as *mut [f64; 256],));
for i in 0..x.len() {
assert_eq!(x[i], i as f64);
}
unsafe { libc::printf(c"all checks passed".as_ptr()); }
}
```

Expand All @@ -84,7 +61,7 @@ So either substitute clang/lld invocations below with absolute path, or set your
First we generate the device (GPU) code.

<div class="warning">

Replace the `target-cpu` (gfx90a) with the right code for your GPU. These are often referred to as "LLVM target names"[^list].

</div>
Expand All @@ -102,7 +79,7 @@ This call also does a lot of work and generates multiple intermediate files for
While we integrated most offload steps into rustc by now, one binary invocation still remains for now:

```
"clang-linker-wrapper" "--should-extract=gfx90a" "--device-compiler=amdgcn-amd-amdhsa=-g" "--device-compiler=amdgcn-amd-amdhsa=-save-temps=cwd" "--device-linker=amdgcn-amd-amdhsa=-lompdevice" "--host-triple=x86_64-unknown-linux-gnu" "--save-temps" "--linker-path=/ABSOlUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/lld/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-pie" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "bare" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/ABSOLUTE_PATH_TO/crtbeginS.o" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/x86_64-unknown-linux-gnu" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21/lib/x86_64-unknown-linux-gnu" "-L/lib/../lib64" "-L/usr/lib64" "-L/lib" "-L/usr/lib" "target/<GPU_DIR>/release/host.o" "-lstdc++" "-lm" "-lomp" "-lomptarget" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib" "-lgcc_s" "-lgcc" "-lpthread" "-lc" "-lgcc_s" "-lgcc" "/ABSOLUTE_PATH_TO/crtendS.o" "/lib/../lib64/crtn.o"
"clang-linker-wrapper" "--should-extract=gfx90a" "--device-compiler=amdgcn-amd-amdhsa=-g" "--device-compiler=amdgcn-amd-amdhsa=-save-temps=cwd" "--device-linker=amdgcn-amd-amdhsa=-lompdevice" "--host-triple=x86_64-unknown-linux-gnu" "--save-temps" "--linker-path=/ABSOlUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/lld/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-pie" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "main" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/ABSOLUTE_PATH_TO/crtbeginS.o" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/x86_64-unknown-linux-gnu" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21/lib/x86_64-unknown-linux-gnu" "-L/lib/../lib64" "-L/usr/lib64" "-L/lib" "-L/usr/lib" "target/<GPU_DIR>/release/host.o" "-lstdc++" "-lm" "-lomp" "-lomptarget" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib" "-lgcc_s" "-lgcc" "-lpthread" "-lc" "-lgcc_s" "-lgcc" "/ABSOLUTE_PATH_TO/crtendS.o" "/lib/../lib64/crtn.o"
```

You can try to find the paths to those files on your system.
Expand All @@ -118,9 +95,7 @@ In the final step, you can now run your binary

```
./main
The first element is zero 0.000000
The first element is NOT zero 21.000000
The second element is 0.000000
all checks passed!
```

To receive more information about the memory transfer, you can enable info printing with
Expand Down
Loading