rewrite no-builtins-lto to rmake

This commit is contained in:
Oneirical 2024-06-13 16:36:35 -04:00
parent cabc982253
commit df6d873ae8
4 changed files with 24 additions and 11 deletions

View File

@ -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

View File

@ -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
@ -10,6 +11,8 @@
//@ ignore-windows
// Reason: `llvm-objdump`'s output looks different on windows than on other platforms.
// Only checking on Unix platforms should suffice.
//FIXME(Oneirical): This could be adapted to work on Windows by checking how
// that output differs.
use run_make_support::{llvm_objdump, regex, rust_lib_name, rustc, static_lib_name};
@ -28,7 +31,7 @@ fn main() {
.codegen_units(1)
.run();
let syms = llvm_objdump().arg("-t").input(static_lib_name("downstream")).run().stdout_utf8();
let re = regex::Regex::new(r#"(?m)\s*g\s*F\s.*issue64153_test_function"#).unwrap();
let re = regex::Regex::new(r#"\s*g\s*F\s.*issue64153_test_function"#).unwrap();
// Count the global instances of `issue64153_test_function`. There'll be 2
// if the `upstream` object file got erroneously included twice.
// The line we are testing for with the regex looks something like:

View File

@ -1,9 +0,0 @@
include ../tools.mk
all:
# Compile a `#![no_builtins]` rlib crate
$(RUSTC) no_builtins.rs
# 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) main.rs -C lto --print link-args | $(CGREP) 'libno_builtins.rlib'

View File

@ -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 this file 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"));
}