Skip to content

Commit 0511506

Browse files
committed
Error out when we detect incompatibilities between mingw and msvc
This has caused lots of frustrations: eg: slint-ui/slint#3802 slint-ui/slint#3539 slint-ui/slint#3739
1 parent bfa80db commit 0511506

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

qttypes/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ fn main() {
211211
""
212212
};
213213

214+
// MinGW and MSVC are not compatible
215+
if cargo_target_os == "windows" {
216+
let spec = qmake_query("QMAKE_SPEC");
217+
if (spec.contains("msvc") && cargo_target_env == "gnu")
218+
|| (spec.contains("g++") && cargo_target_env == "msvc")
219+
{
220+
report_error(&format!("Rust target '{}' is not compatible with Qt mkspec '{spec}'. Mixing MinGW and MSVC is not allowed.", std::env::var_os("TARGET").unwrap_or_default().to_string_lossy()));
221+
}
222+
}
214223
/* https://github.com/rust-lang/cargo/issues/9562
215224
if std::env::var("CARGO_CFG_TARGET_FAMILY").as_ref().map(|s| s.as_ref()) == Ok("unix") {
216225
println!("cargo:rustc-cdylib-link-arg=-Wl,-rpath,{}", &qt_library_path);

0 commit comments

Comments
 (0)