Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5050d1d
Auto merge of #150057 - nikic:update-llvm-21.1.8, r=cuviper
bors Dec 17, 2025
a0d076b
Auto merge of #150105 - jackh726:remove-expressions-coerce, r=BoxyUwU
bors Dec 19, 2025
2e0073b
Auto merge of #150110 - Urgau:remap-relative-library, r=jieyouxu
bors Dec 19, 2025
2413c51
Auto merge of #150056 - Kivooeo:trying-to-address-perf, r=davidtwco
bors Dec 19, 2025
f1a68d7
Auto merge of #148329 - LorrensP-2158466:closure-prop, r=lcnr
bors Dec 20, 2025
49503ad
Auto merge of #149437 - ilammy:patch-1, r=Mark-Simulacrum
bors Dec 21, 2025
22e65f6
Auto merge of #148766 - cjgillot:mir-const-runtime-checks, r=RalfJung…
bors Dec 22, 2025
78fb3df
Add `needs-std-remap-debuginfo` directive to `compiletest` & run-make
Urgau Dec 22, 2025
cccb5db
Update offloading docs to account for simplified usage
ZuseZ4 Dec 9, 2025
f73e4fa
Auto merge of #149202 - ZuseZ4:automate-offload-clangs, r=oli-obk
bors Dec 23, 2025
78bcc34
Auto merge of #150313 - bjorn3:sync_cg_clif-2025-12-23, r=bjorn3
bors Dec 23, 2025
1ef4310
Auto merge of #149114 - BoxyUwU:mgca_adt_exprs, r=lcnr
bors Dec 23, 2025
b5c0620
Rollup merge of #149800 - Delta17920:fix-ice-149746, r=lcnr
matthiaskrgr Dec 23, 2025
6172d4a
Rollup merge of #150182 - saethlin:dont-prefer-c-builtins, r=bjorn3
matthiaskrgr Dec 23, 2025
d675937
Rollup merge of #150216 - reddevilmidzy:t13, r=Kivooeo
matthiaskrgr Dec 23, 2025
bcb074a
Rollup merge of #150308 - Kobzol:bors-conf, r=marcoieni
matthiaskrgr Dec 23, 2025
fad54c9
Rollup merge of #150314 - tshepang:rdg-sync, r=tshepang
matthiaskrgr Dec 23, 2025
6f0bc37
Rollup merge of #150319 - tshepang:triple-is-tuple, r=Kivooeo
matthiaskrgr Dec 23, 2025
e449a2f
Auto merge of #150324 - matthiaskrgr:rollup-cl7wrqn, r=matthiaskrgr
bors Dec 24, 2025
ebe4b5f
Auto merge of #150283 - Urgau:remap-debuginfo-absolute, r=jieyouxu
bors Dec 24, 2025
6e52853
Rollup merge of #150016 - usamoi:stabilize-lazy-get, r=jhpratt
jhpratt Dec 24, 2025
78286ef
Rollup merge of #150139 - GKFX:clone-docs, r=jhpratt
jhpratt Dec 24, 2025
ffe7123
Rollup merge of #150238 - Zalathar:pat-const-kind, r=Nadrieril
jhpratt Dec 24, 2025
d95b69f
Auto merge of #150334 - jhpratt:rollup-met2i6d, r=jhpratt
bors Dec 24, 2025
49ac6bd
Auto merge of #150357 - ZuseZ4:zusez4-stdarch-push, r=sayantan
bors Dec 26, 2025
257d44f
Auto merge of #150395 - GuillaumeGomez:fix-copy-code-example-with-lin…
bors Dec 27, 2025
6596d6b
Auto merge of #142881 - cjgillot:minimap, r=saethlin
bors Dec 27, 2025
4bfbced
Auto merge of #149775 - WaffleLapkin:core-mem-maybe-dangling, r=Mark-…
bors Dec 27, 2025
771060b
Auto merge of #150421 - weihanglo:update-cargo, r=weihanglo
bors Dec 27, 2025
002cd53
Auto merge of #150076 - heathdutton:fix-linked-list-cursor-pop-front-…
bors Dec 28, 2025
8b15a73
Prepare for merging from rust-lang/rust
invalid-email-address Dec 29, 2025
0634f35
Merge ref '7fefa09b90ca' from rust-lang/rust
invalid-email-address Dec 29, 2025
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 @@
2dc30247c5d8293aaa31e1d7dae2ed2fde908ada
7fefa09b90ca57b8a0e0e4717d672d38a0ae58b5
23 changes: 10 additions & 13 deletions src/offload/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,25 @@ pub extern "gpu-kernel" fn kernel_1(x: *mut [f64; 256]) {
## Compile instructions
It is important to use a clang compiler build on the same llvm as rustc. Just calling clang without the full path will likely use your system clang, which probably will be incompatible. So either substitute clang/lld invocations below with absolute path, or set your `PATH` accordingly.

First we generate the host (cpu) code. The first build is just to compile libc, take note of the hashed path. Then we call rustc directly to build our host code, while providing the libc artifact to rustc.
First we generate the device (gpu) code. Replace the target-cpu with the right code for your gpu.
```
cargo +offload build -r -v
rustc +offload --edition 2024 src/lib.rs -g --crate-type cdylib -C opt-level=3 -C panic=abort -C lto=fat -L dependency=/absolute_path_to/target/release/deps --extern libc=/absolute_path_to/target/release/deps/liblibc-<HASH>.rlib --emit=llvm-bc,llvm-ir -Zoffload=Enable -Zunstable-options
RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir -Zoffload=Device -Csave-temps -Zunstable-options" cargo +offload build -Zunstable-options -r -v --target amdgcn-amd-amdhsa -Zbuild-std=core
```
You might afterwards need to copy your target/release/deps/<lib_name>.bc to lib.bc for now, before the next step.

Now we generate the device code. Replace the target-cpu with the right code for your gpu.
Now we generate the host (cpu) code.
```
RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir -Zoffload=Enable -Zunstable-options" cargo +offload build -Zunstable-options -r -v --target amdgcn-amd-amdhsa -Zbuild-std=core
RUSTFLAGS="--emit=llvm-bc,llvm-ir -Csave-temps -Zoffload=Host=/p/lustre1/drehwald1/prog/offload/r/target/amdgcn-amd-amdhsa/release/deps/host.out -Zunstable-options" cargo +offload build -r
```

This call also does a lot of work and generates multiple intermediate files for llvm offload.
While we integrated most offload steps into rustc by now, one binary invocation still remains for now:

```
"clang-21" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-S" "-save-temps=cwd" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "lib.rs" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-resource-dir" "/<ABSOLUTE_PATH_TO>/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21" "-ferror-limit" "19" "-fopenmp" "-fopenmp-offload-mandatory" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fembed-offload-object=host.out" "-fopenmp-targets=amdgcn-amd-amdhsa" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "host.s" "-x" "ir" "lib.bc"

"clang-21" "-cc1as" "-triple" "x86_64-unknown-linux-gnu" "-filetype" "obj" "-main-file-name" "lib.rs" "-target-cpu" "x86-64" "-mrelocation-model" "pic" "-o" "host.o" "host.s"

"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" "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" "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"
```

Especially for the last three commands I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang. By adding `-###` to your clang invocation, you can see the invidual steps.
You can ignore other steps, e.g. the invocation of a "clang-offload-packager".
You can try to find the paths to those files on your system. However, I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang. By adding `-###` to your clang invocation, you can see the invidual steps.
It will show multiple steps, just look for the clang-linker-wrapper example. Make sure to still include the path to the `host.o` file, and not whatever tmp file you got when compiling your c++ example with the following call.
```
myclang++ -fuse-ld=lld -O3 -fopenmp -fopenmp-offload-mandatory --offload-arch=gfx90a omp_bare.cpp -o main -###
```
Expand Down
4 changes: 4 additions & 0 deletions src/tests/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ settings:
assertions.
- `needs-std-debug-assertions` — ignores if std was not built with debug
assertions.
- `ignore-std-remap-debuginfo` — ignores if std was built with remapping of
it's sources.
- `needs-std-remap-debugino` — ignores if std was not built with remapping of
it's sources.
- `ignore-rustc-debug-assertions` — ignores if rustc was built with debug
assertions.
- `needs-rustc-debug-assertions` — ignores if rustc was not built with debug
Expand Down
Loading