@@ -119,16 +119,6 @@ pub(super) fn handle_needs(
119119 condition : config. debugger != Some ( Debugger :: Lldb ) || config. lldb_native_rust ,
120120 ignore_reason : "ignored on targets without Rust's LLDB" ,
121121 } ,
122- Need {
123- name : "needs-i686-dlltool" ,
124- condition : cache. i686_dlltool ,
125- ignore_reason : "ignored when dlltool for i686 is not present" ,
126- } ,
127- Need {
128- name : "needs-x86_64-dlltool" ,
129- condition : cache. x86_64_dlltool ,
130- ignore_reason : "ignored when dlltool for x86_64 is not present" ,
131- } ,
132122 Need {
133123 name : "needs-dlltool" ,
134124 condition : cache. dlltool ,
@@ -218,27 +208,11 @@ pub(super) struct CachedNeedsConditions {
218208 profiler_support : bool ,
219209 xray : bool ,
220210 rust_lld : bool ,
221- i686_dlltool : bool ,
222- x86_64_dlltool : bool ,
223211 dlltool : bool ,
224212}
225213
226214impl CachedNeedsConditions {
227215 pub ( super ) fn load ( config : & Config ) -> Self {
228- let path = std:: env:: var_os ( "PATH" ) . expect ( "missing PATH environment variable" ) ;
229- let path = std:: env:: split_paths ( & path) . collect :: < Vec < _ > > ( ) ;
230-
231- // On Windows, dlltool.exe is used for all architectures.
232- #[ cfg( windows) ]
233- let dlltool = path. iter ( ) . any ( |dir| dir. join ( "dlltool.exe" ) . is_file ( ) ) ;
234-
235- // For non-Windows, there are architecture specific dlltool binaries.
236- #[ cfg( not( windows) ) ]
237- let i686_dlltool = path. iter ( ) . any ( |dir| dir. join ( "i686-w64-mingw32-dlltool" ) . is_file ( ) ) ;
238- #[ cfg( not( windows) ) ]
239- let x86_64_dlltool =
240- path. iter ( ) . any ( |dir| dir. join ( "x86_64-w64-mingw32-dlltool" ) . is_file ( ) ) ;
241-
242216 let target = & & * config. target ;
243217 let sanitizers = & config. target_cfg ( ) . sanitizers ;
244218 Self {
@@ -278,26 +252,30 @@ impl CachedNeedsConditions {
278252 . join ( if config. host . contains ( "windows" ) { "rust-lld.exe" } else { "rust-lld" } )
279253 . exists ( ) ,
280254
281- #[ cfg( windows) ]
282- i686_dlltool : dlltool,
283- #[ cfg( windows) ]
284- x86_64_dlltool : dlltool,
285- #[ cfg( windows) ]
286- dlltool,
287-
288- // For non-Windows, there are architecture specific dlltool binaries.
289- #[ cfg( not( windows) ) ]
290- i686_dlltool,
291- #[ cfg( not( windows) ) ]
292- x86_64_dlltool,
293- #[ cfg( not( windows) ) ]
294- dlltool : if config. matches_arch ( "x86" ) {
295- i686_dlltool
296- } else if config. matches_arch ( "x86_64" ) {
297- x86_64_dlltool
298- } else {
299- false
300- } ,
255+ dlltool : find_dlltool ( & config) ,
301256 }
302257 }
303258}
259+
260+ fn find_dlltool ( config : & Config ) -> bool {
261+ let path = std:: env:: var_os ( "PATH" ) . expect ( "missing PATH environment variable" ) ;
262+ let path = std:: env:: split_paths ( & path) . collect :: < Vec < _ > > ( ) ;
263+
264+ // dlltool is used ony by GNU based `*-*-windows-gnu`
265+ if !( config. matches_os ( "windows" ) && config. matches_env ( "gnu" ) && config. matches_abi ( "" ) ) {
266+ return false ;
267+ }
268+
269+ // On Windows, dlltool.exe is used for all architectures.
270+ // For non-Windows, there are architecture specific dlltool binaries.
271+ let dlltool_found = if cfg ! ( windows) {
272+ path. iter ( ) . any ( |dir| dir. join ( "dlltool.exe" ) . is_file ( ) )
273+ } else if config. matches_arch ( "i686" ) {
274+ path. iter ( ) . any ( |dir| dir. join ( "i686-w64-mingw32-dlltool" ) . is_file ( ) )
275+ } else if config. matches_arch ( "x86_64" ) {
276+ path. iter ( ) . any ( |dir| dir. join ( "x86_64-w64-mingw32-dlltool" ) . is_file ( ) )
277+ } else {
278+ false
279+ } ;
280+ dlltool_found
281+ }
0 commit comments