Rollup merge of #126095 - Oneirical:final-testination, r=jieyouxu
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
This commit is contained in:
commit
440504726c
@ -230,6 +230,12 @@ pub fn link_arg(&mut self, link_arg: &str) -> &mut Self {
|
||||
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());
|
||||
@ -248,4 +254,10 @@ pub fn linker(&mut self, linker: &str) -> &mut Self {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,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
|
||||
@ -105,12 +104,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
|
||||
|
@ -1,10 +0,0 @@
|
||||
# ignore-msvc
|
||||
|
||||
include ../tools.mk
|
||||
|
||||
RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args="d e" -C link-arg=f
|
||||
RUSTC_FLAGS_PRE = -C linker-flavor=ld -Z pre-link-arg=a -Z pre-link-args="b c" -Z pre-link-args="d e" -Z pre-link-arg=f
|
||||
|
||||
all:
|
||||
$(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
|
||||
$(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
|
30
tests/run-make/link-args-order/rmake.rs
Normal file
30
tests/run-make/link-args-order/rmake.rs
Normal file
@ -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""#);
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
# ignore-cross-compile
|
||||
include ../tools.mk
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs
|
||||
$(RUSTC) -Z ls=root $(TMPDIR)/foo
|
||||
touch $(TMPDIR)/bar
|
||||
$(RUSTC) -Z ls=root $(TMPDIR)/bar
|
17
tests/run-make/ls-metadata/rmake.rs
Normal file
17
tests/run-make/ls-metadata/rmake.rs
Normal file
@ -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();
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
# ignore-cross-compile
|
||||
include ../tools.mk
|
||||
|
||||
all:
|
||||
$(RUSTC) lib.rs
|
||||
|
||||
# the compiler needs to copy and modify the rlib file when performing
|
||||
# LTO, so we should ensure that it can cope with the original rlib
|
||||
# being read-only.
|
||||
chmod 444 $(TMPDIR)/*.rlib
|
||||
|
||||
$(RUSTC) main.rs -C lto
|
||||
$(call RUN,main)
|
19
tests/run-make/lto-readonly-lib/rmake.rs
Normal file
19
tests/run-make/lto-readonly-lib/rmake.rs
Normal file
@ -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");
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user