diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 15200752879..c2a4866352f 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -106,7 +106,6 @@ run-make/optimization-remarks-dir-pgo/Makefile run-make/optimization-remarks-dir/Makefile run-make/output-type-permutations/Makefile run-make/panic-abort-eh_frame/Makefile -run-make/pass-linker-flags-from-dep/Makefile run-make/pass-non-c-like-enum-to-c/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile run-make/pgo-gen-lto/Makefile diff --git a/tests/run-make/pass-linker-flags-flavor/rmake.rs b/tests/run-make/pass-linker-flags-flavor/rmake.rs index 9efb89cea09..e36d68cc884 100644 --- a/tests/run-make/pass-linker-flags-flavor/rmake.rs +++ b/tests/run-make/pass-linker-flags-flavor/rmake.rs @@ -4,7 +4,8 @@ // explicit flags and then with those flags passed inside the rust source code. // See https://github.com/rust-lang/rust/pull/118202 -//FIXME(Oneirical): only-linux +//@ only-linux +// Reason: the `gnu-cc` linker is only available on linux use run_make_support::{regex, rustc}; diff --git a/tests/run-make/pass-linker-flags-from-dep/Makefile b/tests/run-make/pass-linker-flags-from-dep/Makefile deleted file mode 100644 index 48b3b26ce81..00000000000 --- a/tests/run-make/pass-linker-flags-from-dep/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include ../tools.mk - -all: - # Build deps - $(RUSTC) native_dep_1.rs --crate-type=staticlib - $(RUSTC) native_dep_2.rs --crate-type=staticlib - $(RUSTC) rust_dep_flag.rs -l static:-bundle=native_dep_1 -l link-arg=some_flag -l static:-bundle=native_dep_2 --crate-type=lib -Z unstable-options - $(RUSTC) rust_dep_attr.rs --crate-type=lib - - # Check sequence of linker args - $(RUSTC) main.rs --extern lib=$(TMPDIR)/librust_dep_flag.rlib --crate-type=bin --print link-args | $(CGREP) -e 'native_dep_1.*some_flag.*native_dep_2' - $(RUSTC) main.rs --extern lib=$(TMPDIR)/librust_dep_attr.rlib --crate-type=bin --print link-args | $(CGREP) -e 'native_dep_1.*some_flag.*native_dep_2' diff --git a/tests/run-make/pass-linker-flags-from-dep/rmake.rs b/tests/run-make/pass-linker-flags-from-dep/rmake.rs new file mode 100644 index 00000000000..4b8e0486e14 --- /dev/null +++ b/tests/run-make/pass-linker-flags-from-dep/rmake.rs @@ -0,0 +1,43 @@ +// A similar test to pass-linker-flags, testing that the `-l link-arg` flag +// respects the order relative to other `-l` flags, but this time, the flags +// are passed on the compilation of a dependency. This test checks that the +// downstream compiled binary contains the linker arguments of the dependency, +// and in the correct order. +// See https://github.com/rust-lang/rust/issues/99427 + +use run_make_support::{regex, rust_lib_name, rustc}; + +fn main() { + // Build dependencies + rustc().input("native_dep_1.rs").crate_type("staticlib").run(); + rustc().input("native_dep_2.rs").crate_type("staticlib").run(); + rustc() + .input("rust_dep_flag.rs") + .arg("-lstatic:-bundle=native_dep_1") + .arg("-llink-arg=some_flag") + .arg("-lstatic:-bundle=native_dep_2") + .crate_type("lib") + .arg("-Zunstable-options") + .run(); + rustc().input("rust_dep_attr.rs").crate_type("lib").run(); + + // Check sequence of linker arguments + let out_flag = rustc() + .input("main.rs") + .extern_("lib", rust_lib_name("rust_dep_flag")) + .crate_type("bin") + .print("link-args") + .run_unchecked() + .stdout_utf8(); + let out_attr = rustc() + .input("main.rs") + .extern_("lib", rust_lib_name("rust_dep_attr")) + .crate_type("bin") + .print("link-args") + .run_unchecked() + .stdout_utf8(); + + let re = regex::Regex::new("native_dep_1.*some_flag.*native_dep_2").unwrap(); + assert!(re.is_match(&out_flag)); + assert!(re.is_match(&out_attr)); +}