From 5a3184e8678b8be0082d1579ea95f7adf67c5045 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 6 Jan 2026 10:43:07 +0100 Subject: [PATCH 01/21] Update to LLVM 22 --- .gitmodules | 4 ++-- src/llvm-project | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 8617643a12029..66c69f4f64038 100644 --- a/.gitmodules +++ b/.gitmodules @@ -24,8 +24,8 @@ shallow = true [submodule "src/llvm-project"] path = src/llvm-project - url = https://github.com/rust-lang/llvm-project.git - branch = rustc/21.1-2025-08-01 + url = https://github.com/nikic/llvm-project.git + branch = rust-llvm-22 shallow = true [submodule "src/doc/embedded-book"] path = src/doc/embedded-book diff --git a/src/llvm-project b/src/llvm-project index 00d23d10dc48c..c583807ff75cb 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 00d23d10dc48c6bb9d57ba96d4a748d85d77d0c7 +Subproject commit c583807ff75cb4627be6296a4818494302e41e68 From 0b00be207287433f72a421ce721452d2de53e452 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 8 Jan 2026 15:32:16 +0100 Subject: [PATCH 02/21] Update host toolchain --- src/ci/docker/scripts/build-clang.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/scripts/build-clang.sh b/src/ci/docker/scripts/build-clang.sh index 905c407730429..67a3253dec44c 100755 --- a/src/ci/docker/scripts/build-clang.sh +++ b/src/ci/docker/scripts/build-clang.sh @@ -5,7 +5,8 @@ set -ex source shared.sh # Try to keep the LLVM version here in sync with src/ci/scripts/install-clang.sh -LLVM=llvmorg-21.1.0-rc2 +#LLVM=llvmorg-21.1.0-rc2 +LLVM=9e78d8a4fb0739455ecdfd1751b347fbd7038c13 mkdir llvm-project cd llvm-project From 2a8522684c20b02696af8838aab69580fbd63a4a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 15 Jan 2026 09:27:11 +0100 Subject: [PATCH 03/21] Add patches --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index c583807ff75cb..32259a1ea4011 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit c583807ff75cb4627be6296a4818494302e41e68 +Subproject commit 32259a1ea4011162d28ce76765147111a73bef82 From fdcc73e348b37b0328e453adbafa6962fb899661 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 8 Jan 2026 22:13:27 -0500 Subject: [PATCH 04/21] add `spirv` target --- bootstrap.example.toml | 2 +- compiler/rustc_llvm/build.rs | 1 + compiler/rustc_llvm/src/lib.rs | 7 ++++ compiler/rustc_target/src/spec/mod.rs | 3 ++ .../spec/targets/spirv_unknown_vulkan1_3.rs | 37 +++++++++++++++++++ src/bootstrap/src/core/build_steps/llvm.rs | 2 +- tests/assembly-llvm/targets/targets-spirv.rs | 21 +++++++++++ 7 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs create mode 100644 tests/assembly-llvm/targets/targets-spirv.rs diff --git a/bootstrap.example.toml b/bootstrap.example.toml index e0cbb0c0e747c..c8be474fb18a5 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -126,7 +126,7 @@ # the resulting rustc being unable to compile for the disabled architectures. # # To add support for new targets, see https://rustc-dev-guide.rust-lang.org/building/new-target.html. -#llvm.targets = "AArch64;AMDGPU;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86" +#llvm.targets = "AArch64;AMDGPU;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SPIRV;SystemZ;WebAssembly;X86" # LLVM experimental targets to build support for. These targets are specified in # the same format as above, but since these targets are experimental, they are diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index c58dd64cca5f7..769d9483a0c9a 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -15,6 +15,7 @@ const OPTIONAL_COMPONENTS: &[&str] = &[ "csky", "mips", "powerpc", + "spirv", "systemz", "webassembly", "msp430", diff --git a/compiler/rustc_llvm/src/lib.rs b/compiler/rustc_llvm/src/lib.rs index a565e1feeb5e5..96fc826f1df00 100644 --- a/compiler/rustc_llvm/src/lib.rs +++ b/compiler/rustc_llvm/src/lib.rs @@ -167,6 +167,13 @@ pub fn initialize_available_targets() { LLVMInitializePowerPCAsmPrinter, LLVMInitializePowerPCAsmParser ); + init_target!( + llvm_component = "spirv", + LLVMInitializeSPIRVTargetInfo, + LLVMInitializeSPIRVTarget, + LLVMInitializeSPIRVTargetMC, + LLVMInitializeSPIRVAsmPrinter + ); init_target!( llvm_component = "systemz", LLVMInitializeSystemZTargetInfo, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index c5a7f119118c9..cc0a89a9e9814 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1720,6 +1720,8 @@ supported_targets! { ("amdgcn-amd-amdhsa", amdgcn_amd_amdhsa), + ("spirv-unknown-vulkan1.3", spirv_unknown_vulkan1_3), + ("xtensa-esp32-none-elf", xtensa_esp32_none_elf), ("xtensa-esp32-espidf", xtensa_esp32_espidf), ("xtensa-esp32s2-none-elf", xtensa_esp32s2_none_elf), @@ -1995,6 +1997,7 @@ crate::target_spec_enum! { VexOs = "vexos", VisionOs = "visionos", Vita = "vita", + Vulkan = "vulkan", VxWorks = "vxworks", Wasi = "wasi", WatchOs = "watchos", diff --git a/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs b/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs new file mode 100644 index 0000000000000..b657adca7cda1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs @@ -0,0 +1,37 @@ +use crate::spec::{ + Arch, LinkerFlavor, Os, PanicStrategy, Target, TargetMetadata, TargetOptions +}; + +pub(crate) fn target() -> Target { + Target { + llvm_target: "spirv-unknown-vulkan1.3".into(), + metadata: TargetMetadata { + description: Some("Vulkan 1.3".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(false), + }, + pointer_width: 64, + data_layout: "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G10".into(), + arch: Arch::SpirV, + options: TargetOptions { + os: Os::Vulkan, + vendor: "unknown".into(), + linker_flavor: LinkerFlavor::Llbc, + max_atomic_width: Some(32), + panic_strategy: PanicStrategy::Abort, + // Allow `cdylib` crate type. + dynamic_linking: true, + obj_is_bitcode: true, + only_cdylib: true, + dll_prefix: "".into(), + dll_suffix: ".spvt".into(), + // The LLVM backend does not support stack canaries for this target + supports_stack_protector: false, + + // Static initializers must not have cycles on this target + static_initializer_must_be_acyclic: true, + ..Default::default() + }, + } +} diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 93b65dbec905e..61a9883e97329 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -330,7 +330,7 @@ impl Step for Llvm { Some(s) => s, None => { "AArch64;AMDGPU;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;\ - Sparc;SystemZ;WebAssembly;X86" + Sparc;SPIRV;SystemZ;WebAssembly;X86" } }; diff --git a/tests/assembly-llvm/targets/targets-spirv.rs b/tests/assembly-llvm/targets/targets-spirv.rs new file mode 100644 index 0000000000000..a213e41eba35b --- /dev/null +++ b/tests/assembly-llvm/targets/targets-spirv.rs @@ -0,0 +1,21 @@ +//@ add-minicore +//@ assembly-output: emit-asm +//@ revisions: spirv_unknown_vulkan1_3 +//@ [spirv_unknown_vulkan1_3] compile-flags: --target spirv-unknown-vulkan1.3 +//@ [spirv_unknown_vulkan1_3] needs-llvm-components: spirv + +// Sanity-check that each target can produce assembly code. + +#![feature(no_core, lang_items)] +#![no_std] +#![no_core] +#![crate_type = "lib"] + +extern crate minicore; +use minicore::*; + +pub fn test() -> u8 { + 42 +} + +// CHECK: OpCapability From 1165a46abf1a90c226ae184a9fdcfebd2a4d416a Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 9 Jan 2026 22:10:34 -0500 Subject: [PATCH 05/21] wip --- compiler/rustc_target/src/callconv/mod.rs | 4 +- compiler/rustc_target/src/callconv/spirv.rs | 40 +++++++++++++++++++ .../compiler-builtins/build.rs | 3 +- library/core/src/ffi/va_list.rs | 1 + src/bootstrap/src/core/builder/cargo.rs | 4 ++ src/bootstrap/src/core/sanity.rs | 7 +++- src/bootstrap/src/utils/cc_detect.rs | 4 ++ src/bootstrap/src/utils/helpers.rs | 1 + src/build_helper/src/targets.rs | 3 +- tests/assembly-llvm/targets/targets-spirv.rs | 24 +++++++---- 10 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 compiler/rustc_target/src/callconv/spirv.rs diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index 6c8e0e181c4a4..9c10efad539e7 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -28,6 +28,7 @@ mod riscv; mod s390x; mod sparc; mod sparc64; +mod spirv; mod wasm; mod x86; mod x86_64; @@ -702,7 +703,8 @@ impl<'a, Ty> FnAbi<'a, Ty> { Arch::RiscV32 | Arch::RiscV64 => riscv::compute_abi_info(cx, self), Arch::Wasm32 | Arch::Wasm64 => wasm::compute_abi_info(cx, self), Arch::Bpf => bpf::compute_abi_info(cx, self), - arch @ (Arch::SpirV | Arch::Other(_)) => { + Arch::SpirV => spirv::compute_abi_info(cx, self), + arch @ Arch::Other(_) => { panic!("no lowering implemented for {arch}") } } diff --git a/compiler/rustc_target/src/callconv/spirv.rs b/compiler/rustc_target/src/callconv/spirv.rs new file mode 100644 index 0000000000000..98ab3ce8eb746 --- /dev/null +++ b/compiler/rustc_target/src/callconv/spirv.rs @@ -0,0 +1,40 @@ +use rustc_abi::{HasDataLayout, TyAbiInterface}; + +use crate::callconv::{ArgAbi, FnAbi}; + +fn classify_ret<'a, Ty, C>(_cx: &C, ret: &mut ArgAbi<'a, Ty>) +where + Ty: TyAbiInterface<'a, C> + Copy, + C: HasDataLayout, +{ + ret.extend_integer_width_to(32); +} + +fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) +where + Ty: TyAbiInterface<'a, C> + Copy, + C: HasDataLayout, +{ + if arg.layout.pass_indirectly_in_non_rustic_abis(cx) { + arg.make_indirect(); + return; + } + arg.extend_integer_width_to(32); +} + +pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) +where + Ty: TyAbiInterface<'a, C> + Copy, + C: HasDataLayout, +{ + if !fn_abi.ret.is_ignore() { + classify_ret(cx, &mut fn_abi.ret); + } + + for arg in fn_abi.args.iter_mut() { + if arg.is_ignore() { + continue; + } + classify_arg(cx, arg); + } +} diff --git a/library/compiler-builtins/compiler-builtins/build.rs b/library/compiler-builtins/compiler-builtins/build.rs index 6e1d230e3cd26..2f100a1d74dba 100644 --- a/library/compiler-builtins/compiler-builtins/build.rs +++ b/library/compiler-builtins/compiler-builtins/build.rs @@ -39,6 +39,7 @@ fn main() { || (target.triple.contains("sgx") && target.triple.contains("fortanix")) || target.triple.contains("-none") || target.triple.contains("nvptx") + || target.triple.contains("spirv") || target.triple.contains("uefi") || target.triple.contains("xous") { @@ -67,7 +68,7 @@ fn main() { // Don't use a C compiler for these targets: // // * nvptx - everything is bitcode, not compatible with mixed C/Rust - if !target.arch.contains("nvptx") { + if !target.arch.contains("nvptx") && !target.arch.contains("spirv") { #[cfg(feature = "c")] c::compile(&llvm_target, &target); } diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index d0f155316a109..2a917cf6e08c0 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -299,6 +299,7 @@ impl<'f> VaList<'f> { // Checks (via an assert in `compiler/rustc_ty_utils/src/abi.rs`) that the C ABI for the current // target correctly implements `rustc_pass_indirectly_in_non_rustic_abis`. +#[cfg(not(target_arch = "spirv"))] const _: () = { #[repr(C)] #[rustc_pass_indirectly_in_non_rustic_abis] diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 7150b2b0d59f2..55544dd29c6fc 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -258,6 +258,10 @@ impl Cargo { fn configure_linker(&mut self, builder: &Builder<'_>) -> &mut Cargo { let target = self.target; let compiler = self.compiler; + + if target.contains("spirv") { + return self; + } // Dealing with rpath here is a little special, so let's go into some // detail. First off, `-rpath` is a linker option on Unix platforms diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 235bbf8ddb783..93ead6b213b90 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -43,6 +43,7 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[ "thumbv7r-none-eabi", "thumbv7r-none-eabihf", "thumbv8r-none-eabihf", + "spirv-unknown-vulkan1.3", ]; /// Minimum version threshold for libstdc++ required when using prebuilt LLVM @@ -249,6 +250,10 @@ than building it. continue; } + if target.contains("spirv") { + continue; + } + // skip check for cross-targets if skip_target_sanity && target != &build.host_target { continue; @@ -357,7 +362,7 @@ than building it. } } - if (target.contains("-none-") || target.contains("nvptx")) + if (target.contains("-none-") || target.contains("nvptx") || target.contains("spirv")) && build.no_std(*target) == Some(false) { panic!("All the *-none-* and nvptx* targets are no-std targets") diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index 0662ae304ac06..a0b6cab254c92 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -105,6 +105,10 @@ pub fn fill_target_compiler(build: &mut Build, target: TargetSelection) { cfg.compiler(cc); } + if target.contains("spirv") { + return; + } + let compiler = cfg.get_compiler(); let ar = if let ar @ Some(..) = config.and_then(|c| c.ar.clone()) { ar diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index c670ae88fc549..8d76145935cac 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -219,6 +219,7 @@ pub fn use_host_linker(target: TargetSelection) -> bool { !(target.contains("emscripten") || target.contains("wasm32") || target.contains("nvptx") + || target.contains("spirv") || target.contains("fortanix") || target.contains("fuchsia") || target.contains("bpf") diff --git a/src/build_helper/src/targets.rs b/src/build_helper/src/targets.rs index cccc413368bc9..ed9037a56a7be 100644 --- a/src/build_helper/src/targets.rs +++ b/src/build_helper/src/targets.rs @@ -7,5 +7,6 @@ pub fn target_supports_std(target_tuple: &str) -> bool { !(target_tuple.contains("-none") || target_tuple.contains("nvptx") - || target_tuple.contains("switch")) + || target_tuple.contains("switch") + || target_tuple.contains("spirv")) } diff --git a/tests/assembly-llvm/targets/targets-spirv.rs b/tests/assembly-llvm/targets/targets-spirv.rs index a213e41eba35b..5704d790dbddd 100644 --- a/tests/assembly-llvm/targets/targets-spirv.rs +++ b/tests/assembly-llvm/targets/targets-spirv.rs @@ -1,4 +1,4 @@ -//@ add-minicore +// @ add-minicore //@ assembly-output: emit-asm //@ revisions: spirv_unknown_vulkan1_3 //@ [spirv_unknown_vulkan1_3] compile-flags: --target spirv-unknown-vulkan1.3 @@ -6,16 +6,24 @@ // Sanity-check that each target can produce assembly code. -#![feature(no_core, lang_items)] +#![feature(no_core, lang_items, never_type)] #![no_std] -#![no_core] +// #![no_core] #![crate_type = "lib"] -extern crate minicore; -use minicore::*; +pub enum A { + Foo(u8), + Bar(u32), +} -pub fn test() -> u8 { - 42 +// extern crate minicore; +// use minicore::*; +#[unsafe(no_mangle)] +pub fn test(x: &mut A) -> u8 { + match x { + A::Foo(x) => *x, + A::Bar(b) => *b as u8 + 2, + } } -// CHECK: OpCapability +// CHECK: what From 0d673e560eb7596bb995214fade22ef69d94a9cd Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Tue, 20 Jan 2026 21:48:55 +0100 Subject: [PATCH 06/21] format --- .../src/spec/targets/spirv_unknown_vulkan1_3.rs | 6 ++---- src/bootstrap/src/core/builder/cargo.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs b/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs index b657adca7cda1..5bf68f70d3fb2 100644 --- a/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs +++ b/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs @@ -1,6 +1,4 @@ -use crate::spec::{ - Arch, LinkerFlavor, Os, PanicStrategy, Target, TargetMetadata, TargetOptions -}; +use crate::spec::{Arch, LinkerFlavor, Os, PanicStrategy, Target, TargetMetadata, TargetOptions}; pub(crate) fn target() -> Target { Target { @@ -16,7 +14,7 @@ pub(crate) fn target() -> Target { arch: Arch::SpirV, options: TargetOptions { os: Os::Vulkan, - vendor: "unknown".into(), + vendor: "unknown".into(), linker_flavor: LinkerFlavor::Llbc, max_atomic_width: Some(32), panic_strategy: PanicStrategy::Abort, diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 55544dd29c6fc..dc3c51ab7bf6f 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -258,7 +258,7 @@ impl Cargo { fn configure_linker(&mut self, builder: &Builder<'_>) -> &mut Cargo { let target = self.target; let compiler = self.compiler; - + if target.contains("spirv") { return self; } From 376ba0015c8cea8baa3e95436adb08da506c3de8 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Tue, 20 Jan 2026 21:48:44 +0100 Subject: [PATCH 07/21] spirv64-intel-unknown triple --- compiler/rustc_target/src/spec/mod.rs | 1 + .../src/spec/targets/spirv64_intel_unknown.rs | 36 +++++++++++++++++++ src/bootstrap/src/core/sanity.rs | 1 + 3 files changed, 38 insertions(+) create mode 100644 compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index cc0a89a9e9814..3a3b1c3ebf0b6 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1720,6 +1720,7 @@ supported_targets! { ("amdgcn-amd-amdhsa", amdgcn_amd_amdhsa), + ("spirv64-intel-unknown", spirv64_intel_unknown), ("spirv-unknown-vulkan1.3", spirv_unknown_vulkan1_3), ("xtensa-esp32-none-elf", xtensa_esp32_none_elf), diff --git a/compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs b/compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs new file mode 100644 index 0000000000000..8f023fc3d3c97 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs @@ -0,0 +1,36 @@ +use crate::spec::{Arch, LinkerFlavor, Os, PanicStrategy, Target, TargetMetadata, TargetOptions}; + +pub(crate) fn target() -> Target { + Target { + llvm_target: "spirv64-intel-unknown".into(), + metadata: TargetMetadata { + description: Some("Intel GPU".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(false), + }, + pointer_width: 64, + data_layout: "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1-P9-A0".into(), + arch: Arch::SpirV, + options: TargetOptions { + os: Os::Unknown, + vendor: "intel".into(), + linker_flavor: LinkerFlavor::Llbc, + max_atomic_width: Some(32), + panic_strategy: PanicStrategy::Abort, + // Allow `cdylib` crate type. + dynamic_linking: true, + obj_is_bitcode: true, + only_cdylib: true, + dll_prefix: "".into(), + dll_suffix: ".spvt".into(), + is_like_gpu: true, + // The LLVM backend does not support stack canaries for this target + supports_stack_protector: false, + + // Static initializers must not have cycles on this target + static_initializer_must_be_acyclic: true, + ..Default::default() + }, + } +} diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 93ead6b213b90..22d898cbb6dfd 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -44,6 +44,7 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[ "thumbv7r-none-eabihf", "thumbv8r-none-eabihf", "spirv-unknown-vulkan1.3", + "spirv64-intel-unknown", ]; /// Minimum version threshold for libstdc++ required when using prebuilt LLVM From 9e1fff82ecad2a3b9a9df90e6c9ae2be4ba60ddf Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Tue, 20 Jan 2026 21:55:23 +0100 Subject: [PATCH 08/21] test --- .../targets/targets-spirv64-intel.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/assembly-llvm/targets/targets-spirv64-intel.rs diff --git a/tests/assembly-llvm/targets/targets-spirv64-intel.rs b/tests/assembly-llvm/targets/targets-spirv64-intel.rs new file mode 100644 index 0000000000000..6a3f4ca9fc1a3 --- /dev/null +++ b/tests/assembly-llvm/targets/targets-spirv64-intel.rs @@ -0,0 +1,21 @@ +//@ add-minicore +//@ assembly-output: emit-asm +//@ revisions: spirv64_intel_unknown +//@ [spirv64_intel_unknown] compile-flags: --target spirv64-intel-unknown +//@ [spirv64_intel_unknown] needs-llvm-components: spirv + +// Sanity-check that each target can produce assembly code. + +#![feature(no_core, lang_items, never_type)] +#![no_std] +#![no_core] +#![crate_type = "lib"] + +extern crate minicore; +use minicore::*; + +pub fn test() -> u8 { + 42 +} + +// CHECK: OpCapability Kernel From 13a732eb3944d4e93f3204f81968d8ff45946c1f Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Fri, 23 Jan 2026 18:03:56 +0100 Subject: [PATCH 09/21] gpu-kernel abi for spirv target --- compiler/rustc_codegen_llvm/src/abi.rs | 1 + compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 1 + compiler/rustc_target/src/spec/abi_map.rs | 6 +- tests/codegen-llvm/gpu-kernel-abi.rs | 5 +- .../feature-gate-abi_gpu_kernel.HOST.stderr | 28 +++---- .../feature-gate-abi_gpu_kernel.SPIRV.stderr | 73 +++++++++++++++++++ .../feature-gate-abi_gpu_kernel.rs | 4 +- 7 files changed, 101 insertions(+), 17 deletions(-) create mode 100644 tests/ui/feature-gates/feature-gate-abi_gpu_kernel.SPIRV.stderr diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index c3c1caf086f09..a4a3228edea0c 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -701,6 +701,7 @@ pub(crate) fn to_llvm_calling_convention(sess: &Session, abi: CanonAbi) -> llvm: CanonAbi::GpuKernel => match &sess.target.arch { Arch::AmdGpu => llvm::AmdgpuKernel, Arch::Nvptx64 => llvm::PtxKernel, + Arch::SpirV => llvm::SpirKernel, arch => panic!("Architecture {arch} does not support GpuKernel calling convention"), }, CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind { diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 454d5c4ffb249..075d8da23bc26 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -173,6 +173,7 @@ pub(crate) enum CallConv { Msp430Intr = 69, X86_ThisCall = 70, PtxKernel = 71, + SpirKernel = 76, X86_64_SysV = 78, X86_64_Win64 = 79, X86_VectorCall = 80, diff --git a/compiler/rustc_target/src/spec/abi_map.rs b/compiler/rustc_target/src/spec/abi_map.rs index d7fc18cd3761e..59129be470eb3 100644 --- a/compiler/rustc_target/src/spec/abi_map.rs +++ b/compiler/rustc_target/src/spec/abi_map.rs @@ -60,6 +60,7 @@ impl AbiMap { Arch::Msp430 => ArchKind::Msp430, Arch::Nvptx64 => ArchKind::Nvptx, Arch::RiscV32 | Arch::RiscV64 => ArchKind::Riscv, + Arch::SpirV => ArchKind::Spirv, Arch::X86 => ArchKind::X86, Arch::X86_64 => ArchKind::X86_64, _ => ArchKind::Other, @@ -131,7 +132,9 @@ impl AbiMap { /* gpu */ (ExternAbi::PtxKernel, ArchKind::Nvptx) => CanonAbi::GpuKernel, - (ExternAbi::GpuKernel, ArchKind::Amdgpu | ArchKind::Nvptx) => CanonAbi::GpuKernel, + (ExternAbi::GpuKernel, ArchKind::Amdgpu | ArchKind::Nvptx | ArchKind::Spirv) => { + CanonAbi::GpuKernel + } (ExternAbi::PtxKernel | ExternAbi::GpuKernel, _) => return AbiMapping::Invalid, /* x86 */ @@ -203,6 +206,7 @@ enum ArchKind { LoongArch, Msp430, Nvptx, + Spirv, Riscv, X86, X86_64, diff --git a/tests/codegen-llvm/gpu-kernel-abi.rs b/tests/codegen-llvm/gpu-kernel-abi.rs index 828b10c37880d..894447fded2d8 100644 --- a/tests/codegen-llvm/gpu-kernel-abi.rs +++ b/tests/codegen-llvm/gpu-kernel-abi.rs @@ -1,11 +1,13 @@ // Checks that the gpu-kernel calling convention correctly translates to LLVM calling conventions. //@ add-minicore -//@ revisions: amdgpu nvptx +//@ revisions: amdgpu nvptx spirv //@ [amdgpu] compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 //@ [amdgpu] needs-llvm-components: amdgpu //@ [nvptx] compile-flags: --crate-type=rlib --target=nvptx64-nvidia-cuda //@ [nvptx] needs-llvm-components: nvptx +//@ [spirv] compile-flags: --crate-type=rlib --target=spirv64-intel-unknown +//@ [spirv] needs-llvm-components: spirv #![feature(no_core, lang_items, abi_gpu_kernel)] #![no_core] @@ -14,5 +16,6 @@ use minicore::*; // amdgpu: define amdgpu_kernel void @fun(i32 // nvptx: define ptx_kernel void @fun(i32 +// spirv: define spir_kernel void @fun(i32 #[no_mangle] pub extern "gpu-kernel" fn fun(_: i32) {} diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.HOST.stderr b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.HOST.stderr index bbc6251601910..02d9316d9da6b 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.HOST.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.HOST.stderr @@ -1,11 +1,11 @@ error[E0570]: "gpu-kernel" is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:17:8 + --> $DIR/feature-gate-abi_gpu_kernel.rs:19:8 | LL | extern "gpu-kernel" fn f1(_: ()) {} | ^^^^^^^^^^^^ error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:17:8 + --> $DIR/feature-gate-abi_gpu_kernel.rs:19:8 | LL | extern "gpu-kernel" fn f1(_: ()) {} | ^^^^^^^^^^^^ @@ -15,13 +15,13 @@ LL | extern "gpu-kernel" fn f1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0570]: "gpu-kernel" is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:22:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:24:12 | LL | extern "gpu-kernel" fn m1(_: ()); | ^^^^^^^^^^^^ error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:22:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:24:12 | LL | extern "gpu-kernel" fn m1(_: ()); | ^^^^^^^^^^^^ @@ -31,13 +31,13 @@ LL | extern "gpu-kernel" fn m1(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0570]: "gpu-kernel" is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:25:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:27:12 | LL | extern "gpu-kernel" fn dm1(_: ()) {} | ^^^^^^^^^^^^ error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:25:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:27:12 | LL | extern "gpu-kernel" fn dm1(_: ()) {} | ^^^^^^^^^^^^ @@ -47,13 +47,13 @@ LL | extern "gpu-kernel" fn dm1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0570]: "gpu-kernel" is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:33:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:35:12 | LL | extern "gpu-kernel" fn m1(_: ()) {} | ^^^^^^^^^^^^ error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:33:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:35:12 | LL | extern "gpu-kernel" fn m1(_: ()) {} | ^^^^^^^^^^^^ @@ -63,13 +63,13 @@ LL | extern "gpu-kernel" fn m1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0570]: "gpu-kernel" is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:39:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:41:12 | LL | extern "gpu-kernel" fn im1(_: ()) {} | ^^^^^^^^^^^^ error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:39:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:41:12 | LL | extern "gpu-kernel" fn im1(_: ()) {} | ^^^^^^^^^^^^ @@ -79,13 +79,13 @@ LL | extern "gpu-kernel" fn im1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0570]: "gpu-kernel" is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:44:18 + --> $DIR/feature-gate-abi_gpu_kernel.rs:46:18 | LL | type A1 = extern "gpu-kernel" fn(_: ()); | ^^^^^^^^^^^^ error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:44:18 + --> $DIR/feature-gate-abi_gpu_kernel.rs:46:18 | LL | type A1 = extern "gpu-kernel" fn(_: ()); | ^^^^^^^^^^^^ @@ -95,13 +95,13 @@ LL | type A1 = extern "gpu-kernel" fn(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0570]: "gpu-kernel" is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:48:8 + --> $DIR/feature-gate-abi_gpu_kernel.rs:50:8 | LL | extern "gpu-kernel" {} | ^^^^^^^^^^^^ error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:48:8 + --> $DIR/feature-gate-abi_gpu_kernel.rs:50:8 | LL | extern "gpu-kernel" {} | ^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.SPIRV.stderr b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.SPIRV.stderr new file mode 100644 index 0000000000000..5157b2c2198fa --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.SPIRV.stderr @@ -0,0 +1,73 @@ +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change + --> $DIR/feature-gate-abi_gpu_kernel.rs:19:8 + | +LL | extern "gpu-kernel" fn f1(_: ()) {} + | ^^^^^^^^^^^^ + | + = note: see issue #135467 for more information + = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change + --> $DIR/feature-gate-abi_gpu_kernel.rs:24:12 + | +LL | extern "gpu-kernel" fn m1(_: ()); + | ^^^^^^^^^^^^ + | + = note: see issue #135467 for more information + = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change + --> $DIR/feature-gate-abi_gpu_kernel.rs:27:12 + | +LL | extern "gpu-kernel" fn dm1(_: ()) {} + | ^^^^^^^^^^^^ + | + = note: see issue #135467 for more information + = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change + --> $DIR/feature-gate-abi_gpu_kernel.rs:35:12 + | +LL | extern "gpu-kernel" fn m1(_: ()) {} + | ^^^^^^^^^^^^ + | + = note: see issue #135467 for more information + = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change + --> $DIR/feature-gate-abi_gpu_kernel.rs:41:12 + | +LL | extern "gpu-kernel" fn im1(_: ()) {} + | ^^^^^^^^^^^^ + | + = note: see issue #135467 for more information + = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change + --> $DIR/feature-gate-abi_gpu_kernel.rs:46:18 + | +LL | type A1 = extern "gpu-kernel" fn(_: ()); + | ^^^^^^^^^^^^ + | + = note: see issue #135467 for more information + = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change + --> $DIR/feature-gate-abi_gpu_kernel.rs:50:8 + | +LL | extern "gpu-kernel" {} + | ^^^^^^^^^^^^ + | + = note: see issue #135467 for more information + = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs index d442c9317f64e..aed8c48cf6b7b 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs @@ -1,10 +1,12 @@ -//@ revisions: HOST AMDGPU NVPTX +//@ revisions: HOST AMDGPU NVPTX SPIRV //@ add-minicore //@ compile-flags: --crate-type=rlib //@[AMDGPU] compile-flags: --target amdgcn-amd-amdhsa -Ctarget-cpu=gfx1100 //@[AMDGPU] needs-llvm-components: amdgpu //@[NVPTX] compile-flags: --target nvptx64-nvidia-cuda //@[NVPTX] needs-llvm-components: nvptx +//@[SPIRV] compile-flags: --target spirv64-intel-unknown +//@[SPIRV] needs-llvm-components: spirv //@ ignore-backends: gcc #![feature(no_core, lang_items)] From c8b9f1cf8ddfa219087184c3c1674eb2b18cbe46 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Fri, 23 Jan 2026 18:04:35 +0100 Subject: [PATCH 10/21] llvm revision with device rtl --- .gitmodules | 4 ++-- src/llvm-project | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 66c69f4f64038..ca54203dbdf9c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -24,8 +24,8 @@ shallow = true [submodule "src/llvm-project"] path = src/llvm-project - url = https://github.com/nikic/llvm-project.git - branch = rust-llvm-22 + url = https://github.com/fineg74/llvm-project.git + branch = l0RTL shallow = true [submodule "src/doc/embedded-book"] path = src/doc/embedded-book diff --git a/src/llvm-project b/src/llvm-project index 32259a1ea4011..e66a4e44abee6 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 32259a1ea4011162d28ce76765147111a73bef82 +Subproject commit e66a4e44abee6936d7dc8eb23c9c87a9dfe2fe63 From 66dc7f6fab31f373eee82aef591ed8b14d6a7cad Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Fri, 23 Jan 2026 18:04:50 +0100 Subject: [PATCH 11/21] update offload tests --- tests/codegen-llvm/gpu_offload/scalar_device.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/codegen-llvm/gpu_offload/scalar_device.rs b/tests/codegen-llvm/gpu_offload/scalar_device.rs index 61772d4040636..79c7a2969cee2 100644 --- a/tests/codegen-llvm/gpu_offload/scalar_device.rs +++ b/tests/codegen-llvm/gpu_offload/scalar_device.rs @@ -1,9 +1,11 @@ //@ add-minicore -//@ revisions: amdgpu nvptx +//@ revisions: amdgpu nvptx spirv //@[nvptx] compile-flags: -Copt-level=0 -Zunstable-options -Zoffload=Device --target nvptx64-nvidia-cuda --crate-type=rlib //@[nvptx] needs-llvm-components: nvptx //@[amdgpu] compile-flags: -Copt-level=0 -Zunstable-options -Zoffload=Device --target amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 --crate-type=rlib //@[amdgpu] needs-llvm-components: amdgpu +//@[spirv] compile-flags: -Copt-level=0 -Zunstable-options -Zoffload=Device --target spirv64-intel-unknown --crate-type=rlib +//@[spirv] needs-llvm-components: spirv //@ no-prefer-dynamic //@ needs-offload @@ -18,6 +20,7 @@ extern crate minicore; // CHECK: ; Function Attrs // nvptx-NEXT: define ptx_kernel void @foo(ptr %dyn_ptr, ptr %0, i64 %1) // amdgpu-NEXT: define amdgpu_kernel void @foo(ptr %dyn_ptr, ptr %0, i64 %1) +// spirv-NEXT: define spir_kernel void @foo(ptr %dyn_ptr, ptr %0, i64 %1) // CHECK-NEXT: entry: // CHECK-NEXT: %2 = trunc i64 %1 to i32 // CHECK-NEXT: %3 = bitcast i32 %2 to float From bd29d0a1241f31e92c2551bfd1f0c7b96ec458b9 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Fri, 23 Jan 2026 18:05:07 +0100 Subject: [PATCH 12/21] manually set cmake defines for offload --- src/bootstrap/src/core/build_steps/llvm.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 61a9883e97329..3ce1f728b90cb 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -1050,9 +1050,15 @@ impl Step for OmpOffload { .profile(profile) .env("LLVM_CONFIG_REAL", &host_llvm_config) .define("LLVM_ENABLE_ASSERTIONS", "ON") - .define("LLVM_ENABLE_RUNTIMES", "openmp;offload") + .define("LLVM_ENABLE_RUNTIMES", "openmp;offload;libsycl") + .define("LLVM_RUNTIME_TARGETS", "spirv64-intel-unknown") + .define("LIBOMPTARGET_PLUGINS_TO_BUILD", "level_zero") + .define("RUNTIMES_spirv64-intel-unknown_LLVM_ENABLE_RUNTIMES", "openmp") .define("LLVM_INCLUDE_TESTS", "OFF") .define("OFFLOAD_INCLUDE_TESTS", "OFF") + .define("CMAKE_C_COMPILER", "clang") + .define("CMAKE_CXX_COMPILER", "clang++") + .define("OFFLOAD_INCLUDE_TESTS", "OFF") .define("OPENMP_STANDALONE_BUILD", "ON") .define("LLVM_ROOT", builder.llvm_out(target).join("build")) .define("LLVM_DIR", llvm_cmake_dir); From db5c105a386a5bd985b59ca5bb46d98f7df7821e Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Fri, 23 Jan 2026 18:38:59 +0100 Subject: [PATCH 13/21] add spirv to tidy `arch_to_llvm_component` mapping --- src/tools/tidy/src/target_specific_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index 11138de5de764..3a5cc900c7678 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -115,6 +115,7 @@ fn arch_to_llvm_component(arch: &str) -> String { _ if arch.starts_with("mips") => "mips".into(), _ if arch.starts_with("powerpc") => "powerpc".into(), _ if arch.starts_with("riscv") => "riscv".into(), + _ if arch.starts_with("spirv") => "spirv".into(), _ => arch.to_ascii_lowercase(), } } From cdab1e7178981bac4f1525234754b04978d4a394 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Fri, 23 Jan 2026 19:46:40 +0100 Subject: [PATCH 14/21] fix unit test for is_like_gpu --- compiler/rustc_target/src/spec/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 3a3b1c3ebf0b6..17c6ce02fd3b2 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2923,8 +2923,8 @@ impl Target { ); check_eq!( self.is_like_gpu, - self.arch == Arch::Nvptx64 || self.arch == Arch::AmdGpu, - "`is_like_gpu` must be set if and only if `target` is `nvptx64` or `amdgcn`" + self.arch == Arch::AmdGpu || self.arch == Arch::Nvptx64 || self.arch == Arch::SpirV, + "`is_like_gpu` must be set if and only if `target` is `amdgcn`, `nvptx64`, or `spirv`" ); check_eq!( self.is_like_windows, From 3cb0b65c09bfdab4ef67438e2592943d4fdb0347 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sat, 24 Jan 2026 19:09:52 +0100 Subject: [PATCH 15/21] more accurate target description --- compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs b/compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs index 8f023fc3d3c97..480b08e5a58f9 100644 --- a/compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs +++ b/compiler/rustc_target/src/spec/targets/spirv64_intel_unknown.rs @@ -4,7 +4,7 @@ pub(crate) fn target() -> Target { Target { llvm_target: "spirv64-intel-unknown".into(), metadata: TargetMetadata { - description: Some("Intel GPU".into()), + description: Some("SPIR-V with Intel GPU extensions".into()), tier: Some(3), host_tools: Some(false), std: Some(false), From e885a2985acd3fa616d127aa04d03d69354bcc82 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sat, 24 Jan 2026 19:32:19 +0100 Subject: [PATCH 16/21] update llvm src --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index e66a4e44abee6..bb719bed6ca80 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit e66a4e44abee6936d7dc8eb23c9c87a9dfe2fe63 +Subproject commit bb719bed6ca80e5dd4157690f22de601da8975a4 From 6e7fb351a3aaa8a67bb6453a5a3451c6d87bf431 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sat, 24 Jan 2026 19:55:01 +0100 Subject: [PATCH 17/21] bless ui/check-cfg tests with the new arch --- tests/ui/check-cfg/cfg-crate-features.stderr | 2 +- .../ui/check-cfg/exhaustive-names-values.empty_cfg.stderr | 2 +- tests/ui/check-cfg/exhaustive-names-values.feature.stderr | 2 +- tests/ui/check-cfg/exhaustive-names-values.full.stderr | 2 +- tests/ui/check-cfg/well-known-values.stderr | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/ui/check-cfg/cfg-crate-features.stderr b/tests/ui/check-cfg/cfg-crate-features.stderr index 242883995488e..dd603f67f7eb0 100644 --- a/tests/ui/check-cfg/cfg-crate-features.stderr +++ b/tests/ui/check-cfg/cfg-crate-features.stderr @@ -24,7 +24,7 @@ warning: unexpected `cfg` condition value: `does_not_exist` LL | #![cfg(not(target(os = "does_not_exist")))] | ^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, and `solid_asp3` and 14 more + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, and `solid_asp3` and 15 more = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index 229390ab4600c..3d3df11ea1423 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `intel`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index 9281392b59ec3..e947eb17571c3 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `intel`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index 9281392b59ec3..e947eb17571c3 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `intel`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index efa0a7f4af9ac..6bd01d1b2240f 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -138,7 +138,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch32`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa` + = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch32`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `spirv`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -201,7 +201,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vulkan`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -230,7 +230,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `intel`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -274,7 +274,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | | | help: there is a expected value with a similar name: `"linux"` | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vulkan`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see for more information about checking conditional configuration warning: 28 warnings emitted From bceda283692f10156520dea4848fbcd5293b2238 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sat, 24 Jan 2026 20:39:58 +0100 Subject: [PATCH 18/21] minor fixes & allow lints in offload example src --- src/doc/rustc-dev-guide/src/offload/usage.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/offload/usage.md b/src/doc/rustc-dev-guide/src/offload/usage.md index 4d3222123aaff..33d2c2a5c1374 100644 --- a/src/doc/rustc-dev-guide/src/offload/usage.md +++ b/src/doc/rustc-dev-guide/src/offload/usage.md @@ -7,6 +7,8 @@ We currently work on launching the following Rust kernel on the GPU. To follow a #![feature(abi_gpu_kernel)] #![feature(rustc_attrs)] #![feature(core_intrinsics)] +#![feature(rustc_private)] +#![allow(internal_features)] #![no_std] #[cfg(target_os = "linux")] @@ -56,8 +58,8 @@ fn main() { } #[inline(never)] -unsafe fn kernel(x: *mut [f64; 256]) { - core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], (x,)) +pub unsafe fn kernel(x: *mut [f64; 256]) { + core::intrinsics::offload(kernel_1, [256, 1, 1], [32, 1, 1], (x,)) } #[cfg(target_os = "linux")] From 0cfbee63172947f38a9e4f8011493cd8926677db Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sat, 24 Jan 2026 20:45:29 +0100 Subject: [PATCH 19/21] target agnostic instructions in rustc-dev-guide/offload/usage.md --- src/doc/rustc-dev-guide/src/offload/usage.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/offload/usage.md b/src/doc/rustc-dev-guide/src/offload/usage.md index 33d2c2a5c1374..4d1665fbb960c 100644 --- a/src/doc/rustc-dev-guide/src/offload/usage.md +++ b/src/doc/rustc-dev-guide/src/offload/usage.md @@ -80,20 +80,24 @@ pub extern "gpu-kernel" fn kernel_1(x: *mut [f64; 256]) { 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 device (gpu) code. Replace the target-cpu with the right code for your gpu. +Replace the $target according to your gpu vendor: +* AMD: amdgcn-amd-amdhsa +* NVIDIA: nvptx64-nvidia-cuda +* INTEL: spirv64-intel-unknown (doesn't need target cpu) ``` -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 +RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir -Zoffload=Device -Csave-temps -Zunstable-options" cargo +offload build -Zunstable-options -r -v --target $target -Zbuild-std=core ``` You might afterwards need to copy your target/release/deps/.bc to lib.bc for now, before the next step. Now we generate the host (cpu) code. ``` -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 +RUSTFLAGS="--emit=llvm-bc,llvm-ir -Csave-temps -Zoffload=Host=/p/lustre1/drehwald1/prog/offload/r/target/$target/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-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//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=$target=-g" "--device-compiler=$target=-save-temps=cwd" "--device-linker=$target=-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//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. 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. From 7c0207f12536f7368d4038bedd731615924e1ef6 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sat, 24 Jan 2026 20:51:50 +0100 Subject: [PATCH 20/21] permit the target to have unknown os --- compiler/rustc_target/src/spec/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 17c6ce02fd3b2..3bb8a691f1ee0 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -3275,6 +3275,7 @@ impl Target { fn can_use_os_unknown(&self) -> bool { self.llvm_target == "wasm32-unknown-unknown" || self.llvm_target == "wasm64-unknown-unknown" + || self.llvm_target == "spirv64-intel-unknown" || (self.env == Env::Sgx && self.vendor == "fortanix") } From 660a91ad8dcbc9b90e949b41cae0a94b24738aa2 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sat, 24 Jan 2026 20:53:19 +0100 Subject: [PATCH 21/21] set `is_like_gpu = true` for `spirv-unknown-vulkan1.3` target Should be fixed in the "upstream" PR --- .../rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs b/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs index 5bf68f70d3fb2..1068ff99e60ef 100644 --- a/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs +++ b/compiler/rustc_target/src/spec/targets/spirv_unknown_vulkan1_3.rs @@ -24,6 +24,7 @@ pub(crate) fn target() -> Target { only_cdylib: true, dll_prefix: "".into(), dll_suffix: ".spvt".into(), + is_like_gpu: true, // The LLVM backend does not support stack canaries for this target supports_stack_protector: false,