Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1bbe36b

Browse files
authoredMay 2, 2024
Rollup merge of rust-lang#124138 - mati865:ignore-llvm-abi-in-dlltool-tests, r=davidtwco
Ignore LLVM ABI in dlltool tests since those targets don't use dlltool Otherwise those two tests fail when running `./x.py test` with this target.
2 parents 9382ba4 + b1fd4a7 commit 1bbe36b

File tree

4 files changed

+26
-53
lines changed

4 files changed

+26
-53
lines changed
 

‎src/tools/compiletest/src/header/needs.rs

+24-46
Original file line numberDiff line numberDiff line change
@@ -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

226214
impl 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+
}

‎tests/run-make/raw-dylib-cross-compilation/Makefile

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Tests that raw-dylib cross compilation works correctly
22

3-
# only-gnu
4-
# needs-i686-dlltool
5-
# needs-x86_64-dlltool
3+
# needs-dlltool
64

75
# i686 dlltool.exe can't product x64 binaries.
86
# ignore-i686-pc-windows-gnu

‎tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Tests that dlltool failing to generate an import library will raise an error.
22

3-
//@ only-gnu
4-
//@ only-windows
53
//@ needs-dlltool
64
//@ compile-flags: --crate-type lib --emit link
75
//@ normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL"

‎tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Tests that failing to run dlltool will raise an error.
22

3-
//@ only-gnu
4-
//@ only-windows
3+
//@ needs-dlltool
54
//@ compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exit.exe
65
#[link(name = "foo", kind = "raw-dylib")]
76
extern "C" {

0 commit comments

Comments
 (0)
Please sign in to comment.