@@ -1368,14 +1368,20 @@ pub fn prepare_zig_linker(target: &str) -> Result<ZigWrapper> {
1368
1368
}
1369
1369
}
1370
1370
1371
+ let current_exe = if let Ok ( exe) = env:: var ( "CARGO_BIN_EXE_cargo-zigbuild" ) {
1372
+ PathBuf :: from ( exe)
1373
+ } else {
1374
+ env:: current_exe ( ) ?
1375
+ } ;
1371
1376
let cc_args_str = cc_args. join ( " " ) ;
1372
- let hash = crc:: Crc :: < u16 > :: new ( & crc:: CRC_16_IBM_SDLC ) . checksum ( cc_args_str. as_bytes ( ) ) ;
1377
+ let hash_input = current_exe. display ( ) . to_string ( ) + & cc_args_str;
1378
+ let hash = crc:: Crc :: < u16 > :: new ( & crc:: CRC_16_IBM_SDLC ) . checksum ( hash_input. as_bytes ( ) ) ;
1373
1379
let zig_cc = zig_linker_dir. join ( format ! ( "zigcc-{file_target}-{:x}.{file_ext}" , hash) ) ;
1374
1380
let zig_cxx = zig_linker_dir. join ( format ! ( "zigcxx-{file_target}-{:x}.{file_ext}" , hash) ) ;
1375
1381
let zig_ranlib = zig_linker_dir. join ( format ! ( "zigranlib.{file_ext}" ) ) ;
1376
- write_linker_wrapper ( & zig_cc, "cc" , & cc_args_str) ?;
1377
- write_linker_wrapper ( & zig_cxx, "c++" , & cc_args_str) ?;
1378
- write_linker_wrapper ( & zig_ranlib, "ranlib" , "" ) ?;
1382
+ write_linker_wrapper ( & current_exe , & zig_cc, "cc" , & cc_args_str) ?;
1383
+ write_linker_wrapper ( & current_exe , & zig_cxx, "c++" , & cc_args_str) ?;
1384
+ write_linker_wrapper ( & current_exe , & zig_ranlib, "ranlib" , "" ) ?;
1379
1385
1380
1386
let exe_ext = if cfg ! ( windows) { ".exe" } else { "" } ;
1381
1387
let zig_ar = zig_linker_dir. join ( format ! ( "ar{exe_ext}" ) ) ;
@@ -1424,13 +1430,13 @@ fn symlink_wrapper(target: &Path) -> Result<()> {
1424
1430
1425
1431
/// Write a zig cc wrapper batch script for unix
1426
1432
#[ cfg( target_family = "unix" ) ]
1427
- fn write_linker_wrapper ( path : & Path , command : & str , args : & str ) -> Result < ( ) > {
1433
+ fn write_linker_wrapper (
1434
+ current_exe : & PathBuf ,
1435
+ path : & Path ,
1436
+ command : & str ,
1437
+ args : & str ,
1438
+ ) -> Result < ( ) > {
1428
1439
let mut buf = Vec :: < u8 > :: new ( ) ;
1429
- let current_exe = if let Ok ( exe) = env:: var ( "CARGO_BIN_EXE_cargo-zigbuild" ) {
1430
- PathBuf :: from ( exe)
1431
- } else {
1432
- env:: current_exe ( ) ?
1433
- } ;
1434
1440
writeln ! ( & mut buf, "#!/bin/sh" ) ?;
1435
1441
writeln ! (
1436
1442
& mut buf,
@@ -1458,13 +1464,13 @@ fn write_linker_wrapper(path: &Path, command: &str, args: &str) -> Result<()> {
1458
1464
1459
1465
/// Write a zig cc wrapper batch script for windows
1460
1466
#[ cfg( not( target_family = "unix" ) ) ]
1461
- fn write_linker_wrapper ( path : & Path , command : & str , args : & str ) -> Result < ( ) > {
1467
+ fn write_linker_wrapper (
1468
+ current_exe : & PathBuf ,
1469
+ path : & Path ,
1470
+ command : & str ,
1471
+ args : & str ,
1472
+ ) -> Result < ( ) > {
1462
1473
let mut buf = Vec :: < u8 > :: new ( ) ;
1463
- let current_exe = if let Ok ( exe) = env:: var ( "CARGO_BIN_EXE_cargo-zigbuild" ) {
1464
- PathBuf :: from ( exe)
1465
- } else {
1466
- env:: current_exe ( ) ?
1467
- } ;
1468
1474
let current_exe = if is_mingw_shell ( ) {
1469
1475
current_exe. to_slash_lossy ( ) . to_string ( )
1470
1476
} else {
0 commit comments