From f2cce98149b78e2880e2e81e03c2cc94ff5a29a5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 12 Jun 2024 10:52:44 +0200 Subject: [PATCH 1/3] Migrate `run-make/prefer-rlib` to `rmake.rs` --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/prefer-rlib/Makefile | 9 --------- tests/run-make/prefer-rlib/rmake.rs | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 10 deletions(-) delete mode 100644 tests/run-make/prefer-rlib/Makefile create mode 100644 tests/run-make/prefer-rlib/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 448d4887d32cb..ac89a30f35342 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -175,7 +175,6 @@ run-make/pgo-gen/Makefile run-make/pgo-indirect-call-promotion/Makefile run-make/pgo-use/Makefile run-make/pointer-auth-link-with-c/Makefile -run-make/prefer-rlib/Makefile run-make/pretty-print-to-file/Makefile run-make/pretty-print-with-dep-file/Makefile run-make/print-calling-conventions/Makefile diff --git a/tests/run-make/prefer-rlib/Makefile b/tests/run-make/prefer-rlib/Makefile deleted file mode 100644 index 2e86b9c1dd7e0..0000000000000 --- a/tests/run-make/prefer-rlib/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib - ls $(TMPDIR)/$(call RLIB_GLOB,bar) - $(RUSTC) foo.rs - rm $(TMPDIR)/*bar* - $(call RUN,foo) diff --git a/tests/run-make/prefer-rlib/rmake.rs b/tests/run-make/prefer-rlib/rmake.rs new file mode 100644 index 0000000000000..1d336a0790322 --- /dev/null +++ b/tests/run-make/prefer-rlib/rmake.rs @@ -0,0 +1,16 @@ +// Check that `foo.rs` prefers to link to `bar` statically, and can be executed even if the `bar` +// library artifacts are removed. + +//@ ignore-cross-compile + +use run_make_support::{dynamic_lib_name, path, run, rust_lib_name, rustc}; +use std::fs::remove_file; + +fn main() { + rustc().input("bar.rs").crate_type("dylib").crate_type("rlib").run(); + assert!(path(rust_lib_name("bar")).exists()); + rustc().input("foo.rs").run(); + remove_file(rust_lib_name("bar")).unwrap(); + remove_file(dynamic_lib_name("bar")).unwrap(); + run("foo"); +} From d79aeaf8981f331f16295e119d4a226842feaf3c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 12 Jun 2024 10:53:06 +0200 Subject: [PATCH 2/3] Remove unused import in `run-make/prefer-dylib/rmake.rs` --- tests/run-make/prefer-dylib/rmake.rs | 1 - tests/run-make/prefer-rlib/rmake.rs | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/run-make/prefer-dylib/rmake.rs b/tests/run-make/prefer-dylib/rmake.rs index ad9fd8a15a2c0..5b2b064967386 100644 --- a/tests/run-make/prefer-dylib/rmake.rs +++ b/tests/run-make/prefer-dylib/rmake.rs @@ -2,7 +2,6 @@ use run_make_support::{cwd, dynamic_lib_name, read_dir, run, run_fail, rustc}; use std::fs::remove_file; -use std::process::Command; fn main() { rustc().input("bar.rs").crate_type("dylib").crate_type("rlib").arg("-Cprefer-dynamic").run(); diff --git a/tests/run-make/prefer-rlib/rmake.rs b/tests/run-make/prefer-rlib/rmake.rs index 1d336a0790322..96861a264e621 100644 --- a/tests/run-make/prefer-rlib/rmake.rs +++ b/tests/run-make/prefer-rlib/rmake.rs @@ -3,14 +3,13 @@ //@ ignore-cross-compile -use run_make_support::{dynamic_lib_name, path, run, rust_lib_name, rustc}; -use std::fs::remove_file; +use run_make_support::{dynamic_lib_name, fs_wrapper, path, run, rust_lib_name, rustc}; fn main() { rustc().input("bar.rs").crate_type("dylib").crate_type("rlib").run(); assert!(path(rust_lib_name("bar")).exists()); rustc().input("foo.rs").run(); - remove_file(rust_lib_name("bar")).unwrap(); - remove_file(dynamic_lib_name("bar")).unwrap(); + fs_wrapper::remove_file(rust_lib_name("bar")); + fs_wrapper::remove_file(dynamic_lib_name("bar")); run("foo"); } From 45a9bd5d40d1674af33287088dbc24bd092541ac Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 12 Jun 2024 11:46:05 +0200 Subject: [PATCH 3/3] Use `fs_wrapper` in `run-make/prefer-dylib` --- tests/run-make/prefer-dylib/rmake.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/run-make/prefer-dylib/rmake.rs b/tests/run-make/prefer-dylib/rmake.rs index 5b2b064967386..6b3b3ad6d3b8a 100644 --- a/tests/run-make/prefer-dylib/rmake.rs +++ b/tests/run-make/prefer-dylib/rmake.rs @@ -1,7 +1,6 @@ //@ ignore-cross-compile -use run_make_support::{cwd, dynamic_lib_name, read_dir, run, run_fail, rustc}; -use std::fs::remove_file; +use run_make_support::{cwd, dynamic_lib_name, fs_wrapper, read_dir, run, run_fail, rustc}; fn main() { rustc().input("bar.rs").crate_type("dylib").crate_type("rlib").arg("-Cprefer-dynamic").run(); @@ -9,7 +8,7 @@ fn main() { run("foo"); - remove_file(dynamic_lib_name("bar")).unwrap(); + fs_wrapper::remove_file(dynamic_lib_name("bar")); // This time the command should fail. run_fail("foo"); }