Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use std::{env, fs, mem};
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2025-11-02"
channel = "nightly-2025-11-13"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = bd3ac0330018c23b111bbee176f32c377be7b319"#;
# commit_hash = 01867557cd7dbe256a031a7b8e28d05daecd75ab"#;

fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
Expand Down Expand Up @@ -135,6 +135,10 @@ fn generate_pqp_cg_ssa() -> Result<(), Box<dyn Error>> {
}

let in_path = entry.path();

if in_path.ends_with(".DS_Store") {
continue;
}
let out_path = out_dir.join(entry.file_name());

let mut src = fs::read_to_string(in_path)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
OperandRef {
val,
layout: place.layout,
move_annotation: None,
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl<'a, 'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'tcx> {
fn add_coverage(&mut self, _instance: Instance<'tcx>, _kind: &CoverageKind) {}
}

impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> {
impl<'a, 'tcx> DebugInfoBuilderMethods<'_> for Builder<'a, 'tcx> {
fn dbg_var_addr(
&mut self,
_dbg_var: Self::DIVariable,
Expand Down
2 changes: 0 additions & 2 deletions crates/rustc_codegen_spirv/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// HACK(eddyb) start of `rustc_codegen_ssa` crate-level attributes (see `build.rs`).
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(file_buffered)]
#![feature(if_let_guard)]
#![feature(negative_impls)]
#![feature(rustdoc_internals)]
#![feature(string_from_utf8_lossy_owned)]
#![feature(trait_alias)]
#![feature(try_blocks)]
Expand Down
10 changes: 7 additions & 3 deletions crates/rustc_codegen_spirv/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ use rustc_session::config::{
};
use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename};
use rustc_span::Symbol;
use spirv_tools::TargetEnv;
use std::collections::BTreeMap;
use std::ffi::{CString, OsStr};
use std::fs::File;
use std::io::{BufWriter, Read};
use std::iter;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;

pub fn link(
Expand Down Expand Up @@ -337,7 +339,8 @@ fn do_spirv_opt(
opt::{self, Optimizer},
};

let mut optimizer = opt::create(sess.target.options.env.parse().ok());
let target_env = TargetEnv::from_str(sess.target.options.env.desc()).ok();
let mut optimizer = opt::create(target_env);

match sess.opts.optimize {
OptLevel::No => {}
Expand Down Expand Up @@ -399,7 +402,8 @@ fn do_spirv_val(
) {
use spirv_tools::val::{self, Validator};

let validator = val::create(sess.target.options.env.parse().ok());
let target_env = TargetEnv::from_str(sess.target.options.env.desc()).ok();
let validator = val::create(target_env);

if let Err(e) = validator.validate(spv_binary, Some(options)) {
let mut err = sess.dcx().struct_err(e.to_string());
Expand Down Expand Up @@ -498,7 +502,7 @@ fn add_upstream_native_libraries(
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
match lib.cfg {
Some(ref cfg) => {
eval_config_entry(sess, cfg, CRATE_NODE_ID, None, ShouldEmit::ErrorsAndLints).as_bool()
eval_config_entry(sess, cfg, CRATE_NODE_ID, ShouldEmit::ErrorsAndLints).as_bool()
}
None => true,
}
Expand Down
9 changes: 5 additions & 4 deletions crates/rustc_codegen_spirv/src/target.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rspirv::spirv::MemoryModel;
use rustc_target::spec::{Cc, LinkerFlavor, PanicStrategy, Target, TargetOptions};
use rustc_target::spec::{Arch, Cc, Env, LinkerFlavor, PanicStrategy, Target, TargetOptions};
use spirv_tools::TargetEnv;

const ARCH: &str = "spirv";
Expand Down Expand Up @@ -61,8 +61,9 @@ impl SpirvTarget {
o.emit_debug_gdb_scripts = false;
o.linker_flavor = LinkerFlavor::Unix(Cc::No);
o.panic_strategy = PanicStrategy::Abort;
o.env = self.env.to_string().into();
o.vendor = self.vendor.clone().into();
o.env = Env::Other(self.env.to_string().into());
// Note(@firestar99): not sure if this does anything
o.is_like_gpu = true;
// TODO: Investigate if main_needs_argc_argv is useful (for building exes)
o.main_needs_argc_argv = false;
o
Expand All @@ -74,7 +75,7 @@ impl SpirvTarget {
metadata: Default::default(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".into(),
arch: ARCH.into(),
arch: Arch::Other(ARCH.into()),
options: self.init_target_opts(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[toolchain]
channel = "nightly-2025-11-02"
channel = "nightly-2025-11-13"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = bd3ac0330018c23b111bbee176f32c377be7b319
# commit_hash = 01867557cd7dbe256a031a7b8e28d05daecd75ab

# Whenever changing the nightly channel, update the commit hash above, and
# change `REQUIRED_RUST_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` too.
Loading