diff --git a/Cargo.lock b/Cargo.lock index 6d823c5b5a596..271a2f7962cac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3214,7 +3214,7 @@ dependencies = [ [[package]] name = "run_make_support" -version = "0.2.0" +version = "0.0.0" dependencies = [ "bstr", "build_helper", diff --git a/src/tools/run-make-support/CHANGELOG.md b/src/tools/run-make-support/CHANGELOG.md deleted file mode 100644 index c1b7b618a9217..0000000000000 --- a/src/tools/run-make-support/CHANGELOG.md +++ /dev/null @@ -1,83 +0,0 @@ -# Changelog - -All notable changes to the `run_make_support` library should be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the support -library should adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) even if it's -not intended for public consumption (it's moreso to help internally, to help test writers track -changes to the support library). - -This support library will probably never reach 1.0. Please bump the minor version in `Cargo.toml` if -you make any breaking changes or other significant changes, or bump the patch version for bug fixes. - -## [0.2.0] - 2024-06-11 - -### Added - -- Added `fs_wrapper` module which provides panic-on-fail helpers for their respective `std::fs` - counterparts, the motivation is to: - - Reduce littering `.unwrap()` or `.expect()` everywhere for fs operations - - Help the test writer avoid forgetting to check fs results (even though enforced by - `-Dunused_must_use`) - - Provide better panic messages by default -- Added `path()` helper which creates a `Path` relative to `cwd()` (but is less noisy). - -### Changed - -- Marked many functions with `#[must_use]`, and rmake.rs are now compiled with `-Dunused_must_use`. - -## [0.1.0] - 2024-06-09 - -### Changed - -- Use *drop bombs* to enforce that commands are executed; a command invocation will panic if it is - constructed but never executed. Execution methods `Command::{run, run_fail}` will defuse the drop - bomb. -- Added `Command` helpers that forward to `std::process::Command` counterparts. - -### Removed - -- The `env_var` method which was incorrectly named and is `env_clear` underneath and is a footgun - from `impl_common_helpers`. For example, removing `TMPDIR` on Unix and `TMP`/`TEMP` breaks - `std::env::temp_dir` and wrecks anything using that, such as rustc's codgen. -- Removed `Deref`/`DerefMut` for `run_make_support::Command` -> `std::process::Command` because it - causes a method chain like `htmldocck().arg().run()` to fail, because `arg()` resolves to - `std::process::Command` which also returns a `&mut std::process::Command`, causing the `run()` to - be not found. - -## [0.0.0] - 2024-06-09 - -Consider this version to contain all changes made to the support library before we started to track -changes in this changelog. - -### Added - -- Custom command wrappers around `std::process::Command` (`run_make_support::Command`) and custom - wrapper around `std::process::Output` (`CompletedProcess`) to make it more convenient to work with - commands and their output, and help avoid forgetting to check for exit status. - - `Command`: `set_stdin`, `run`, `run_fail`. - - `CompletedProcess`: `std{err,out}_utf8`, `status`, `assert_std{err,out}_{equals, contains, - not_contains}`, `assert_exit_code`. -- `impl_common_helpers` macro to avoid repeating adding common convenience methods, including: - - Environment manipulation methods: `env`, `env_remove` - - Command argument providers: `arg`, `args` - - Common invocation inspection (of the command invocation up until `inspect` is called): - `inspect` - - Execution methods: `run` (for commands expected to succeed execution, exit status `0`) and - `run_fail` (for commands expected to fail execution, exit status non-zero). -- Command wrappers around: `rustc`, `clang`, `cc`, `rustc`, `rustdoc`, `llvm-readobj`. -- Thin helpers to construct `python` and `htmldocck` commands. -- `run` and `run_fail` (like `Command::{run, run_fail}`) for running binaries, which sets suitable - env vars (like `LD_LIB_PATH` or equivalent, `TARGET_RPATH_ENV`, `PATH` on Windows). -- Pseudo command `diff` which has similar functionality as the cli util but not the same API. -- Convenience panic-on-fail helpers `env_var`, `env_var_os`, `cwd` for their `std::env` conterparts. -- Convenience panic-on-fail helpers for reading respective env vars: `target`, `source_root`. -- Platform check helpers: `is_windows`, `is_msvc`, `cygpath_windows`, `uname`. -- fs helpers: `copy_dir_all`. -- `recursive_diff` helper. -- Generic `assert_not_contains` helper. -- Scoped run-with-teardown helper `run_in_tmpdir` which is designed to run commands in a temporary - directory that is cleared when closure returns. -- Helpers for constructing the name of binaries and libraries: `rust_lib_name`, `static_lib_name`, - `bin_name`, `dynamic_lib_name`. -- Re-export libraries: `gimli`, `object`, `regex`, `wasmparsmer`. diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index 3226f467ba4f9..a4e7534137d5e 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -1,18 +1,27 @@ [package] name = "run_make_support" -version = "0.2.0" -edition = "2021" +version = "0.0.0" +edition = "2024" [dependencies] + +# These dependencies are either used to implement part of support library +# functionality, or re-exported to test recipe programs via the support library, +# or both. + +# tidy-alphabetical-start bstr = "1.12" +gimli = "0.32" +libc = "0.2" object = "0.37" +regex = "1.11" +serde_json = "1.0" similar = "2.7" wasmparser = { version = "0.219", default-features = false, features = ["std"] } -regex = "1.11" -gimli = "0.32" +# tidy-alphabetical-end + +# Shared with bootstrap and compiletest build_helper = { path = "../../build_helper" } -serde_json = "1.0" -libc = "0.2" [lib] crate-type = ["lib", "dylib"] diff --git a/src/tools/run-make-support/src/artifact_names.rs b/src/tools/run-make-support/src/artifact_names.rs index b0d588d3550ac..a889b30e145d6 100644 --- a/src/tools/run-make-support/src/artifact_names.rs +++ b/src/tools/run-make-support/src/artifact_names.rs @@ -2,7 +2,7 @@ //! libraries which are target-dependent. use crate::target; -use crate::targets::is_msvc; +use crate::targets::is_windows_msvc; /// Construct the static library name based on the target. #[track_caller] @@ -10,7 +10,7 @@ use crate::targets::is_msvc; pub fn static_lib_name(name: &str) -> String { assert!(!name.contains(char::is_whitespace), "static library name cannot contain whitespace"); - if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") } + if is_windows_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") } } /// Construct the dynamic library name based on the target. @@ -45,7 +45,7 @@ pub fn dynamic_lib_extension() -> &'static str { #[track_caller] #[must_use] pub fn msvc_import_dynamic_lib_name(name: &str) -> String { - assert!(is_msvc(), "this function is exclusive to MSVC"); + assert!(is_windows_msvc(), "this function is exclusive to MSVC"); assert!(!name.contains(char::is_whitespace), "import library name cannot contain whitespace"); format!("{name}.dll.lib") diff --git a/src/tools/run-make-support/src/external_deps/c_build.rs b/src/tools/run-make-support/src/external_deps/c_build.rs index 9dd30713f958b..ecbf5ba8fe0d0 100644 --- a/src/tools/run-make-support/src/external_deps/c_build.rs +++ b/src/tools/run-make-support/src/external_deps/c_build.rs @@ -4,7 +4,7 @@ use crate::artifact_names::{dynamic_lib_name, static_lib_name}; use crate::external_deps::c_cxx_compiler::{cc, cxx}; use crate::external_deps::llvm::llvm_ar; use crate::path_helpers::path; -use crate::targets::{is_darwin, is_msvc, is_windows}; +use crate::targets::{is_darwin, is_windows, is_windows_msvc}; // FIXME(Oneirical): These native build functions should take a Path-based generic. @@ -24,12 +24,12 @@ pub fn build_native_static_lib_optimized(lib_name: &str) -> PathBuf { #[track_caller] fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf { - let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; + let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; let src = format!("{lib_name}.c"); let lib_path = static_lib_name(lib_name); let mut cc = cc(); - if !is_msvc() { + if !is_windows_msvc() { cc.arg("-v"); } if optimzed { @@ -37,7 +37,7 @@ fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf { } cc.arg("-c").out_exe(&obj_file).input(src).optimize().run(); - let obj_file = if is_msvc() { + let obj_file = if is_windows_msvc() { PathBuf::from(format!("{lib_name}.obj")) } else { PathBuf::from(format!("{lib_name}.o")) @@ -50,16 +50,17 @@ fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf { /// [`std::env::consts::DLL_PREFIX`] and [`std::env::consts::DLL_EXTENSION`]. #[track_caller] pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf { - let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; + let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; let src = format!("{lib_name}.c"); let lib_path = dynamic_lib_name(lib_name); - 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(); }; - let obj_file = if is_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") }; - if is_msvc() { + let obj_file = + if is_windows_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") }; + if is_windows_msvc() { let out_arg = format!("-out:{lib_path}"); cc().input(&obj_file).args(&["-link", "-dll", &out_arg]).run(); } else if is_darwin() { @@ -79,15 +80,15 @@ pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf { /// Built from a C++ file. #[track_caller] pub fn build_native_static_lib_cxx(lib_name: &str) -> PathBuf { - let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; + let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; let src = format!("{lib_name}.cpp"); let lib_path = static_lib_name(lib_name); - if is_msvc() { + if is_windows_msvc() { cxx().arg("-EHs").arg("-c").out_exe(&obj_file).input(src).run(); } else { cxx().arg("-c").out_exe(&obj_file).input(src).run(); }; - let obj_file = if is_msvc() { + let obj_file = if is_windows_msvc() { PathBuf::from(format!("{lib_name}.obj")) } else { PathBuf::from(format!("{lib_name}.o")) diff --git a/src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs b/src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs index 0e6d6ea6075d2..31469e669e18e 100644 --- a/src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs +++ b/src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs @@ -1,7 +1,7 @@ use std::path::Path; use crate::command::Command; -use crate::{env_var, is_msvc}; +use crate::{env_var, is_windows_msvc}; /// Construct a new platform-specific C compiler invocation. /// @@ -82,7 +82,7 @@ impl Cc { pub fn out_exe(&mut self, name: &str) -> &mut Self { let mut path = std::path::PathBuf::from(name); - if is_msvc() { + if is_windows_msvc() { path.set_extension("exe"); let fe_path = path.clone(); path.set_extension(""); @@ -108,7 +108,7 @@ impl Cc { /// Optimize the output. /// Equivalent to `-O3` for GNU-compatible linkers or `-O2` for MSVC linkers. pub fn optimize(&mut self) -> &mut Self { - if is_msvc() { + if is_windows_msvc() { self.cmd.arg("-O2"); } else { self.cmd.arg("-O3"); diff --git a/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs b/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs index c031763387362..ac7392641c0d7 100644 --- a/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs +++ b/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs @@ -1,9 +1,9 @@ -use crate::{is_msvc, is_win7, is_windows, uname}; +use crate::{is_win7, is_windows, is_windows_msvc, uname}; /// `EXTRACFLAGS` pub fn extra_c_flags() -> Vec<&'static str> { if is_windows() { - if is_msvc() { + if is_windows_msvc() { let mut libs = vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"]; if is_win7() { @@ -29,7 +29,7 @@ pub fn extra_c_flags() -> Vec<&'static str> { /// `EXTRACXXFLAGS` pub fn extra_cxx_flags() -> Vec<&'static str> { if is_windows() { - if is_msvc() { vec![] } else { vec!["-lstdc++"] } + if is_windows_msvc() { vec![] } else { vec!["-lstdc++"] } } else { match &uname()[..] { "Darwin" => vec!["-lc++"], diff --git a/src/tools/run-make-support/src/external_deps/rustc.rs b/src/tools/run-make-support/src/external_deps/rustc.rs index 72a1e062a38da..1ea549ca7ea13 100644 --- a/src/tools/run-make-support/src/external_deps/rustc.rs +++ b/src/tools/run-make-support/src/external_deps/rustc.rs @@ -6,7 +6,7 @@ use crate::command::Command; use crate::env::env_var; use crate::path_helpers::cwd; use crate::util::set_host_compiler_dylib_path; -use crate::{is_aix, is_darwin, is_msvc, is_windows, target, uname}; +use crate::{is_aix, is_darwin, is_windows, is_windows_msvc, target, uname}; /// Construct a new `rustc` invocation. This will automatically set the library /// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this. @@ -377,7 +377,7 @@ impl Rustc { // So we end up with the following hack: we link use static:-bundle to only // link the parts of libstdc++ that we actually use, which doesn't include // the dependency on the pthreads DLL. - if !is_msvc() { + if !is_windows_msvc() { self.cmd.arg("-lstatic:-bundle=stdc++"); }; } else if is_darwin() { diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 67d8c351a59fb..29cd6c4ad1591 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -3,9 +3,6 @@ //! notably is built via cargo: this means that if your test wants some non-trivial utility, such //! as `object` or `wasmparser`, they can be re-exported and be made available through this library. -// We want to control use declaration ordering and spacing (and preserve use group comments), so -// skip rustfmt on this file. -#![cfg_attr(rustfmt, rustfmt::skip)] #![warn(unreachable_pub)] mod command; @@ -22,8 +19,8 @@ pub mod path_helpers; pub mod run; pub mod scoped_run; pub mod string; -pub mod targets; pub mod symbols; +pub mod targets; // Internally we call our fs-related support module as `fs`, but re-export its content as `rfs` // to tests to avoid colliding with commonly used `use std::fs;`. @@ -36,77 +33,56 @@ pub mod rfs { } // Re-exports of third-party library crates. -// tidy-alphabetical-start -pub use bstr; -pub use gimli; -pub use libc; -pub use object; -pub use regex; -pub use serde_json; -pub use similar; -pub use wasmparser; -// tidy-alphabetical-end +pub use {bstr, gimli, libc, object, regex, serde_json, similar, wasmparser}; -// Re-exports of external dependencies. -pub use external_deps::{ - cargo, c_build, c_cxx_compiler, clang, htmldocck, llvm, python, rustc, rustdoc +// Helpers for building names of output artifacts that are potentially target-specific. +pub use crate::artifact_names::{ + bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name, + static_lib_name, }; - -// These rely on external dependencies. -pub use c_cxx_compiler::{Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc}; -pub use c_build::{ +pub use crate::assertion_helpers::{ + assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals, + assert_not_contains, assert_not_contains_regex, +}; +// `diff` is implemented in terms of the [similar] library. +// +// [similar]: https://github.com/mitsuhiko/similar +pub use crate::diff::{Diff, diff}; +// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers. +pub use crate::env::{env_var, env_var_os, set_current_dir}; +pub use crate::external_deps::c_build::{ build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_cxx, build_native_static_lib_optimized, }; -pub use cargo::cargo; -pub use clang::{clang, Clang}; -pub use htmldocck::htmldocck; -pub use llvm::{ - llvm_ar, llvm_bcanalyzer, llvm_dis, llvm_dwarfdump, llvm_filecheck, llvm_nm, llvm_objcopy, - llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, LlvmBcanalyzer, LlvmDis, LlvmDwarfdump, - LlvmFilecheck, LlvmNm, LlvmObjcopy, LlvmObjdump, LlvmProfdata, LlvmReadobj, -}; -pub use python::python_command; -pub use rustc::{bare_rustc, rustc, rustc_path, Rustc}; -pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc}; - -/// [`diff`][mod@diff] is implemented in terms of the [similar] library. -/// -/// [similar]: https://github.com/mitsuhiko/similar -pub use diff::{diff, Diff}; - -/// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers. -pub use env::{env_var, env_var_os, set_current_dir}; - -/// Convenience helpers for running binaries and other commands. -pub use run::{cmd, run, run_fail, run_with_args}; - -/// Helpers for checking target information. -pub use targets::{ - apple_os, is_aix, is_darwin, is_msvc, is_windows, is_windows_gnu, is_windows_msvc, is_win7, llvm_components_contain, - target, uname, +// Re-exports of external dependencies. +pub use crate::external_deps::c_cxx_compiler::{ + Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc, }; - -/// Helpers for building names of output artifacts that are potentially target-specific. -pub use artifact_names::{ - bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name, - static_lib_name, +pub use crate::external_deps::cargo::cargo; +pub use crate::external_deps::clang::{Clang, clang}; +pub use crate::external_deps::htmldocck::htmldocck; +pub use crate::external_deps::llvm::{ + self, LlvmAr, LlvmBcanalyzer, LlvmDis, LlvmDwarfdump, LlvmFilecheck, LlvmNm, LlvmObjcopy, + LlvmObjdump, LlvmProfdata, LlvmReadobj, llvm_ar, llvm_bcanalyzer, llvm_dis, llvm_dwarfdump, + llvm_filecheck, llvm_nm, llvm_objcopy, llvm_objdump, llvm_profdata, llvm_readobj, }; - -/// Path-related helpers. -pub use path_helpers::{ +pub use crate::external_deps::python::python_command; +pub use crate::external_deps::rustc::{self, Rustc, bare_rustc, rustc, rustc_path}; +pub use crate::external_deps::rustdoc::{Rustdoc, bare_rustdoc, rustdoc}; +// Path-related helpers. +pub use crate::path_helpers::{ build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix, has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root, }; - -/// Helpers for scoped test execution where certain properties are attempted to be maintained. -pub use scoped_run::{run_in_tmpdir, test_while_readonly}; - -pub use assertion_helpers::{ - assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals, - assert_not_contains, assert_not_contains_regex, -}; - -pub use string::{ +// Convenience helpers for running binaries and other commands. +pub use crate::run::{cmd, run, run_fail, run_with_args}; +// Helpers for scoped test execution where certain properties are attempted to be maintained. +pub use crate::scoped_run::{run_in_tmpdir, test_while_readonly}; +pub use crate::string::{ count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains, }; +// Helpers for checking target information. +pub use crate::targets::{ + apple_os, is_aix, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc, + llvm_components_contain, target, uname, +}; diff --git a/src/tools/run-make-support/src/linker.rs b/src/tools/run-make-support/src/linker.rs index 89093cf011393..b2893ad88fe21 100644 --- a/src/tools/run-make-support/src/linker.rs +++ b/src/tools/run-make-support/src/linker.rs @@ -1,6 +1,6 @@ use regex::Regex; -use crate::{Rustc, is_msvc}; +use crate::{Rustc, is_windows_msvc}; /// Asserts that `rustc` uses LLD for linking when executed. pub fn assert_rustc_uses_lld(rustc: &mut Rustc) { @@ -22,7 +22,7 @@ pub fn assert_rustc_doesnt_use_lld(rustc: &mut Rustc) { fn get_stderr_with_linker_messages(rustc: &mut Rustc) -> String { // lld-link is used if msvc, otherwise a gnu-compatible lld is used. - let linker_version_flag = if is_msvc() { "--version" } else { "-Wl,-v" }; + let linker_version_flag = if is_windows_msvc() { "--version" } else { "-Wl,-v" }; let output = rustc.arg("-Wlinker-messages").link_arg(linker_version_flag).run(); output.stderr_utf8() diff --git a/src/tools/run-make-support/src/targets.rs b/src/tools/run-make-support/src/targets.rs index 1ab2e2ab2be40..b20e12561fbfa 100644 --- a/src/tools/run-make-support/src/targets.rs +++ b/src/tools/run-make-support/src/targets.rs @@ -16,10 +16,10 @@ pub fn is_windows() -> bool { target().contains("windows") } -/// Check if target uses msvc. +/// Check if target is windows-msvc. #[must_use] -pub fn is_msvc() -> bool { - target().contains("msvc") +pub fn is_windows_msvc() -> bool { + target().ends_with("windows-msvc") } /// Check if target is windows-gnu. @@ -28,12 +28,6 @@ pub fn is_windows_gnu() -> bool { target().ends_with("windows-gnu") } -/// Check if target is windows-msvc. -#[must_use] -pub fn is_windows_msvc() -> bool { - target().ends_with("windows-msvc") -} - /// Check if target is win7. #[must_use] pub fn is_win7() -> bool { diff --git a/tests/run-make/archive-duplicate-names/rmake.rs b/tests/run-make/archive-duplicate-names/rmake.rs index 62a3556619984..0c352b3ae1b57 100644 --- a/tests/run-make/archive-duplicate-names/rmake.rs +++ b/tests/run-make/archive-duplicate-names/rmake.rs @@ -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(); diff --git a/tests/run-make/c-link-to-rust-dylib/rmake.rs b/tests/run-make/c-link-to-rust-dylib/rmake.rs index 3a48af8a3665a..ece0c81d2da6e 100644 --- a/tests/run-make/c-link-to-rust-dylib/rmake.rs +++ b/tests/run-make/c-link-to-rust-dylib/rmake.rs @@ -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(); diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs b/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs index 62e1748b6fb92..ba5fe589acb03 100644 --- a/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs +++ b/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs @@ -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(); diff --git a/tests/run-make/cdylib-dylib-linkage/rmake.rs b/tests/run-make/cdylib-dylib-linkage/rmake.rs index a8fd8e2d16848..3c145d9f99cf3 100644 --- a/tests/run-make/cdylib-dylib-linkage/rmake.rs +++ b/tests/run-make/cdylib-dylib-linkage/rmake.rs @@ -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") }); diff --git a/tests/run-make/cdylib/rmake.rs b/tests/run-make/cdylib/rmake.rs index 21b83d1b1a91f..21fd8b486c489 100644 --- a/tests/run-make/cdylib/rmake.rs +++ b/tests/run-make/cdylib/rmake.rs @@ -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(); diff --git a/tests/run-make/compiler-rt-works-on-mingw/rmake.rs b/tests/run-make/compiler-rt-works-on-mingw/rmake.rs index f1b41f96312de..b15e56db1bb75 100644 --- a/tests/run-make/compiler-rt-works-on-mingw/rmake.rs +++ b/tests/run-make/compiler-rt-works-on-mingw/rmake.rs @@ -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(); diff --git a/tests/run-make/link-args-order/rmake.rs b/tests/run-make/link-args-order/rmake.rs index 7a67c12f74c8d..e3c730bfec55e 100644 --- a/tests/run-make/link-args-order/rmake.rs +++ b/tests/run-make/link-args-order/rmake.rs @@ -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") diff --git a/tests/run-make/link-dedup/rmake.rs b/tests/run-make/link-dedup/rmake.rs index 874e6e0083bdf..84fdf87e9c70e 100644 --- a/tests/run-make/link-dedup/rmake.rs +++ b/tests/run-make/link-dedup/rmake.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(); diff --git a/tests/run-make/native-link-modifier-bundle/rmake.rs b/tests/run-make/native-link-modifier-bundle/rmake.rs index 058b66b15f12f..64ee7733498ec 100644 --- a/tests/run-make/native-link-modifier-bundle/rmake.rs +++ b/tests/run-make/native-link-modifier-bundle/rmake.rs @@ -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() diff --git a/tests/run-make/native-link-modifier-whole-archive/rmake.rs b/tests/run-make/native-link-modifier-whole-archive/rmake.rs index b8b814043e5cd..90b0203e278c9 100644 --- a/tests/run-make/native-link-modifier-whole-archive/rmake.rs +++ b/tests/run-make/native-link-modifier-whole-archive/rmake.rs @@ -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"), diff --git a/tests/run-make/pointer-auth-link-with-c/rmake.rs b/tests/run-make/pointer-auth-link-with-c/rmake.rs index 7b6dff10eaec0..a4d7454e5755a 100644 --- a/tests/run-make/pointer-auth-link-with-c/rmake.rs +++ b/tests/run-make/pointer-auth-link-with-c/rmake.rs @@ -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"); diff --git a/tests/run-make/print-native-static-libs/rmake.rs b/tests/run-make/print-native-static-libs/rmake.rs index a51ac934c722e..4502c874cae60 100644 --- a/tests/run-make/print-native-static-libs/rmake.rs +++ b/tests/run-make/print-native-static-libs/rmake.rs @@ -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); diff --git a/tests/run-make/raw-dylib-alt-calling-convention/rmake.rs b/tests/run-make/raw-dylib-alt-calling-convention/rmake.rs index 1a1622f275421..0843c6beae823 100644 --- a/tests/run-make/raw-dylib-alt-calling-convention/rmake.rs +++ b/tests/run-make/raw-dylib-alt-calling-convention/rmake.rs @@ -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") diff --git a/tests/run-make/raw-dylib-import-name-type/rmake.rs b/tests/run-make/raw-dylib-import-name-type/rmake.rs index 13a2c99150e5b..71f255ab39f06 100644 --- a/tests/run-make/raw-dylib-import-name-type/rmake.rs +++ b/tests/run-make/raw-dylib-import-name-type/rmake.rs @@ -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") diff --git a/tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs b/tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs index 6e3b31a0cdbdc..a167e8198a7c8 100644 --- a/tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs +++ b/tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs @@ -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") diff --git a/tests/run-make/raw-dylib-link-ordinal/rmake.rs b/tests/run-make/raw-dylib-link-ordinal/rmake.rs index b52181ae3f9d6..43274b9765bb1 100644 --- a/tests/run-make/raw-dylib-link-ordinal/rmake.rs +++ b/tests/run-make/raw-dylib-link-ordinal/rmake.rs @@ -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") diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs b/tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs index 320ea1520d85f..f898cc0f8c8d4 100644 --- a/tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs +++ b/tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs @@ -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") diff --git a/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs b/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs index ff0438a6b72be..f0929a3ee85eb 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs +++ b/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs @@ -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"); diff --git a/tests/run-make/split-debuginfo/rmake.rs b/tests/run-make/split-debuginfo/rmake.rs index 530a5d119f136..e8de5aed17260 100644 --- a/tests/run-make/split-debuginfo/rmake.rs +++ b/tests/run-make/split-debuginfo/rmake.rs @@ -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 . @@ -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); diff --git a/tests/run-make/static-dylib-by-default/rmake.rs b/tests/run-make/static-dylib-by-default/rmake.rs index 133210c74e75a..b1160c632972d 100644 --- a/tests/run-make/static-dylib-by-default/rmake.rs +++ b/tests/run-make/static-dylib-by-default/rmake.rs @@ -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"); diff --git a/tests/run-make/staticlib-dylib-linkage/rmake.rs b/tests/run-make/staticlib-dylib-linkage/rmake.rs index 8dd1ac0ffbdcd..9582ca19831c0 100644 --- a/tests/run-make/staticlib-dylib-linkage/rmake.rs +++ b/tests/run-make/staticlib-dylib-linkage/rmake.rs @@ -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::>(); - if is_msvc() { + if is_windows_msvc() { // For MSVC pass the arguments on to the linker. native_link_args.insert(0, "-link"); } diff --git a/tests/run-make/symbol-visibility/rmake.rs b/tests/run-make/symbol-visibility/rmake.rs index 49c8e87707b64..e3d276d6da89b 100644 --- a/tests/run-make/symbol-visibility/rmake.rs +++ b/tests/run-make/symbol-visibility/rmake.rs @@ -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(