@@ -1594,8 +1594,8 @@ impl Build {
1594
1594
1595
1595
if objs. len ( ) <= 1 {
1596
1596
for obj in objs {
1597
- let ( mut cmd, name ) = self . create_compile_object_cmd ( obj) ?;
1598
- run ( & mut cmd, & name , & self . cargo_output ) ?;
1597
+ let mut cmd = self . create_compile_object_cmd ( obj) ?;
1598
+ run ( & mut cmd, & self . cargo_output ) ?;
1599
1599
}
1600
1600
1601
1601
return Ok ( ( ) ) ;
@@ -1623,12 +1623,8 @@ impl Build {
1623
1623
// acquire the appropriate tokens, Once all objects have been compiled
1624
1624
// we wait on all the processes and propagate the results of compilation.
1625
1625
1626
- let pendings = Cell :: new ( Vec :: < (
1627
- Command ,
1628
- Cow < ' static , Path > ,
1629
- KillOnDrop ,
1630
- parallel:: job_token:: JobToken ,
1631
- ) > :: new ( ) ) ;
1626
+ let pendings =
1627
+ Cell :: new ( Vec :: < ( Command , KillOnDrop , parallel:: job_token:: JobToken ) > :: new ( ) ) ;
1632
1628
let is_disconnected = Cell :: new ( false ) ;
1633
1629
let has_made_progress = Cell :: new ( false ) ;
1634
1630
@@ -1649,14 +1645,8 @@ impl Build {
1649
1645
1650
1646
cell_update ( & pendings, |mut pendings| {
1651
1647
// Try waiting on them.
1652
- pendings. retain_mut ( |( cmd, program, child, _token) | {
1653
- match try_wait_on_child (
1654
- cmd,
1655
- program,
1656
- & mut child. 0 ,
1657
- & mut stdout,
1658
- & mut child. 1 ,
1659
- ) {
1648
+ pendings. retain_mut ( |( cmd, child, _token) | {
1649
+ match try_wait_on_child ( cmd, & mut child. 0 , & mut stdout, & mut child. 1 ) {
1660
1650
Ok ( Some ( ( ) ) ) => {
1661
1651
// Task done, remove the entry
1662
1652
has_made_progress. set ( true ) ;
@@ -1695,14 +1685,14 @@ impl Build {
1695
1685
} ;
1696
1686
let spawn_future = async {
1697
1687
for obj in objs {
1698
- let ( mut cmd, program ) = self . create_compile_object_cmd ( obj) ?;
1688
+ let mut cmd = self . create_compile_object_cmd ( obj) ?;
1699
1689
let token = tokens. acquire ( ) . await ?;
1700
- let mut child = spawn ( & mut cmd, & program , & self . cargo_output ) ?;
1690
+ let mut child = spawn ( & mut cmd, & self . cargo_output ) ?;
1701
1691
let mut stderr_forwarder = StderrForwarder :: new ( & mut child) ;
1702
1692
stderr_forwarder. set_non_blocking ( ) ?;
1703
1693
1704
1694
cell_update ( & pendings, |mut pendings| {
1705
- pendings. push ( ( cmd, program , KillOnDrop ( child, stderr_forwarder) , token) ) ;
1695
+ pendings. push ( ( cmd, KillOnDrop ( child, stderr_forwarder) , token) ) ;
1706
1696
pendings
1707
1697
} ) ;
1708
1698
@@ -1741,17 +1731,14 @@ impl Build {
1741
1731
check_disabled ( ) ?;
1742
1732
1743
1733
for obj in objs {
1744
- let ( mut cmd, name ) = self . create_compile_object_cmd ( obj) ?;
1745
- run ( & mut cmd, & name , & self . cargo_output ) ?;
1734
+ let mut cmd = self . create_compile_object_cmd ( obj) ?;
1735
+ run ( & mut cmd, & self . cargo_output ) ?;
1746
1736
}
1747
1737
1748
1738
Ok ( ( ) )
1749
1739
}
1750
1740
1751
- fn create_compile_object_cmd (
1752
- & self ,
1753
- obj : & Object ,
1754
- ) -> Result < ( Command , Cow < ' static , Path > ) , Error > {
1741
+ fn create_compile_object_cmd ( & self , obj : & Object ) -> Result < Command , Error > {
1755
1742
let asm_ext = AsmFileExt :: from_path ( & obj. src ) ;
1756
1743
let is_asm = asm_ext. is_some ( ) ;
1757
1744
let target = self . get_target ( ) ?;
@@ -1761,23 +1748,14 @@ impl Build {
1761
1748
let gnu = compiler. family == ToolFamily :: Gnu ;
1762
1749
1763
1750
let is_assembler_msvc = msvc && asm_ext == Some ( AsmFileExt :: DotAsm ) ;
1764
- let ( mut cmd, name) = if is_assembler_msvc {
1765
- let ( cmd, name) = self . msvc_macro_assembler ( ) ?;
1766
- ( cmd, Cow :: Borrowed ( Path :: new ( name) ) )
1751
+ let mut cmd = if is_assembler_msvc {
1752
+ self . msvc_macro_assembler ( ) ?
1767
1753
} else {
1768
1754
let mut cmd = compiler. to_command ( ) ;
1769
1755
for ( a, b) in self . env . iter ( ) {
1770
1756
cmd. env ( a, b) ;
1771
1757
}
1772
- (
1773
- cmd,
1774
- compiler
1775
- . path
1776
- . file_name ( )
1777
- . ok_or_else ( || Error :: new ( ErrorKind :: IOError , "Failed to get compiler path." ) )
1778
- . map ( PathBuf :: from)
1779
- . map ( Cow :: Owned ) ?,
1780
- )
1758
+ cmd
1781
1759
} ;
1782
1760
let is_arm = matches ! ( target. arch, "aarch64" | "arm" ) ;
1783
1761
command_add_output_file (
@@ -1817,7 +1795,7 @@ impl Build {
1817
1795
self . fix_env_for_apple_os ( & mut cmd) ?;
1818
1796
}
1819
1797
1820
- Ok ( ( cmd, name ) )
1798
+ Ok ( cmd)
1821
1799
}
1822
1800
1823
1801
/// This will return a result instead of panicking; see [`Self::expand()`] for
@@ -1852,12 +1830,7 @@ impl Build {
1852
1830
1853
1831
cmd. args ( self . files . iter ( ) . map ( std:: ops:: Deref :: deref) ) ;
1854
1832
1855
- let name = compiler
1856
- . path
1857
- . file_name ( )
1858
- . ok_or_else ( || Error :: new ( ErrorKind :: IOError , "Failed to get compiler path." ) ) ?;
1859
-
1860
- run_output ( & mut cmd, name, & self . cargo_output )
1833
+ run_output ( & mut cmd, & self . cargo_output )
1861
1834
}
1862
1835
1863
1836
/// Run the compiler, returning the macro-expanded version of the input files.
@@ -2476,7 +2449,7 @@ impl Build {
2476
2449
flags_env_var_value. is_ok ( )
2477
2450
}
2478
2451
2479
- fn msvc_macro_assembler ( & self ) -> Result < ( Command , & ' static str ) , Error > {
2452
+ fn msvc_macro_assembler ( & self ) -> Result < Command , Error > {
2480
2453
let target = self . get_target ( ) ?;
2481
2454
let tool = if target. arch == "x86_64" {
2482
2455
"ml64.exe"
@@ -2531,7 +2504,7 @@ impl Build {
2531
2504
cmd. arg ( "-safeseh" ) ;
2532
2505
}
2533
2506
2534
- Ok ( ( cmd, tool ) )
2507
+ Ok ( cmd)
2535
2508
}
2536
2509
2537
2510
fn assemble ( & self , lib_name : & str , dst : & Path , objs : & [ Object ] ) -> Result < ( ) , Error > {
@@ -2559,7 +2532,7 @@ impl Build {
2559
2532
let dlink = out_dir. join ( lib_name. to_owned ( ) + "_dlink.o" ) ;
2560
2533
let mut nvcc = self . get_compiler ( ) . to_command ( ) ;
2561
2534
nvcc. arg ( "--device-link" ) . arg ( "-o" ) . arg ( & dlink) . arg ( dst) ;
2562
- run ( & mut nvcc, "nvcc" , & self . cargo_output ) ?;
2535
+ run ( & mut nvcc, & self . cargo_output ) ?;
2563
2536
self . assemble_progressive ( dst, & [ dlink. as_path ( ) ] ) ?;
2564
2537
}
2565
2538
@@ -2587,12 +2560,12 @@ impl Build {
2587
2560
// Non-msvc targets (those using `ar`) need a separate step to add
2588
2561
// the symbol table to archives since our construction command of
2589
2562
// `cq` doesn't add it for us.
2590
- let ( mut ar, cmd , _any_flags ) = self . get_ar ( ) ?;
2563
+ let mut ar = self . try_get_archiver ( ) ?;
2591
2564
2592
2565
// NOTE: We add `s` even if flags were passed using $ARFLAGS/ar_flag, because `s`
2593
2566
// here represents a _mode_, not an arbitrary flag. Further discussion of this choice
2594
2567
// can be seen in https://github.com/rust-lang/cc-rs/pull/763.
2595
- run ( ar. arg ( "s" ) . arg ( dst) , & cmd , & self . cargo_output ) ?;
2568
+ run ( ar. arg ( "s" ) . arg ( dst) , & self . cargo_output ) ?;
2596
2569
}
2597
2570
2598
2571
Ok ( ( ) )
@@ -2601,7 +2574,7 @@ impl Build {
2601
2574
fn assemble_progressive ( & self , dst : & Path , objs : & [ & Path ] ) -> Result < ( ) , Error > {
2602
2575
let target = self . get_target ( ) ?;
2603
2576
2604
- let ( mut cmd, program, any_flags) = self . get_ar ( ) ?;
2577
+ let ( mut cmd, program, any_flags) = self . try_get_archiver_and_flags ( ) ?;
2605
2578
if target. env == "msvc" && !program. to_string_lossy ( ) . contains ( "llvm-ar" ) {
2606
2579
// NOTE: -out: here is an I/O flag, and so must be included even if $ARFLAGS/ar_flag is
2607
2580
// in use. -nologo on the other hand is just a regular flag, and one that we'll skip if
@@ -2619,7 +2592,7 @@ impl Build {
2619
2592
cmd. arg ( dst) ;
2620
2593
}
2621
2594
cmd. args ( objs) ;
2622
- run ( & mut cmd, & program , & self . cargo_output ) ?;
2595
+ run ( & mut cmd, & self . cargo_output ) ?;
2623
2596
} else {
2624
2597
// Set an environment variable to tell the OSX archiver to ensure
2625
2598
// that all dates listed in the archive are zero, improving
@@ -2648,11 +2621,7 @@ impl Build {
2648
2621
// NOTE: We add cq here regardless of whether $ARFLAGS/ar_flag have been used because
2649
2622
// it dictates the _mode_ ar runs in, which the setter of $ARFLAGS/ar_flag can't
2650
2623
// dictate. See https://github.com/rust-lang/cc-rs/pull/763 for further discussion.
2651
- run (
2652
- cmd. arg ( "cq" ) . arg ( dst) . args ( objs) ,
2653
- & program,
2654
- & self . cargo_output ,
2655
- ) ?;
2624
+ run ( cmd. arg ( "cq" ) . arg ( dst) . args ( objs) , & self . cargo_output ) ?;
2656
2625
}
2657
2626
2658
2627
Ok ( ( ) )
@@ -3114,10 +3083,6 @@ impl Build {
3114
3083
}
3115
3084
}
3116
3085
3117
- fn get_ar ( & self ) -> Result < ( Command , PathBuf , bool ) , Error > {
3118
- self . try_get_archiver_and_flags ( )
3119
- }
3120
-
3121
3086
/// Get the archiver (ar) that's in use for this configuration.
3122
3087
///
3123
3088
/// You can use [`Command::get_program`] to get just the path to the command.
@@ -3764,7 +3729,6 @@ impl Build {
3764
3729
. arg ( "--show-sdk-path" )
3765
3730
. arg ( "--sdk" )
3766
3731
. arg ( sdk) ,
3767
- "xcrun" ,
3768
3732
& self . cargo_output ,
3769
3733
) ?;
3770
3734
@@ -3821,7 +3785,6 @@ impl Build {
3821
3785
. arg ( "--show-sdk-version" )
3822
3786
. arg ( "--sdk" )
3823
3787
. arg ( sdk) ,
3824
- "xcrun" ,
3825
3788
& self . cargo_output ,
3826
3789
)
3827
3790
. ok ( ) ?;
@@ -3992,7 +3955,6 @@ impl Build {
3992
3955
) -> Option < PathBuf > {
3993
3956
let search_dirs = run_output (
3994
3957
cc. arg ( "-print-search-dirs" ) ,
3995
- "cc" ,
3996
3958
// this doesn't concern the compilation so we always want to show warnings.
3997
3959
cargo_output,
3998
3960
)
0 commit comments