Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -100,7 +100,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 @@ -109,12 +108,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.

30 changes: 30 additions & 0 deletions tests/run-make/link-args-order/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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

//@ ignore-msvc
// Reason: the ld linker does not exist on Windows.

use run_make_support::rustc;

fn main() {
rustc()
.input("empty.rs")
.linker_flavor("ld")
.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("ld")
.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");
});
}