From 115d7d33af2aa2c327e6c0647e136a9c5bea31f3 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Sun, 9 Jun 2024 16:37:31 -0400 Subject: [PATCH] rewrite prune-link-args to rmake format --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/compiler-lookup-paths/rmake.rs | 102 +++++++----------- tests/run-make/dump-mono-stats/rmake.rs | 9 +- tests/run-make/prune-link-args/Makefile | 10 -- tests/run-make/prune-link-args/empty.rs | 1 - tests/run-make/prune-link-args/rmake.rs | 15 +++ 6 files changed, 61 insertions(+), 77 deletions(-) delete mode 100644 tests/run-make/prune-link-args/Makefile delete mode 100644 tests/run-make/prune-link-args/empty.rs create mode 100644 tests/run-make/prune-link-args/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 3c52154a8c06f..0c741a3a91225 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -181,7 +181,6 @@ run-make/pretty-print-with-dep-file/Makefile run-make/print-calling-conventions/Makefile run-make/print-target-list/Makefile run-make/profile/Makefile -run-make/prune-link-args/Makefile run-make/raw-dylib-alt-calling-convention/Makefile run-make/raw-dylib-c/Makefile run-make/raw-dylib-cross-compilation/Makefile diff --git a/tests/run-make/compiler-lookup-paths/rmake.rs b/tests/run-make/compiler-lookup-paths/rmake.rs index f33076c37c793..52748dc2e720d 100644 --- a/tests/run-make/compiler-lookup-paths/rmake.rs +++ b/tests/run-make/compiler-lookup-paths/rmake.rs @@ -5,99 +5,75 @@ // fail to be used by the compiler. // See https://github.com/rust-lang/rust/pull/19941 -use run_make_support::fs_wrapper; -use run_make_support::{rmake_out_path, rustc}; +use run_make_support::{fs_wrapper, rustc}; fn main() { - assert!(rmake_out_path("libnative.a").exists()); - fs_wrapper::create_dir_all(rmake_out_path("crate")); - fs_wrapper::create_dir_all(rmake_out_path("native")); - fs_wrapper::rename(rmake_out_path("libnative.a"), rmake_out_path("native")); + assert!("libnative.a".exists()); + fs_wrapper::create_dir_all("crate"); + fs_wrapper::create_dir_all("native"); + fs_wrapper::rename("libnative.a", "native/libnative.a"); rustc().input("a.rs").run(); - fs_wrapper::rename(rmake_out_path("liba.a"), rmake_out_path("crate")); - rustc() - .input("b.rs") - .specific_library_search_path("native", rmake_out_path("crate")) - .run_fail(); - rustc() - .input("b.rs") - .specific_library_search_path("dependency", rmake_out_path("crate")) - .run_fail(); - rustc().input("b.rs").specific_library_search_path("crate", rmake_out_path("crate")).run(); - rustc().input("b.rs").specific_library_search_path("all", rmake_out_path("crate")).run(); + fs_wrapper::rename("liba.a", "crate/liba.a"); + rustc().input("b.rs").specific_library_search_path("native", "crate").run_fail(); + rustc().input("b.rs").specific_library_search_path("dependency", "crate").run_fail(); + rustc().input("b.rs").specific_library_search_path("crate", "crate").run(); + rustc().input("b.rs").specific_library_search_path("all", "crate").run(); - rustc() - .input("c.rs") - .specific_library_search_path("native", rmake_out_path("crate")) - .run_fail(); - rustc().input("c.rs").specific_library_search_path("crate", rmake_out_path("crate")).run_fail(); - rustc().input("c.rs").specific_library_search_path("dependency", rmake_out_path("crate")).run(); - rustc().input("c.rs").specific_library_search_path("all", rmake_out_path("crate")).run(); + rustc().input("c.rs").specific_library_search_path("native", "crate").run_fail(); + rustc().input("c.rs").specific_library_search_path("crate", "crate").run_fail(); + rustc().input("c.rs").specific_library_search_path("dependency", "crate").run(); + rustc().input("c.rs").specific_library_search_path("all", "crate").run(); - rustc() - .input("d.rs") - .specific_library_search_path("dependency", rmake_out_path("native")) - .run_fail(); - rustc() - .input("d.rs") - .specific_library_search_path("crate", rmake_out_path("native")) - .run_fail(); - rustc().input("d.rs").specific_library_search_path("native", rmake_out_path("native")).run(); - rustc().input("d.rs").specific_library_search_path("all", rmake_out_path("native")).run(); + rustc().input("d.rs").specific_library_search_path("dependency", "native").run_fail(); + rustc().input("d.rs").specific_library_search_path("crate", "native").run_fail(); + rustc().input("d.rs").specific_library_search_path("native", "native").run(); + rustc().input("d.rs").specific_library_search_path("all", "native").run(); // Deduplication tests. - fs_wrapper::create_dir_all(rmake_out_path("e1")); - fs_wrapper::create_dir_all(rmake_out_path("e2")); + fs_wrapper::create_dir_all("e1"); + fs_wrapper::create_dir_all("e2"); - rustc().input("e.rs").output(rmake_out_path("e1/libe.rlib")).run(); - rustc().input("e.rs").output(rmake_out_path("e2/libe.rlib")).run(); + rustc().input("e.rs").output("e1/libe.rlib").run(); + rustc().input("e.rs").output("e2/libe.rlib").run(); // If the library hash is correct, compilation should succeed. + rustc().input("f.rs").library_search_path("e1").library_search_path("e2").run(); rustc() .input("f.rs") - .library_search_path(rmake_out_path("e1")) - .library_search_path(rmake_out_path("e2")) - .run(); - rustc() - .input("f.rs") - .specific_library_search_path("crate", rmake_out_path("e1")) - .library_search_path(rmake_out_path("e2")) + .specific_library_search_path("crate", "e1") + .library_search_path("e2") .run(); rustc() .input("f.rs") - .specific_library_search_path("crate", rmake_out_path("e1")) - .specific_library_search_path("crate", rmake_out_path("e2")) + .specific_library_search_path("crate", "e1") + .specific_library_search_path("crate", "e2") .run(); // If the library has a different hash, errors should occur. - rustc().input("e2.rs").output(rmake_out_path("e2/libe.rlib")).run(); - rustc() - .input("f.rs") - .library_search_path(rmake_out_path("e1")) - .library_search_path(rmake_out_path("e2")) - .run_fail(); + rustc().input("e2.rs").output("e2/libe.rlib").run(); + rustc().input("f.rs").library_search_path("e1").library_search_path("e2").run_fail(); rustc() .input("f.rs") - .specific_library_search_path("crate", rmake_out_path("e1")) - .library_search_path(rmake_out_path("e2")) + .specific_library_search_path("crate", "e1") + .library_search_path("e2") .run_fail(); rustc() .input("f.rs") - .specific_library_search_path("crate", rmake_out_path("e1")) - .specific_library_search_path("crate", rmake_out_path("e2")) + .specific_library_search_path("crate", "e1") + .specific_library_search_path("crate", "e2") .run_fail(); // Native and dependency paths do not cause errors. rustc() .input("f.rs") - .specific_library_search_path("native", rmake_out_path("e1")) - .library_search_path(rmake_out_path("e2")) + .specific_library_search_path("native", "e1") + .library_search_path("e2") .run(); rustc() .input("f.rs") - .specific_library_search_path("dependency", rmake_out_path("e1")) - .library_search_path(rmake_out_path("e2")) + .specific_library_search_path("dependency", "e1") + .library_search_path("e2") .run(); rustc() .input("f.rs") - .specific_library_search_path("dependency", rmake_out_path("e1")) - .specific_library_search_path("crate", rmake_out_path("e2")) + .specific_library_search_path("dependency", "e1") + .specific_library_search_path("crate", "e2") .run(); } diff --git a/tests/run-make/dump-mono-stats/rmake.rs b/tests/run-make/dump-mono-stats/rmake.rs index 67915959e6da9..8ad1aab0bc2ed 100644 --- a/tests/run-make/dump-mono-stats/rmake.rs +++ b/tests/run-make/dump-mono-stats/rmake.rs @@ -7,6 +7,11 @@ use run_make_support::{cwd, fs_wrapper, rustc}; fn main() { - rustc().crate_type("lib").input("foo.rs").dump_mono_stats(cwd()).arg("-Zdump-mono-stats-format=json").run(); - assert!(fs_wrapper::read_to_string("foo.mono_items.json").contains("\"name\":\"bar\""); + rustc() + .crate_type("lib") + .input("foo.rs") + .dump_mono_stats(cwd()) + .arg("-Zdump-mono-stats-format=json") + .run(); + assert!(fs_wrapper::read_to_string("foo.mono_items.json").contains(r#""name":"bar""#)); } diff --git a/tests/run-make/prune-link-args/Makefile b/tests/run-make/prune-link-args/Makefile deleted file mode 100644 index c21ba6ace38d6..0000000000000 --- a/tests/run-make/prune-link-args/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# ignore-windows - -# Notice the space in the end, this emulates the output of pkg-config -RUSTC_FLAGS = -C link-args="-lc " - -all: - $(RUSTC) $(RUSTC_FLAGS) empty.rs diff --git a/tests/run-make/prune-link-args/empty.rs b/tests/run-make/prune-link-args/empty.rs deleted file mode 100644 index f328e4d9d04c3..0000000000000 --- a/tests/run-make/prune-link-args/empty.rs +++ /dev/null @@ -1 +0,0 @@ -fn main() {} diff --git a/tests/run-make/prune-link-args/rmake.rs b/tests/run-make/prune-link-args/rmake.rs new file mode 100644 index 0000000000000..ef473d29876d7 --- /dev/null +++ b/tests/run-make/prune-link-args/rmake.rs @@ -0,0 +1,15 @@ +// Passing link-args with an unexpected space +// could result in the flag being parsed and receiving +// an unexpected, empty linker argument. This test +// ensures successful compilation even when a space is +// present. +// See https://github.com/rust-lang/rust/pull/10749 + +//@ ignore-cross-compile + +use run_make_support::rustc; + +fn main() { + // Notice the space at the end of -lc, which emulates the output of pkg-config. + rustc().arg(r#"-Clink-args="-lc ""#).input("empty.rs").run(); +}