Skip to content

Commit

Permalink
Auto merge of #126095 - Oneirical:final-testination, r=<try>
Browse files Browse the repository at this point in the history
Migrate `link-args-order`, `ls-metadata` and `lto-readonly-lib` `run-make` tests to `rmake`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Guaranteed to fail CI until #125736 gets merged. Will require addition of `fs_wrapper::set_permissions` in the associated module.

try-job: x86_64-msvc
  • Loading branch information
bors committed Jun 19, 2024
2 parents 3186d17 + c243f12 commit e0c1673
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 34 deletions.
12 changes: 12 additions & 0 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ impl Rustc {
self
}

/// Add multiple extra arguments to the linker invocation, via `-Clink-args`.
pub fn link_args(&mut self, link_args: &str) -> &mut Self {
self.cmd.arg(format!("-Clink-args={link_args}"));
self
}

/// Specify a stdin input
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());
Expand All @@ -248,4 +254,10 @@ impl Rustc {
self.cmd.arg(format!("-Clinker={linker}"));
self
}

/// Specify the linker flavor
pub fn linker_flavor(&mut self, linker_flavor: &str) -> &mut Self {
self.cmd.arg(format!("-Clinker-flavor={linker_flavor}"));
self
}
}
3 changes: 0 additions & 3 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ run-make/libtest-json/Makefile
run-make/libtest-junit/Makefile
run-make/libtest-padding/Makefile
run-make/libtest-thread-limit/Makefile
run-make/link-args-order/Makefile
run-make/link-cfg/Makefile
run-make/link-framework/Makefile
run-make/link-path-order/Makefile
Expand All @@ -107,12 +106,10 @@ run-make/llvm-ident/Makefile
run-make/long-linker-command-lines-cmd-exe/Makefile
run-make/long-linker-command-lines/Makefile
run-make/longjmp-across-rust/Makefile
run-make/ls-metadata/Makefile
run-make/lto-dylib-dep/Makefile
run-make/lto-empty/Makefile
run-make/lto-linkage-used-attr/Makefile
run-make/lto-no-link-whole-rlib/Makefile
run-make/lto-readonly-lib/Makefile
run-make/lto-smoke-c/Makefile
run-make/macos-deployment-target/Makefile
run-make/macos-fat-archive/Makefile
Expand Down
10 changes: 0 additions & 10 deletions tests/run-make/link-args-order/Makefile

This file was deleted.

28 changes: 28 additions & 0 deletions tests/run-make/link-args-order/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Passing linker arguments to the compiler used to be lost or reordered in a messy way
// as they were passed further to the linker. This was fixed in #70665, and this test
// checks that linker arguments remain intact and in the order they were originally passed in.
// See https://github.com/rust-lang/rust/pull/70665

use run_make_support::{is_windows, rustc};

fn main() {
let link_flavor = if is_windows() { "lld-link" } else { "ld" };
rustc()
.input("empty.rs")
.linker_flavor(link_flavor)
.link_arg("a")
.link_args("b c")
.link_args("d e")
.link_arg("f")
.run_fail()
.assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
rustc()
.input("empty.rs")
.linker_flavor(link_flavor)
.arg("-Zpre-link-arg=a")
.arg("-Zpre-link-args=b c")
.arg("-Zpre-link-args=d e")
.arg("-Zpre-link-arg=f")
.run_fail()
.assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
}
8 changes: 0 additions & 8 deletions tests/run-make/ls-metadata/Makefile

This file was deleted.

17 changes: 17 additions & 0 deletions tests/run-make/ls-metadata/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Passing invalid files to -Z ls (which lists the symbols
// defined by a library crate) used to cause a segmentation fault.
// As this was fixed in #11262, this test checks that no segfault
// occurs when passing the invalid file `bar` to -Z ls.
// See https://github.com/rust-lang/rust/issues/11259

//@ ignore-cross-compile

use run_make_support::fs_wrapper;
use run_make_support::rustc;

fn main() {
rustc().input("foo.rs").run();
rustc().arg("-Zls=root").input("foo").run();
fs_wrapper::create_file("bar");
rustc().arg("-Zls=root").input("bar").run();
}
13 changes: 0 additions & 13 deletions tests/run-make/lto-readonly-lib/Makefile

This file was deleted.

19 changes: 19 additions & 0 deletions tests/run-make/lto-readonly-lib/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// When the compiler is performing link time optimization, it will
// need to copy the original rlib file, set the copy's permissions to read/write,
// and modify that copy - even if the original
// file is read-only. This test creates a read-only rlib, and checks that
// compilation with LTO succeeds.
// See https://github.com/rust-lang/rust/pull/17619

//@ ignore-cross-compile

use run_make_support::fs_wrapper;
use run_make_support::{run, rust_lib_name, rustc, test_while_readonly};

fn main() {
rustc().input("lib.rs").run();
test_while_readonly(rust_lib_name("lib"), || {
rustc().input("main.rs").arg("-Clto").run();
run("main");
});
}

0 comments on commit e0c1673

Please sign in to comment.