From 29113bfb1b7dad0d051579721a1875d00b93111e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 23 Jun 2024 15:11:57 +0200 Subject: [PATCH 1/2] Add `ar_command` in `run_make_support` --- src/tools/run-make-support/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 487132683e920..14b4f14e8f0cd 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -61,6 +61,14 @@ pub fn target() -> String { env_var("TARGET") } +/// `AR` +#[track_caller] +#[must_use] +pub fn ar_command() -> Command { + let ar_path = env_var("AR"); + Command::new(ar_path) +} + /// Check if target is windows-like. #[must_use] pub fn is_windows() -> bool { From 10990e29cf98d1e0babecf12d948340bf13b9b52 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 23 Jun 2024 15:12:17 +0200 Subject: [PATCH 2/2] Migrate `run-make/invalid-library` to `rmake.rs` --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/invalid-library/Makefile | 6 ------ tests/run-make/invalid-library/rmake.rs | 8 ++++++++ 3 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/invalid-library/Makefile create mode 100644 tests/run-make/invalid-library/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 07073ef5d40c7..d90b19c024ec8 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -54,7 +54,6 @@ run-make/incr-add-rust-src-component/Makefile run-make/incr-foreign-head-span/Makefile run-make/interdependent-c-libraries/Makefile run-make/intrinsic-unreachable/Makefile -run-make/invalid-library/Makefile run-make/invalid-so/Makefile run-make/issue-107094/Makefile run-make/issue-109934-lto-debuginfo/Makefile diff --git a/tests/run-make/invalid-library/Makefile b/tests/run-make/invalid-library/Makefile deleted file mode 100644 index 910d9af7b0564..0000000000000 --- a/tests/run-make/invalid-library/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -include ../tools.mk - -all: - touch $(TMPDIR)/lib.rmeta - $(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/lib.rmeta - $(RUSTC) foo.rs 2>&1 | $(CGREP) "found invalid metadata" diff --git a/tests/run-make/invalid-library/rmake.rs b/tests/run-make/invalid-library/rmake.rs new file mode 100644 index 0000000000000..e76b3f3b5d223 --- /dev/null +++ b/tests/run-make/invalid-library/rmake.rs @@ -0,0 +1,8 @@ +use run_make_support::fs_wrapper::create_file; +use run_make_support::{ar_command, rustc}; + +fn main() { + create_file("lib.rmeta"); + ar_command().arg("crus").arg("libfoo-ffffffff-1.0.rlib").arg("lib.rmeta").run(); + rustc().input("foo.rs").run_fail().assert_stderr_contains("found invalid metadata"); +}