@@ -119,16 +119,6 @@ pub(super) fn handle_needs(
119
119
condition : config. debugger != Some ( Debugger :: Lldb ) || config. lldb_native_rust ,
120
120
ignore_reason : "ignored on targets without Rust's LLDB" ,
121
121
} ,
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
- } ,
132
122
Need {
133
123
name : "needs-dlltool" ,
134
124
condition : cache. dlltool ,
@@ -218,27 +208,11 @@ pub(super) struct CachedNeedsConditions {
218
208
profiler_support : bool ,
219
209
xray : bool ,
220
210
rust_lld : bool ,
221
- i686_dlltool : bool ,
222
- x86_64_dlltool : bool ,
223
211
dlltool : bool ,
224
212
}
225
213
226
214
impl CachedNeedsConditions {
227
215
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
-
242
216
let target = & & * config. target ;
243
217
let sanitizers = & config. target_cfg ( ) . sanitizers ;
244
218
Self {
@@ -278,26 +252,30 @@ impl CachedNeedsConditions {
278
252
. join ( if config. host . contains ( "windows" ) { "rust-lld.exe" } else { "rust-lld" } )
279
253
. exists ( ) ,
280
254
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) ,
301
256
}
302
257
}
303
258
}
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