Skip to content

Commit 475a06e

Browse files
committed
fix spirv-builder with default-features = false failing to compile
1 parent f45b4c3 commit 475a06e

File tree

1 file changed

+11
-6
lines changed
  • crates/spirv-builder/src

1 file changed

+11
-6
lines changed

crates/spirv-builder/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -981,12 +981,17 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
981981
// target_spec jsons, some later version requires them, some earlier
982982
// version fails with them (notably our 0.9.0 release)
983983
if toolchain_rustc_version >= Version::new(1, 76, 0) {
984-
let path = builder.path_to_target_spec.clone();
985-
let path = if cfg!(feature = "include_target_specs") {
986-
path.unwrap_or_else(|| PathBuf::from(format!("{TARGET_SPEC_DIR_PATH}/{target}.json")))
987-
} else {
988-
path.ok_or(SpirvBuilderError::MissingTargetSpec)?
989-
};
984+
let path_opt = builder.path_to_target_spec.clone();
985+
let path;
986+
#[cfg(feature = "include_target_specs")]
987+
{
988+
path = path_opt
989+
.unwrap_or_else(|| PathBuf::from(format!("{TARGET_SPEC_DIR_PATH}/{target}.json")));
990+
}
991+
#[cfg(not(feature = "include_target_specs"))]
992+
{
993+
path = path_opt.ok_or(SpirvBuilderError::MissingTargetSpec)?;
994+
}
990995
cargo.arg("--target").arg(path);
991996
} else {
992997
cargo.arg("--target").arg(target);

0 commit comments

Comments
 (0)