@@ -107,6 +107,8 @@ pub enum SpirvBuilderError {
107
107
"Without feature `compile_codegen`, you need to set the path of the codegen dylib using `rustc_codegen_spirv_location(...)`"
108
108
) ]
109
109
MissingCodegenBackendDylib ,
110
+ #[ error( "`rustc_codegen_spirv_location` path '{0}' is not a file" ) ]
111
+ CodegenBackendDylibDoesNotExist ( PathBuf ) ,
110
112
#[ error( "build failed" ) ]
111
113
BuildFailed ,
112
114
#[ error( "multi-module build cannot be used with print_metadata = MetadataPrintout::Full" ) ]
@@ -556,17 +558,8 @@ impl SpirvBuilder {
556
558
}
557
559
558
560
#[ must_use]
559
- pub fn rustc_codegen_spirv_location (
560
- mut self ,
561
- path_to_dylib : impl AsRef < std:: path:: Path > ,
562
- ) -> Self {
563
- let path_to_dylib = path_to_dylib. as_ref ( ) . to_path_buf ( ) ;
564
- assert ! (
565
- path_to_dylib. is_file( ) ,
566
- "Provided path to dylib '{}' is not a file" ,
567
- path_to_dylib. display( )
568
- ) ;
569
- self . rustc_codegen_spirv_location = Some ( path_to_dylib) ;
561
+ pub fn rustc_codegen_spirv_location ( mut self , path_to_dylib : impl AsRef < Path > ) -> Self {
562
+ self . rustc_codegen_spirv_location = Some ( path_to_dylib. as_ref ( ) . to_path_buf ( ) ) ;
570
563
self
571
564
}
572
565
@@ -732,6 +725,11 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
732
725
let rustc_codegen_spirv = Ok ( builder. rustc_codegen_spirv_location . clone ( ) )
733
726
. transpose ( )
734
727
. unwrap_or_else ( find_rustc_codegen_spirv) ?;
728
+ if !rustc_codegen_spirv. is_file ( ) {
729
+ return Err ( SpirvBuilderError :: CodegenBackendDylibDoesNotExist (
730
+ rustc_codegen_spirv,
731
+ ) ) ;
732
+ }
735
733
736
734
let mut rustflags = vec ! [
737
735
format!( "-Zcodegen-backend={}" , rustc_codegen_spirv. display( ) ) ,
0 commit comments