@@ -251,32 +251,35 @@ impl Library {
251
251
}
252
252
}
253
253
254
- // Allow both dynamic/static library by default
255
- //
256
- // This is due to some distribution does not provide libiomp5.a
257
- let possible_link_types = if cfg ! ( feature = "openmp-strict-link-type" ) {
258
- vec ! [ config. link]
259
- } else {
260
- vec ! [ config. link, config. link. otherwise( ) ]
261
- } ;
262
- for link in possible_link_types {
263
- if file_name == openmp_runtime_file_name ( link) {
264
- match link {
265
- LinkType :: Static => {
266
- log:: info!(
267
- "Found static OpenMP runtime ({}): {}" ,
268
- file_name,
269
- dir. display( )
270
- ) ;
271
- iomp5_static_dir = Some ( dir. clone ( ) )
272
- }
273
- LinkType :: Dynamic => {
274
- log:: info!(
275
- "Found dynamic OpenMP runtime ({}): {}" ,
276
- file_name,
277
- dir. display( )
278
- ) ;
279
- iomp5_dynamic_dir = Some ( dir. clone ( ) )
254
+ // Do not seek OpenMP runtime if `Threading::Sequential`
255
+ if config. parallel == Threading :: OpenMP {
256
+ // Allow both dynamic/static library by default
257
+ //
258
+ // This is due to some distribution does not provide libiomp5.a
259
+ let possible_link_types = if cfg ! ( feature = "openmp-strict-link-type" ) {
260
+ vec ! [ config. link]
261
+ } else {
262
+ vec ! [ config. link, config. link. otherwise( ) ]
263
+ } ;
264
+ for link in possible_link_types {
265
+ if file_name == openmp_runtime_file_name ( link) {
266
+ match link {
267
+ LinkType :: Static => {
268
+ log:: info!(
269
+ "Found static OpenMP runtime ({}): {}" ,
270
+ file_name,
271
+ dir. display( )
272
+ ) ;
273
+ iomp5_static_dir = Some ( dir. clone ( ) )
274
+ }
275
+ LinkType :: Dynamic => {
276
+ log:: info!(
277
+ "Found dynamic OpenMP runtime ({}): {}" ,
278
+ file_name,
279
+ dir. display( )
280
+ ) ;
281
+ iomp5_dynamic_dir = Some ( dir. clone ( ) )
282
+ }
280
283
}
281
284
}
282
285
}
@@ -399,17 +402,31 @@ impl Library {
399
402
}
400
403
}
401
404
402
- if let Some ( dir) = & self . iomp5_static_dir {
403
- if dir != & self . library_dir {
404
- println ! ( "cargo:rustc-link-search={}" , dir. display( ) ) ;
405
- }
406
- }
407
- if let Some ( dir) = & self . iomp5_dynamic_dir {
408
- if dir != & self . library_dir {
409
- println ! ( "cargo:rustc-link-search={}" , dir. display( ) ) ;
405
+ if self . config . parallel == Threading :: OpenMP {
406
+ match (
407
+ self . iomp5_static_dir . as_ref ( ) ,
408
+ self . iomp5_dynamic_dir . as_ref ( ) ,
409
+ ) {
410
+ ( Some ( static_dir) , Some ( dynamic_dir) ) => match self . config . link {
411
+ LinkType :: Static => {
412
+ println ! ( "cargo:rustc-link-search={}" , static_dir. display( ) ) ;
413
+ }
414
+ LinkType :: Dynamic => {
415
+ println ! ( "cargo:rustc-link-search={}" , dynamic_dir. display( ) ) ;
416
+ }
417
+ } ,
418
+ ( Some ( static_dir) , None ) => {
419
+ println ! ( "cargo:rustc-link-search={}" , static_dir. display( ) ) ;
420
+ }
421
+ ( None , Some ( dynamic_dir) ) => {
422
+ println ! ( "cargo:rustc-link-search={}" , dynamic_dir. display( ) ) ;
423
+ }
424
+ _ => {
425
+ bail ! ( "OpenMP runtime not found" ) ;
426
+ }
410
427
}
428
+ println ! ( "cargo:rustc-link-lib={}" , OPENMP_RUNTIME_LIB ) ;
411
429
}
412
- println ! ( "cargo:rustc-link-lib={}" , OPENMP_RUNTIME_LIB ) ;
413
430
Ok ( ( ) )
414
431
}
415
432
}
0 commit comments