From d80b45e22b41664c8b36ae296bed611868871807 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 23 Jun 2024 15:11:57 +0200 Subject: [PATCH 1/3] 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 62a5acc9ba660c9237abec43b013a9cd51aaa91a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 23 Jun 2024 15:12:17 +0200 Subject: [PATCH 2/3] 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"); +} From 22cac4688b13add278e4ed25d3cd9db5ab0569aa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 24 Jun 2024 11:05:54 +0200 Subject: [PATCH 3/3] Add `needs-ar` compiletest instruction --- src/tools/compiletest/src/header/needs.rs | 5 +++++ tests/run-make/invalid-library/rmake.rs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs index 5b2665f7d0ba7..06423697ee7d1 100644 --- a/src/tools/compiletest/src/header/needs.rs +++ b/src/tools/compiletest/src/header/needs.rs @@ -144,6 +144,11 @@ pub(super) fn handle_needs( condition: config.runner.as_ref().is_some_and(|r| r.contains("wasmtime")), ignore_reason: "ignored when wasmtime runner is not available", }, + Need { + name: "needs-ar", + condition: !config.target.contains("msvc"), + ignore_reason: "ignored when ar command is not available", + }, Need { name: "needs-symlink", condition: cache.symlinks, diff --git a/tests/run-make/invalid-library/rmake.rs b/tests/run-make/invalid-library/rmake.rs index e76b3f3b5d223..310c916f82ce3 100644 --- a/tests/run-make/invalid-library/rmake.rs +++ b/tests/run-make/invalid-library/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-ar + use run_make_support::fs_wrapper::create_file; use run_make_support::{ar_command, rustc};