@@ -104,11 +104,10 @@ pub fn link_kernel(tokens: TokenStream) -> TokenStream {
104
104
let type_layout_start_pattern = format ! ( "\n \t // .globl\t {kernel_layout_name}" ) ;
105
105
106
106
if let Some ( type_layout_start) = kernel_ptx. find ( & type_layout_start_pattern) {
107
- const BEFORE_PARAM_PATTERN : & str = "\n .global .align 1 .b8 " ;
107
+ const BEFORE_PARAM_PATTERN : & str = ".global .align 1 .b8 " ;
108
108
const PARAM_LEN_PATTERN : & str = "[" ;
109
109
const LEN_BYTES_PATTERN : & str = "] = {" ;
110
- const AFTER_BYTES_PATTERN : & str = "};\n " ;
111
- const BYTES_PARAM_PATTERN : & str = "};" ;
110
+ const AFTER_BYTES_PATTERN : & str = "};" ;
112
111
113
112
let after_type_layout_start = type_layout_start + type_layout_start_pattern. len ( ) ;
114
113
@@ -178,7 +177,7 @@ pub fn link_kernel(tokens: TokenStream) -> TokenStream {
178
177
} ) ;
179
178
180
179
next_type_layout =
181
- bytes_start + bytes_end_offset + BYTES_PARAM_PATTERN . len ( ) ;
180
+ bytes_start + bytes_end_offset + AFTER_BYTES_PATTERN . len ( ) ;
182
181
} else {
183
182
next_type_layout = bytes_start;
184
183
}
@@ -224,30 +223,31 @@ fn compile_kernel(
224
223
args. to_string( ) . to_uppercase( )
225
224
) ;
226
225
227
- if let Ok ( kernel_path) =
228
- build_kernel_with_specialisation ( crate_path, & specialisation_var, specialisation)
229
- {
230
- let mut file = fs:: File :: open ( & kernel_path)
231
- . unwrap_or_else ( |_| panic ! ( "Failed to open kernel file at {:?}." , & kernel_path) ) ;
226
+ match build_kernel_with_specialisation ( crate_path, & specialisation_var, specialisation) {
227
+ Ok ( kernel_path) => {
228
+ let mut file = fs:: File :: open ( & kernel_path)
229
+ . unwrap_or_else ( |_| panic ! ( "Failed to open kernel file at {:?}." , & kernel_path) ) ;
232
230
233
- let mut kernel_ptx = String :: new ( ) ;
231
+ let mut kernel_ptx = String :: new ( ) ;
234
232
235
- file. read_to_string ( & mut kernel_ptx)
236
- . unwrap_or_else ( |_| panic ! ( "Failed to read kernel file at {:?}." , & kernel_path) ) ;
233
+ file. read_to_string ( & mut kernel_ptx)
234
+ . unwrap_or_else ( |_| panic ! ( "Failed to read kernel file at {:?}." , & kernel_path) ) ;
237
235
238
- colored:: control:: set_override ( true ) ;
239
- eprintln ! (
240
- "{} {} compiling a PTX crate." ,
241
- "[PTX]" . bright_black( ) . bold( ) ,
242
- "Finished" . green( ) . bold( )
243
- ) ;
244
- colored:: control:: unset_override ( ) ;
245
-
246
- Some ( kernel_ptx)
247
- } else {
248
- emit_ptx_build_error ( ) ;
236
+ colored:: control:: set_override ( true ) ;
237
+ eprintln ! (
238
+ "{} {} compiling a PTX crate." ,
239
+ "[PTX]" . bright_black( ) . bold( ) ,
240
+ "Finished" . green( ) . bold( )
241
+ ) ;
242
+ colored:: control:: unset_override ( ) ;
249
243
250
- None
244
+ Some ( kernel_ptx)
245
+ } ,
246
+ Err ( err) => {
247
+ eprintln ! ( "{err:?}" ) ;
248
+ emit_ptx_build_error ( ) ;
249
+ None
250
+ } ,
251
251
}
252
252
}
253
253
0 commit comments