@@ -100,26 +100,29 @@ fn build_with_prebuilt_kernels() {
100100 ) ;
101101 }
102102
103- // Read and validate hashes
103+ // Read and validate hashes (only .cu and .fatbin, not build.rs)
104104 let stored_hashes_content = fs:: read_to_string ( & md5_path)
105105 . unwrap_or_else ( |_| panic ! ( "Failed to read {}" , md5_path. display( ) ) ) ;
106106 let stored_hashes: Vec < & str > = stored_hashes_content. lines ( ) . collect ( ) ;
107107
108- if stored_hashes. len ( ) != 3 {
109- panic ! ( "Invalid .md5 format for {}" , kernel_name) ;
108+ if stored_hashes. len ( ) != 2 {
109+ panic ! (
110+ "Invalid .md5 format for {} (expected 2 lines: .cu hash, .fatbin hash)" ,
111+ kernel_name
112+ ) ;
110113 }
111114
112- let build_rs_path = Path :: new ( & manifest_dir) . join ( "build.rs" ) ;
113- let current_build_rs_hash = compute_file_hash ( & build_rs_path) ;
114115 let current_cu_hash = compute_file_hash ( cu_path) ;
115116 let current_fatbin_hash = compute_file_hash ( & fatbin_path) ;
116117
117118 // Validate hashes
118- if current_build_rs_hash != stored_hashes[ 0 ]
119- || current_cu_hash != stored_hashes[ 1 ]
120- || current_fatbin_hash != stored_hashes[ 2 ]
121- {
122- panic ! ( "Hash mismatch for {}! Rebuild with nvcc." , kernel_name) ;
119+ if current_cu_hash != stored_hashes[ 0 ] || current_fatbin_hash != stored_hashes[ 1 ] {
120+ panic ! (
121+ "Hash mismatch for {}! Rebuild with nvcc.\n .cu: current={}, stored={}\n .fatbin: current={}, stored={}" ,
122+ kernel_name,
123+ current_cu_hash, stored_hashes[ 0 ] ,
124+ current_fatbin_hash, stored_hashes[ 1 ]
125+ ) ;
123126 }
124127
125128 // Copy fatbin to OUT_DIR
@@ -237,22 +240,19 @@ fn generate_prebuilt_artifacts(cu_path: &Path, arch_flags: &[String], out_dir: &
237240 // Copy .fatbin to prebuilt directory
238241 fs:: copy ( & temp_fatbin, & fatbin_path) . expect ( "Failed to copy .fatbin to cuda/prebuilt/" ) ;
239242
240- // Generate MD5 hashes of all three files for consistency validation
241- let build_rs_path = Path :: new ( & manifest_dir) . join ( "build.rs" ) ;
242- let build_rs_hash = compute_file_hash ( & build_rs_path) ;
243+ // Generate MD5 hashes for consistency validation (only .cu and .fatbin)
243244 let cu_hash = compute_file_hash ( cu_path) ;
244245 let fatbin_hash = compute_file_hash ( & fatbin_path) ;
245246
246- // Write all three hashes (one per line)
247- let hashes = format ! ( "{}\n {}\n {} \n " , build_rs_hash , cu_hash, fatbin_hash) ;
247+ // Write hashes (one per line: .cu hash, .fatbin hash )
248+ let hashes = format ! ( "{}\n {}\n " , cu_hash, fatbin_hash) ;
248249 fs:: write ( & md5_path, hashes) . expect ( "Failed to write .md5 file" ) ;
249250
250251 println ! (
251252 "cargo:warning=Generated prebuilt artifacts:\n {}\n {}" ,
252253 fatbin_path. display( ) ,
253254 md5_path. display( )
254255 ) ;
255- println ! ( "cargo:warning=build.rs hash: {}" , build_rs_hash) ;
256256 println ! ( "cargo:warning=.cu source hash: {}" , cu_hash) ;
257257 println ! ( "cargo:warning=.fatbin hash: {}" , fatbin_hash) ;
258258}
0 commit comments