Use is_windows_msvc instead of is_msvc in run-make tests
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
//@ ignore-cross-compile
|
||||
// Reason: the compiled binary is executed
|
||||
|
||||
use run_make_support::{cc, is_msvc, llvm_ar, rfs, run, rustc};
|
||||
use run_make_support::{cc, is_windows_msvc, llvm_ar, rfs, run, rustc};
|
||||
|
||||
fn main() {
|
||||
rfs::create_dir("a");
|
||||
@@ -15,7 +15,7 @@ fn main() {
|
||||
compile_obj_force_foo("b", "bar");
|
||||
let mut ar = llvm_ar();
|
||||
ar.obj_to_ar().arg("libfoo.a");
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
ar.arg("a/foo.obj").arg("b/foo.obj").run();
|
||||
} else {
|
||||
ar.arg("a/foo.o").arg("b/foo.o").run();
|
||||
@@ -27,9 +27,9 @@ fn main() {
|
||||
|
||||
#[track_caller]
|
||||
pub fn compile_obj_force_foo(dir: &str, lib_name: &str) {
|
||||
let obj_file = if is_msvc() { format!("{dir}/foo") } else { format!("{dir}/foo.o") };
|
||||
let obj_file = if is_windows_msvc() { format!("{dir}/foo") } else { format!("{dir}/foo.o") };
|
||||
let src = format!("{lib_name}.c");
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
cc().arg("-c").out_exe(&obj_file).input(src).run();
|
||||
} else {
|
||||
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{cc, cwd, dynamic_lib_extension, is_msvc, rfs, run, run_fail, rustc};
|
||||
use run_make_support::{
|
||||
cc, cwd, dynamic_lib_extension, is_windows_msvc, rfs, run, run_fail, rustc,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
rustc().input("foo.rs").run();
|
||||
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
let lib = "foo.dll.lib";
|
||||
|
||||
cc().input("bar.c").arg(lib).out_exe("bar").run();
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
//@ needs-unwind
|
||||
// Reason: this test exercises unwinding a panic
|
||||
|
||||
use run_make_support::{cc, is_msvc, llvm_ar, run, rustc, static_lib_name};
|
||||
use run_make_support::{cc, is_windows_msvc, llvm_ar, run, rustc, static_lib_name};
|
||||
|
||||
fn main() {
|
||||
// Compile `add.c` into an object file.
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
cc().arg("-c").out_exe("add").input("add.c").run();
|
||||
} else {
|
||||
cc().arg("-v").arg("-c").out_exe("add.o").input("add.c").run();
|
||||
@@ -24,7 +24,7 @@ fn main() {
|
||||
rustc().emit("obj").input("panic.rs").run();
|
||||
|
||||
// Now, create an archive using these two objects.
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.obj", "panic.o"]).run();
|
||||
} else {
|
||||
llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.o", "panic.o"]).run();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
use run_make_support::{
|
||||
bin_name, cc, dynamic_lib_extension, dynamic_lib_name, filename_contains, has_extension,
|
||||
has_prefix, has_suffix, is_msvc, msvc_import_dynamic_lib_name, path, run, rustc,
|
||||
has_prefix, has_suffix, is_windows_msvc, msvc_import_dynamic_lib_name, path, run, rustc,
|
||||
shallow_find_files, target,
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ fn main() {
|
||||
let sysroot = rustc().print("sysroot").run().stdout_utf8();
|
||||
let sysroot = sysroot.trim();
|
||||
let target_sysroot = path(sysroot).join("lib/rustlib").join(target()).join("lib");
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
let mut libs = shallow_find_files(&target_sysroot, |path| {
|
||||
has_prefix(path, "libstd-") && has_suffix(path, ".dll.lib")
|
||||
});
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{cc, cwd, dynamic_lib_name, is_msvc, rfs, run, rustc};
|
||||
use run_make_support::{cc, cwd, dynamic_lib_name, is_windows_msvc, rfs, run, rustc};
|
||||
|
||||
fn main() {
|
||||
rustc().input("bar.rs").run();
|
||||
rustc().input("foo.rs").run();
|
||||
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
cc().input("foo.c").arg("foo.dll.lib").out_exe("foo").run();
|
||||
} else {
|
||||
cc().input("foo.c").arg("-lfoo").library_search_path(cwd()).output("foo").run();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
//@ only-windows-gnu
|
||||
|
||||
use run_make_support::{cxx, is_msvc, llvm_ar, run, rustc, static_lib_name};
|
||||
use run_make_support::{cxx, llvm_ar, run, rustc, static_lib_name};
|
||||
|
||||
fn main() {
|
||||
cxx().input("foo.cpp").arg("-c").out_exe("foo.o").run();
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
// checks that linker arguments remain intact and in the order they were originally passed in.
|
||||
// See https://github.com/rust-lang/rust/pull/70665
|
||||
|
||||
use run_make_support::{is_msvc, rustc};
|
||||
use run_make_support::{is_windows_msvc, rustc};
|
||||
|
||||
fn main() {
|
||||
let linker = if is_msvc() { "msvc" } else { "ld" };
|
||||
let linker = if is_windows_msvc() { "msvc" } else { "ld" };
|
||||
|
||||
rustc()
|
||||
.input("empty.rs")
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
use std::fmt::Write;
|
||||
|
||||
use run_make_support::{is_msvc, rustc, target};
|
||||
use run_make_support::{is_windows_msvc, rustc, target};
|
||||
|
||||
fn main() {
|
||||
rustc().input("depa.rs").run();
|
||||
@@ -32,7 +32,7 @@ fn main() {
|
||||
fn needle_from_libs(libs: &[&str]) -> String {
|
||||
let mut needle = String::new();
|
||||
for lib in libs {
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
needle.write_fmt(format_args!(r#""{lib}.lib" "#)).unwrap();
|
||||
} else if target().contains("wasm") {
|
||||
needle.write_fmt(format_args!(r#""-l" "{lib}" "#)).unwrap();
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
// Reason: cross-compilation fails to export native symbols
|
||||
|
||||
use run_make_support::{
|
||||
build_native_static_lib, dynamic_lib_name, is_msvc, llvm_nm, rust_lib_name, rustc,
|
||||
build_native_static_lib, dynamic_lib_name, is_windows_msvc, llvm_nm, rust_lib_name, rustc,
|
||||
static_lib_name,
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ fn main() {
|
||||
.assert_stdout_contains_regex("U _*native_func");
|
||||
|
||||
// This part of the test does not function on Windows MSVC - no symbols are printed.
|
||||
if !is_msvc() {
|
||||
if !is_windows_msvc() {
|
||||
// Build a cdylib, `native-staticlib` will not appear on the linker line because it was
|
||||
// bundled previously. The cdylib will contain the `native_func` symbol in the end.
|
||||
rustc()
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
// Reason: compiling C++ code does not work well when cross-compiling
|
||||
// plus, the compiled binary is executed
|
||||
|
||||
use run_make_support::{cxx, is_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name};
|
||||
use run_make_support::{cxx, is_windows_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name};
|
||||
|
||||
fn main() {
|
||||
let mut cxx = cxx();
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
cxx.arg("-EHs");
|
||||
}
|
||||
cxx.input("c_static_lib_with_constructor.cpp")
|
||||
@@ -24,7 +24,7 @@ fn main() {
|
||||
|
||||
let mut llvm_ar = llvm_ar();
|
||||
llvm_ar.obj_to_ar();
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
llvm_ar
|
||||
.output_input(
|
||||
static_lib_name("c_static_lib_with_constructor"),
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//@ ignore-cross-compile
|
||||
// Reason: the compiled binary is executed
|
||||
|
||||
use run_make_support::{build_native_static_lib, cc, is_msvc, llvm_ar, run, rustc};
|
||||
use run_make_support::{build_native_static_lib, cc, is_windows_msvc, llvm_ar, run, rustc};
|
||||
|
||||
fn main() {
|
||||
build_native_static_lib("test");
|
||||
@@ -21,7 +21,7 @@ fn main() {
|
||||
.input("test.c")
|
||||
.arg("-mbranch-protection=bti+pac-ret+leaf")
|
||||
.run();
|
||||
let obj_file = if is_msvc() { "test.obj" } else { "test" };
|
||||
let obj_file = if is_windows_msvc() { "test.obj" } else { "test" };
|
||||
llvm_ar().obj_to_ar().output_input("libtest.a", &obj_file).run();
|
||||
rustc().arg("-Zbranch-protection=bti,pac-ret,leaf").input("test.rs").run();
|
||||
run("test");
|
||||
@@ -33,7 +33,7 @@ fn main() {
|
||||
// .input("test.c")
|
||||
// .arg("-mbranch-protection=bti+pac-ret+pc+leaf")
|
||||
// .run();
|
||||
// let obj_file = if is_msvc() { "test.obj" } else { "test" };
|
||||
// let obj_file = if is_windows_msvc() { "test.obj" } else { "test" };
|
||||
// llvm_ar().obj_to_ar().output_input("libtest.a", &obj_file).run();
|
||||
// rustc().arg("-Zbranch-protection=bti,pac-ret,pc,leaf").input("test.rs").run();
|
||||
// run("test");
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//@ ignore-cross-compile
|
||||
//@ ignore-wasm
|
||||
|
||||
use run_make_support::{is_msvc, rustc};
|
||||
use run_make_support::{is_windows_msvc, rustc};
|
||||
|
||||
fn main() {
|
||||
// build supporting crate
|
||||
@@ -41,9 +41,9 @@ fn main() {
|
||||
($lib:literal in $args:ident) => {{
|
||||
let lib = format!(
|
||||
"{}{}{}",
|
||||
if !is_msvc() { "-l" } else { "" },
|
||||
if !is_windows_msvc() { "-l" } else { "" },
|
||||
$lib,
|
||||
if !is_msvc() { "" } else { ".lib" },
|
||||
if !is_windows_msvc() { "" } else { ".lib" },
|
||||
);
|
||||
let found = $args.contains(&&*lib);
|
||||
assert!(found, "unable to find lib `{}` in those linker args: {:?}", lib, $args);
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
//@ only-x86
|
||||
//@ only-windows
|
||||
|
||||
use run_make_support::{build_native_dynamic_lib, diff, is_msvc, run, run_with_args, rustc};
|
||||
use run_make_support::{
|
||||
build_native_dynamic_lib, diff, is_windows_msvc, run, run_with_args, rustc,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
rustc()
|
||||
@@ -21,7 +23,7 @@ fn main() {
|
||||
build_native_dynamic_lib("extern");
|
||||
let out = run("driver").stdout_utf8();
|
||||
diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run();
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
let out_msvc = run_with_args("driver", &["true"]).stdout_utf8();
|
||||
diff()
|
||||
.expected_file("output.msvc.txt")
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
//@ only-windows
|
||||
// Reason: this test specifically exercises a 32bit Windows calling convention.
|
||||
|
||||
use run_make_support::{cc, diff, is_msvc, run, rustc};
|
||||
use run_make_support::{cc, diff, is_windows_msvc, run, rustc};
|
||||
|
||||
// NOTE: build_native_dynamic lib is not used, as the special `def` files
|
||||
// must be passed to the CC compiler.
|
||||
|
||||
fn main() {
|
||||
rustc().crate_type("bin").input("driver.rs").run();
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
cc().arg("-c").out_exe("extern").input("extern.c").run();
|
||||
cc().input("extern.obj")
|
||||
.arg("extern.msvc.def")
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
//@ only-windows
|
||||
|
||||
use run_make_support::{cc, diff, is_msvc, llvm_objdump, run, rustc};
|
||||
use run_make_support::{cc, diff, is_windows_msvc, llvm_objdump, run, rustc};
|
||||
|
||||
fn main() {
|
||||
rustc()
|
||||
@@ -31,7 +31,7 @@ fn main() {
|
||||
.assert_stdout_not_contains("inline_library_function")
|
||||
// Make sure we do find an import to the functions we expect to be imported.
|
||||
.assert_stdout_contains("library_function");
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
cc().arg("-c").out_exe("extern_1").input("extern_1.c").run();
|
||||
cc().arg("-c").out_exe("extern_2").input("extern_2.c").run();
|
||||
cc().input("extern_1.obj")
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
//@ only-windows
|
||||
|
||||
use run_make_support::{cc, diff, is_msvc, run, rustc};
|
||||
use run_make_support::{cc, diff, is_windows_msvc, run, rustc};
|
||||
|
||||
// NOTE: build_native_dynamic lib is not used, as the special `def` files
|
||||
// must be passed to the CC compiler.
|
||||
@@ -19,7 +19,7 @@ use run_make_support::{cc, diff, is_msvc, run, rustc};
|
||||
fn main() {
|
||||
rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run();
|
||||
rustc().crate_type("bin").input("driver.rs").run();
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
cc().arg("-c").out_exe("exporter").input("exporter.c").run();
|
||||
cc().input("exporter.obj")
|
||||
.arg("exporter.def")
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//@ only-windows
|
||||
// Reason: this test specifically exercises a 32bit Windows calling convention.
|
||||
|
||||
use run_make_support::{cc, diff, is_msvc, run, rustc};
|
||||
use run_make_support::{cc, diff, is_windows_msvc, run, rustc};
|
||||
|
||||
// NOTE: build_native_dynamic lib is not used, as the special `def` files
|
||||
// must be passed to the CC compiler.
|
||||
@@ -18,7 +18,7 @@ use run_make_support::{cc, diff, is_msvc, run, rustc};
|
||||
fn main() {
|
||||
rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run();
|
||||
rustc().crate_type("bin").input("driver.rs").run();
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
cc().arg("-c").out_exe("exporter").input("exporter.c").run();
|
||||
cc().input("exporter.obj")
|
||||
.arg("exporter-msvc.def")
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
// Reason: cross-compilation fails to export native symbols
|
||||
|
||||
use run_make_support::{
|
||||
bin_name, build_native_static_lib, cwd, filename_contains, is_msvc, llvm_ar, llvm_nm, rfs,
|
||||
rust_lib_name, rustc, shallow_find_files,
|
||||
bin_name, build_native_static_lib, cwd, filename_contains, is_windows_msvc, llvm_ar, llvm_nm,
|
||||
rfs, rust_lib_name, rustc, shallow_find_files,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
@@ -74,7 +74,7 @@ fn main() {
|
||||
.assert_stdout_contains_regex("native_dep_1.*native_dep_2.*native_dep_3");
|
||||
|
||||
// The binary "main" will not contain any symbols on MSVC.
|
||||
if !is_msvc() {
|
||||
if !is_windows_msvc() {
|
||||
llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f1");
|
||||
llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f2");
|
||||
llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f3");
|
||||
|
||||
@@ -61,8 +61,8 @@ use std::collections::BTreeSet;
|
||||
|
||||
use run_make_support::rustc::Rustc;
|
||||
use run_make_support::{
|
||||
cwd, has_extension, is_darwin, is_msvc, is_windows, llvm_dwarfdump, run_in_tmpdir, rustc,
|
||||
shallow_find_directories, shallow_find_files, uname,
|
||||
cwd, has_extension, is_darwin, is_windows, is_windows_msvc, llvm_dwarfdump, run_in_tmpdir,
|
||||
rustc, shallow_find_directories, shallow_find_files, uname,
|
||||
};
|
||||
|
||||
/// `-C debuginfo`. See <https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo>.
|
||||
@@ -1296,7 +1296,7 @@ fn main() {
|
||||
// identify which combination isn't exercised with a 6-layers nested for loop iterating through
|
||||
// each of the cli flag enum variants.
|
||||
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
// FIXME: the windows-msvc test coverage is sparse at best.
|
||||
|
||||
windows_msvc_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::Unspecified);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// Reason: the compiled binary is executed
|
||||
|
||||
use run_make_support::{
|
||||
cc, cwd, dynamic_lib_name, extra_c_flags, has_extension, is_msvc, rfs, run, rustc,
|
||||
cc, cwd, dynamic_lib_name, extra_c_flags, has_extension, is_windows_msvc, rfs, run, rustc,
|
||||
shallow_find_files,
|
||||
};
|
||||
|
||||
@@ -22,13 +22,13 @@ fn main() {
|
||||
// bar.dll.exp // export library for the dylib
|
||||
// msvc's underlying link.exe requires the import library for the dynamic library as input.
|
||||
// That is why the library is bar.dll.lib, not bar.dll.
|
||||
let library = if is_msvc() { "bar.dll.lib" } else { &dynamic_lib_name("bar") };
|
||||
let library = if is_windows_msvc() { "bar.dll.lib" } else { &dynamic_lib_name("bar") };
|
||||
cc().input("main.c").out_exe("main").arg(library).args(extra_c_flags()).run();
|
||||
for rlib in shallow_find_files(cwd(), |path| has_extension(path, "rlib")) {
|
||||
rfs::remove_file(rlib);
|
||||
}
|
||||
rfs::remove_file(dynamic_lib_name("foo"));
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
rfs::remove_file("foo.dll.lib");
|
||||
}
|
||||
run("main");
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//@ ignore-wasm
|
||||
// Reason: WASM does not support dynamic libraries
|
||||
|
||||
use run_make_support::{cc, is_msvc, regex, run, rustc, static_lib_name};
|
||||
use run_make_support::{cc, is_windows_msvc, regex, run, rustc, static_lib_name};
|
||||
|
||||
fn main() {
|
||||
rustc().arg("-Cprefer-dynamic").input("bar.rs").run();
|
||||
@@ -27,7 +27,7 @@ fn main() {
|
||||
let (_, native_link_args) = libs.split_once("note: native-static-libs: ").unwrap();
|
||||
// divide the command-line arguments in a vec
|
||||
let mut native_link_args = native_link_args.split(' ').collect::<Vec<&str>>();
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
// For MSVC pass the arguments on to the linker.
|
||||
native_link_args.insert(0, "-link");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// See https://github.com/rust-lang/rust/issues/37530
|
||||
|
||||
use run_make_support::object::read::Object;
|
||||
use run_make_support::{bin_name, dynamic_lib_name, is_msvc, object, regex, rfs, rustc};
|
||||
use run_make_support::{bin_name, dynamic_lib_name, is_windows_msvc, object, regex, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
let cdylib_name = dynamic_lib_name("a_cdylib");
|
||||
@@ -64,7 +64,7 @@ fn main() {
|
||||
);
|
||||
|
||||
// FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
// Check that an executable does not export any dynamic symbols
|
||||
symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), false);
|
||||
symbols_check(
|
||||
@@ -130,7 +130,7 @@ fn main() {
|
||||
);
|
||||
|
||||
// FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032
|
||||
if is_msvc() {
|
||||
if is_windows_msvc() {
|
||||
// Check that an executable does not export any dynamic symbols
|
||||
symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), false);
|
||||
symbols_check(
|
||||
|
||||
Reference in New Issue
Block a user