From 27ff241027180605252987ad1f90d6d5c2c6c72b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Jun 2024 11:51:08 +0200 Subject: [PATCH 1/4] Add new `MSVC_LIB_PATH` runtest environment variable to know location of the `msvc_lib` binary --- src/tools/compiletest/src/runtest.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 5398820313648..7e7f98a13548f 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3382,6 +3382,7 @@ impl<'test> TestCx<'test> { cmd.env("IS_MSVC", "1") .env("IS_WINDOWS", "1") .env("MSVC_LIB", format!("'{}' -nologo", lib.display())) + .env("MSVC_LIB_PATH", format!("{}", lib.display())) .env("CC", format!("'{}' {}", self.config.cc, cflags)) .env("CXX", format!("'{}' {}", &self.config.cxx, cxxflags)); } else { @@ -3752,6 +3753,7 @@ impl<'test> TestCx<'test> { cmd.env("IS_MSVC", "1") .env("IS_WINDOWS", "1") .env("MSVC_LIB", format!("'{}' -nologo", lib.display())) + .env("MSVC_LIB_PATH", format!("{}", lib.display())) // Note: we diverge from legacy run_make and don't lump `CC` the compiler and // default flags together. .env("CC_DEFAULT_FLAGS", &cflags) From 33c4a6f47f00dd68985a046bad9000934b70dbea Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Jun 2024 11:51:30 +0200 Subject: [PATCH 2/4] Add `run_make_support::build_native_static_lib` function --- src/tools/run-make-support/src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index b85191970de62..4228ff03a9866 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -55,7 +55,21 @@ pub use python::python_command; pub use rustc::{aux_build, bare_rustc, rustc, Rustc}; pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc}; -/// [`diff`][mod@diff] is implemented in terms of the [similar] library. +/// Implement common helpers for command wrappers. This assumes that the command wrapper is a struct +/// containing a `cmd: Command` field and a `output` function. The provided helpers are: +/// +/// 1. Generic argument acceptors: `arg` and `args` (delegated to [`Command`]). These are intended +/// to be *fallback* argument acceptors, when specific helpers don't make sense. Prefer to add +/// new specific helper methods over relying on these generic argument providers. +/// 2. Environment manipulation methods: `env`, `env_remove` and `env_clear`: these delegate to +/// methods of the same name on [`Command`]. +/// 3. Output and execution: `output`, `run` and `run_fail` are provided. `output` waits for the +/// command to finish running and returns the process's [`Output`]. `run` and `run_fail` are +/// higher-level convenience methods which waits for the command to finish running and assert +/// that the command successfully ran or failed as expected. Prefer `run` and `run_fail` when +/// possible. +/// +/// Example usage: /// /// [similar]: https://github.com/mitsuhiko/similar pub use diff::{diff, Diff}; From 9638dd77cc84c0cd1fd164b75d14702074e83a93 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Jun 2024 11:53:00 +0200 Subject: [PATCH 3/4] Migrate `run-make/issue-15460` to `rmake.rs` --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/issue-15460/Makefile | 7 ------- tests/run-make/issue-15460/rmake.rs | 12 ++++++++++++ 3 files changed, 12 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/issue-15460/Makefile create mode 100644 tests/run-make/issue-15460/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 1cb52ea91f9c2..c36bc0869ddc3 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -31,7 +31,6 @@ run-make/incr-foreign-head-span/Makefile run-make/interdependent-c-libraries/Makefile run-make/issue-107094/Makefile run-make/issue-14698/Makefile -run-make/issue-15460/Makefile run-make/issue-33329/Makefile run-make/issue-35164/Makefile run-make/issue-36710/Makefile diff --git a/tests/run-make/issue-15460/Makefile b/tests/run-make/issue-15460/Makefile deleted file mode 100644 index a36a085fa6f18..0000000000000 --- a/tests/run-make/issue-15460/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic - $(RUSTC) bar.rs - $(call RUN,bar) diff --git a/tests/run-make/issue-15460/rmake.rs b/tests/run-make/issue-15460/rmake.rs new file mode 100644 index 0000000000000..6f2c0d4e59536 --- /dev/null +++ b/tests/run-make/issue-15460/rmake.rs @@ -0,0 +1,12 @@ +//@ ignore-cross-compile + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("foo"); + + rustc().input("foo.rs").extra_filename("-383hf8").arg("-Cprefer-dynamic").run(); + rustc().input("bar.rs").run(); + + run("bar"); +} From 7ad48c76191d6d02e6c194effee8528b9b9779f3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Jun 2024 14:20:39 +0200 Subject: [PATCH 4/4] Rename `tests/run-make/issue-15460` into `tests/run-make/link-native-static-lib-to-dylib` --- .../{issue-15460 => link-native-static-lib-to-dylib}/bar.rs | 0 .../{issue-15460 => link-native-static-lib-to-dylib}/foo.c | 0 .../{issue-15460 => link-native-static-lib-to-dylib}/foo.rs | 0 .../{issue-15460 => link-native-static-lib-to-dylib}/rmake.rs | 2 ++ 4 files changed, 2 insertions(+) rename tests/run-make/{issue-15460 => link-native-static-lib-to-dylib}/bar.rs (100%) rename tests/run-make/{issue-15460 => link-native-static-lib-to-dylib}/foo.c (100%) rename tests/run-make/{issue-15460 => link-native-static-lib-to-dylib}/foo.rs (100%) rename tests/run-make/{issue-15460 => link-native-static-lib-to-dylib}/rmake.rs (78%) diff --git a/tests/run-make/issue-15460/bar.rs b/tests/run-make/link-native-static-lib-to-dylib/bar.rs similarity index 100% rename from tests/run-make/issue-15460/bar.rs rename to tests/run-make/link-native-static-lib-to-dylib/bar.rs diff --git a/tests/run-make/issue-15460/foo.c b/tests/run-make/link-native-static-lib-to-dylib/foo.c similarity index 100% rename from tests/run-make/issue-15460/foo.c rename to tests/run-make/link-native-static-lib-to-dylib/foo.c diff --git a/tests/run-make/issue-15460/foo.rs b/tests/run-make/link-native-static-lib-to-dylib/foo.rs similarity index 100% rename from tests/run-make/issue-15460/foo.rs rename to tests/run-make/link-native-static-lib-to-dylib/foo.rs diff --git a/tests/run-make/issue-15460/rmake.rs b/tests/run-make/link-native-static-lib-to-dylib/rmake.rs similarity index 78% rename from tests/run-make/issue-15460/rmake.rs rename to tests/run-make/link-native-static-lib-to-dylib/rmake.rs index 6f2c0d4e59536..0746c3963143b 100644 --- a/tests/run-make/issue-15460/rmake.rs +++ b/tests/run-make/link-native-static-lib-to-dylib/rmake.rs @@ -1,3 +1,5 @@ +// Regression test for . + //@ ignore-cross-compile use run_make_support::{build_native_static_lib, run, rustc};