@@ -4,7 +4,9 @@ pub use nvvm::*;
4
4
use serde:: Deserialize ;
5
5
use std:: {
6
6
borrow:: Borrow ,
7
- env, fmt,
7
+ env,
8
+ ffi:: OsString ,
9
+ fmt,
8
10
path:: { Path , PathBuf } ,
9
11
process:: { Command , Stdio } ,
10
12
} ;
@@ -278,16 +280,15 @@ fn find_rustc_codegen_nvvm() -> PathBuf {
278
280
panic ! ( "Could not find {} in library path" , filename) ;
279
281
}
280
282
281
- fn add_libnvvm_to_path ( ) {
283
+ fn get_new_path_var ( ) -> OsString {
282
284
let split_paths = env:: var_os ( dylib_path_envvar ( ) ) . unwrap_or_default ( ) ;
283
285
let mut paths = env:: split_paths ( & split_paths) . collect :: < Vec < _ > > ( ) ;
284
286
let libnvvm_path = find_cuda_helper:: find_cuda_root ( )
285
287
. unwrap ( )
286
288
. join ( "nvvm" )
287
289
. join ( "bin" ) ;
288
290
paths. push ( libnvvm_path) ;
289
- let joined = env:: join_paths ( & paths) . expect ( "Failed to join paths for PATH" ) ;
290
- env:: set_var ( dylib_path_envvar ( ) , joined) ;
291
+ env:: join_paths ( & paths) . expect ( "Failed to join paths for PATH" )
291
292
}
292
293
293
294
/// Joins strings together while ensuring none of the strings contain the separator.
@@ -309,7 +310,7 @@ fn invoke_rustc(builder: &CudaBuilder) -> Result<PathBuf, CudaBuilderError> {
309
310
// on what this does
310
311
let rustc_codegen_nvvm = find_rustc_codegen_nvvm ( ) ;
311
312
312
- add_libnvvm_to_path ( ) ;
313
+ let new_path = get_new_path_var ( ) ;
313
314
314
315
let mut rustflags = vec ! [ format!(
315
316
"-Zcodegen-backend={}" ,
@@ -367,6 +368,8 @@ fn invoke_rustc(builder: &CudaBuilder) -> Result<PathBuf, CudaBuilderError> {
367
368
target,
368
369
] ) ;
369
370
371
+ cargo. env ( dylib_path_envvar ( ) , new_path) ;
372
+
370
373
if builder. release {
371
374
cargo. arg ( "--release" ) ;
372
375
}
0 commit comments