From 6fffe848e3575292ac67d550298a6f169528fd6c Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 14 Jun 2024 16:54:08 -0400 Subject: [PATCH] rewrite native-link-modifier-linker to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../Makefile | 15 ------- .../rmake.rs | 41 +++++++++++++++++++ .../rmake.rs | 7 +++- .../rmake.rs | 5 ++- 5 files changed, 50 insertions(+), 19 deletions(-) delete mode 100644 tests/run-make/native-link-modifier-verbatim-linker/Makefile create mode 100644 tests/run-make/native-link-modifier-verbatim-linker/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 9689f2b355f..2e266cd1a64 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -142,7 +142,6 @@ run-make/missing-crate-dependency/Makefile run-make/mixing-libs/Makefile run-make/msvc-opt-minsize/Makefile run-make/native-link-modifier-bundle/Makefile -run-make/native-link-modifier-verbatim-linker/Makefile run-make/native-link-modifier-whole-archive/Makefile run-make/no-alloc-shim/Makefile run-make/no-builtins-attribute/Makefile diff --git a/tests/run-make/native-link-modifier-verbatim-linker/Makefile b/tests/run-make/native-link-modifier-verbatim-linker/Makefile deleted file mode 100644 index 47ed2a14291..00000000000 --- a/tests/run-make/native-link-modifier-verbatim-linker/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# ignore-cross-compile -# ignore-apple - -include ../tools.mk - -all: - # Verbatim allows specify precise name. - $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/local_some_strange_name.ext - $(RUSTC) main.rs -l static:+verbatim=local_some_strange_name.ext - - # With verbatim any other name cannot be used (local). - $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/liblocal_native_dep.a - $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/local_native_dep.a - $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/local_native_dep.lib - $(RUSTC) main.rs -l static:+verbatim=local_native_dep 2>&1 | $(CGREP) "local_native_dep" diff --git a/tests/run-make/native-link-modifier-verbatim-linker/rmake.rs b/tests/run-make/native-link-modifier-verbatim-linker/rmake.rs new file mode 100644 index 00000000000..6868cb368cc --- /dev/null +++ b/tests/run-make/native-link-modifier-verbatim-linker/rmake.rs @@ -0,0 +1,41 @@ +// `verbatim` is a native link modifier that forces rustc to only accept libraries with +// a specified name. This test checks that this modifier works as intended. +// This test is the same as native-link-modifier-rustc, but without rlibs. +// See https://github.com/rust-lang/rust/issues/99425 + +//@ ignore-apple +// Reason: linking fails due to the unusual ".ext" staticlib name. + +use run_make_support::rustc; + +fn main() { + // Verbatim allows for the specification of a precise name + // - in this case, the unconventional ".ext" extension. + rustc() + .input("local_native_dep.rs") + .crate_type("staticlib") + .output("local_some_strange_name.ext") + .run(); + rustc().input("main.rs").arg("-lstatic:+verbatim=local_some_strange_name.ext").run(); + + // This section voluntarily avoids using static_lib_name helpers to be verbatim. + // With verbatim, even these common library names are refused + // - it wants local_native_dep without + // any file extensions. + rustc() + .input("local_native_dep.rs") + .crate_type("staticlib") + .output("liblocal_native_dep.a") + .run(); + rustc().input("local_native_dep.rs").crate_type("staticlib").output("local_native_dep.a").run(); + rustc() + .input("local_native_dep.rs") + .crate_type("staticlib") + .output("local_native_dep.lib") + .run(); + rustc() + .input("main.rs") + .arg("-lstatic:+verbatim=local_native_dep") + .run_fail() + .assert_stderr_contains("local_native_dep"); +} diff --git a/tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs b/tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs index 58c7fef232c..703b8a80ef3 100644 --- a/tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs +++ b/tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs @@ -1,11 +1,13 @@ // `verbatim` is a native link modifier that forces rustc to only accept libraries with // a specified name. This test checks that this modifier works as intended. +// This test is the same as native-link-modifier-linker, but with rlibs. // See https://github.com/rust-lang/rust/issues/99425 use run_make_support::rustc; fn main() { - // Verbatim allows for the specification of a precise name - in this case, the unconventional ".ext" extension. + // Verbatim allows for the specification of a precise name + // - in this case, the unconventional ".ext" extension. rustc() .input("upstream_native_dep.rs") .crate_type("staticlib") @@ -18,7 +20,8 @@ fn main() { .run(); // This section voluntarily avoids using static_lib_name helpers to be verbatim. - // With verbatim, even these common library names are refused - it wants upstream_native_dep without + // With verbatim, even these common library names are refused + // - it wants upstream_native_dep without // any file extensions. rustc() .input("upstream_native_dep.rs") diff --git a/tests/run-make/output-filename-conflicts-with-directory/rmake.rs b/tests/run-make/output-filename-conflicts-with-directory/rmake.rs index 245bc395f14..4b5c9e8d118 100644 --- a/tests/run-make/output-filename-conflicts-with-directory/rmake.rs +++ b/tests/run-make/output-filename-conflicts-with-directory/rmake.rs @@ -1,3 +1,4 @@ +// ignore-tidy-linelength // When the compiled executable would conflict with a directory, a // rustc error should be displayed instead of a verbose and // potentially-confusing linker error. @@ -7,5 +8,7 @@ fn main() { fs_wrapper::create_dir("foo"); - rustc().input("foo.rs").output("foo").run_fail().assert_stderr_contains(r#"the generated executable for the input file "foo.rs" conflicts with the existing directory "foo""#); + rustc().input("foo.rs").output("foo").run_fail().assert_stderr_contains( + r#"the generated executable for the input file "foo.rs" conflicts with the existing directory "foo""#, + ); }