about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-06-13 16:36:35 -0400
committerOneirical <manchot@videotron.ca>2024-06-17 15:18:23 -0400
commitdf6d873ae852dfdefafeb9251f5f38ed20e9a2ff (patch)
treee7cb77b9551d0fe07c0abb0bd42f0bddd873cfb5
parentcabc9822537a7ded20a64092917bf81d3f994c71 (diff)
downloadrust-df6d873ae852dfdefafeb9251f5f38ed20e9a2ff.tar.gz
rust-df6d873ae852dfdefafeb9251f5f38ed20e9a2ff.zip
rewrite no-builtins-lto to rmake
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/lto-avoid-object-duplication/rmake.rs5
-rw-r--r--tests/run-make/no-builtins-lto/Makefile9
-rw-r--r--tests/run-make/no-builtins-lto/rmake.rs20
4 files changed, 24 insertions, 11 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index a4ca3151baa..8b91c7d8308 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -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
diff --git a/tests/run-make/lto-avoid-object-duplication/rmake.rs b/tests/run-make/lto-avoid-object-duplication/rmake.rs
index 018e6a25b92..b0e7494cb51 100644
--- a/tests/run-make/lto-avoid-object-duplication/rmake.rs
+++ b/tests/run-make/lto-avoid-object-duplication/rmake.rs
@@ -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:
diff --git a/tests/run-make/no-builtins-lto/Makefile b/tests/run-make/no-builtins-lto/Makefile
deleted file mode 100644
index c8f05d9918b..00000000000
--- a/tests/run-make/no-builtins-lto/Makefile
+++ /dev/null
@@ -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'
diff --git a/tests/run-make/no-builtins-lto/rmake.rs b/tests/run-make/no-builtins-lto/rmake.rs
new file mode 100644
index 00000000000..8e0c3a63649
--- /dev/null
+++ b/tests/run-make/no-builtins-lto/rmake.rs
@@ -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"));
+}