Skip to content

Commit 2591a8e

Browse files
committed
Rewrite lto-readonly-lib to rmake
1 parent 87ae390 commit 2591a8e

File tree

6 files changed

+56
-50
lines changed

6 files changed

+56
-50
lines changed

src/tools/run-make-support/src/command.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,14 @@ impl CompletedProcess {
127127

128128
#[track_caller]
129129
pub fn assert_stderr_contains<S: AsRef<str>>(self, needle: S) -> Self {
130-
assert!(self.stderr_utf8().contains(needle.as_ref()));
130+
assert!(
131+
self.stderr_utf8().contains(needle.as_ref()),
132+
format!(
133+
"The stderr {:?} did not contain the string {:?}",
134+
self.stderr_utf8(),
135+
needle.as_ref(),
136+
)
137+
);
131138
self
132139
}
133140

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ run-make/lto-dylib-dep/Makefile
129129
run-make/lto-empty/Makefile
130130
run-make/lto-linkage-used-attr/Makefile
131131
run-make/lto-no-link-whole-rlib/Makefile
132-
run-make/lto-readonly-lib/Makefile
133132
run-make/lto-smoke-c/Makefile
134133
run-make/macos-deployment-target/Makefile
135134
run-make/macos-fat-archive/Makefile

tests/run-make/link-args-order/rmake.rs

+18-30
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,22 @@
66
use run_make_support::rustc;
77

88
fn main() {
9-
assert!(
10-
String::from_utf8(
11-
rustc()
12-
.input("empty.rs")
13-
.linker_flavor("ld")
14-
.link_arg("a")
15-
.link_args("\"b c\"")
16-
.link_args("\"d e\"")
17-
.link_arg("f")
18-
.run_fail()
19-
.stderr
20-
)
21-
.unwrap()
22-
.contains("\"a\" \"b\" \"c\" \"d\" \"e\" \"f\"")
23-
);
24-
assert!(
25-
String::from_utf8(
26-
rustc()
27-
.input("empty.rs")
28-
.linker_flavor("ld")
29-
.pre_link_arg("a")
30-
.pre_link_args("\"b c\"")
31-
.pre_link_args("\"d e\"")
32-
.pre_link_arg("f")
33-
.run_fail()
34-
.stderr
35-
)
36-
.unwrap()
37-
.contains("\"a\" \"b\" \"c\" \"d\" \"e\" \"f\"")
38-
);
9+
rustc()
10+
.input("empty.rs")
11+
.linker_flavor("ld")
12+
.link_arg("a")
13+
.link_args("\"b c\"")
14+
.link_args("\"d e\"")
15+
.link_arg("f")
16+
.run_fail()
17+
.assert_stderr_contains("\"a\" \"b\" \"c\" \"d\" \"e\" \"f\"");
18+
rustc()
19+
.input("empty.rs")
20+
.linker_flavor("ld")
21+
.pre_link_arg("a")
22+
.pre_link_args("\"b c\"")
23+
.pre_link_args("\"d e\"")
24+
.pre_link_arg("f")
25+
.run_fail()
26+
.assert_stderr_contains("\"a\" \"b\" \"c\" \"d\" \"e\" \"f\"");
3927
}

tests/run-make/ls-metadata/rmake.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
//@ ignore-cross-compile
88

99
use run_make_support::fs_wrapper;
10-
use run_make_support::{rmake_out_path, rustc};
10+
use run_make_support::rustc;
1111

1212
fn main() {
13-
rustc().input("foo.rs");
14-
rustc().arg("-Zls=root").input(rmake_out_path("foo"));
15-
fs_wrapper::create_file(rmake_out_path("bar"));
16-
rustc().arg("-Zls=root").input(rmake_out_path("bar"));
13+
rustc().input("foo.rs").run();
14+
rustc().arg("-Zls=root").input("foo").run();
15+
fs_wrapper::create_file("bar");
16+
rustc().arg("-Zls=root").input("bar").run();
1717
}

tests/run-make/lto-readonly-lib/Makefile

-13
This file was deleted.
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// When the compiler is performing link time optimization, it will
2+
// need to copy the original rlib file, set the copy's permissions to read/write,
3+
// and modify that copy - even if the original
4+
// file is read-only. This test creates a read-only rlib, and checks that
5+
// compilation with LTO succeeds.
6+
// See https://github.com/rust-lang/rust/pull/17619
7+
8+
//@ ignore-cross-compile
9+
10+
use run_make_support::fs_wrapper;
11+
use run_make_support::{cwd, run, rustc};
12+
13+
fn main() {
14+
rustc().input("lib.rs").run();
15+
let entries = fs_wrapper::read_dir(cwd());
16+
for entry in entries {
17+
if entry.path().extension().and_then(|s| s.to_str()) == Some("rlib") {
18+
let mut perms = fs_wrapper::metadata(entry.path()).permissions();
19+
perms.set_readonly(true);
20+
fs_wrapper::set_permissions(entry.path(), perms);
21+
}
22+
}
23+
rustc().input("main.rs").arg("-Clto").run();
24+
run("main");
25+
}

0 commit comments

Comments
 (0)