Skip to content

Commit 7128267

Browse files
committed
rewrite no-builtins-lto to rmake
1 parent 946c47c commit 7128267

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

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

+14
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@ impl CompletedProcess {
176176
self
177177
}
178178

179+
pub fn assert_stdout_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
180+
let stdout = self.stdout_utf8();
181+
let stdout_trimmed = stdout.trim();
182+
let expected_trimmed = expected.as_ref().trim();
183+
if !self.stdout_utf8().contains(expected.as_ref()) {
184+
eprintln!("=== STDOUT (ACTUAL) TRIMMED ===");
185+
eprintln!("{}", stdout_trimmed);
186+
eprintln!("=== EXPECTED TRIMMED ===");
187+
eprintln!("{}", expected_trimmed);
188+
panic!("trimmed stdout does not contain trimmed expected");
189+
}
190+
self
191+
}
192+
179193
/// Checks that trimmed `stderr` matches trimmed `content`.
180194
#[track_caller]
181195
pub fn assert_stderr_equals<S: AsRef<str>>(&self, content: S) -> &Self {

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ run-make/native-link-modifier-verbatim-rustc/Makefile
148148
run-make/native-link-modifier-whole-archive/Makefile
149149
run-make/no-alloc-shim/Makefile
150150
run-make/no-builtins-attribute/Makefile
151-
run-make/no-builtins-lto/Makefile
152151
run-make/no-duplicate-libs/Makefile
153152
run-make/obey-crate-type-flag/Makefile
154153
run-make/optimization-remarks-dir-pgo/Makefile

tests/run-make/lto-avoid-object-duplication/rmake.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-tidy-tab
12
// Staticlibs don't include Rust object files from upstream crates if the same
23
// code was already pulled into the lib via LTO. However, the bug described in
34
// https://github.com/rust-lang/rust/issues/64153 lead to this exclusion not

tests/run-make/no-builtins-lto/Makefile

-9
This file was deleted.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// The rlib produced by a no_builtins crate should be explicitely linked
2+
// during compilation, and as a result be present in the linker arguments.
3+
// See the comments inside the test for more details.
4+
// See https://github.com/rust-lang/rust/pull/35637
5+
6+
use run_make_support::{rust_lib_name, rustc};
7+
8+
fn main() {
9+
// Compile a `#![no_builtins]` rlib crate
10+
rustc().input("no_builtins.rs").run();
11+
// Build an executable that depends on that crate using LTO. The no_builtins crate doesn't
12+
// participate in LTO, so its rlib must be explicitly
13+
// linked into the final binary. Verify this by grepping the linker arguments.
14+
rustc()
15+
.input("main.rs")
16+
.arg("-Clto")
17+
.print("link-args")
18+
.run()
19+
.assert_stdout_contains(rust_lib_name("no_builtins"));
20+
}

0 commit comments

Comments
 (0)