Skip to content

Commit

Permalink
rewrite no-builtins-lto to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jun 14, 2024
1 parent cabc982 commit ea37b98
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
14 changes: 14 additions & 0 deletions src/tools/run-make-support/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ impl CompletedProcess {
self
}

pub fn assert_stdout_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
let stdout = self.stdout_utf8();
let stdout_trimmed = stdout.trim();
let expected_trimmed = expected.as_ref().trim();
if !self.stdout_utf8().contains(expected.as_ref()) {
eprintln!("=== STDOUT (ACTUAL) TRIMMED ===");
eprintln!("{}", stdout_trimmed);
eprintln!("=== EXPECTED TRIMMED ===");
eprintln!("{}", expected_trimmed);
panic!("trimmed stdout does not contain trimmed expected");
}
self
}

/// Checks that trimmed `stderr` matches trimmed `content`.
#[track_caller]
pub fn assert_stderr_equals<S: AsRef<str>>(&self, content: S) -> &Self {
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ run-make/native-link-modifier-verbatim-rustc/Makefile
run-make/native-link-modifier-whole-archive/Makefile
run-make/no-alloc-shim/Makefile
run-make/no-builtins-attribute/Makefile
run-make/no-builtins-lto/Makefile
run-make/no-duplicate-libs/Makefile
run-make/obey-crate-type-flag/Makefile
run-make/optimization-remarks-dir-pgo/Makefile
Expand Down
1 change: 1 addition & 0 deletions tests/run-make/lto-avoid-object-duplication/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore-tidy-tab
// Staticlibs don't include Rust object files from upstream crates if the same
// code was already pulled into the lib via LTO. However, the bug described in
// https://github.com/rust-lang/rust/issues/64153 lead to this exclusion not
Expand Down
9 changes: 0 additions & 9 deletions tests/run-make/no-builtins-lto/Makefile

This file was deleted.

20 changes: 20 additions & 0 deletions tests/run-make/no-builtins-lto/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// The rlib produced by a no_builtins crate should be explicitely linked
// during compilation, and as a result be present in the linker arguments.
// See the comments inside the test for more details.
// See https://github.com/rust-lang/rust/pull/35637

use run_make_support::{rust_lib_name, rustc};

fn main() {
// Compile a `#![no_builtins]` rlib crate
rustc().input("no_builtins.rs").run();
// Build an executable that depends on that crate using LTO. The no_builtins crate doesn't
// participate in LTO, so its rlib must be explicitly
// linked into the final binary. Verify this by grepping the linker arguments.
rustc()
.input("main.rs")
.arg("-Clto")
.print("link-args")
.run()
.assert_stdout_contains(rust_lib_name("no_builtins"));
}

0 comments on commit ea37b98

Please sign in to comment.