From d5c073eb090f34b42da85f3f768ea6847b9ba7bc Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 22 Jul 2024 15:35:18 -0400 Subject: [PATCH] rewrite no-builtins-attribute to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../native-link-modifier-whole-archive/rmake.rs | 3 ++- tests/run-make/no-builtins-attribute/Makefile | 9 --------- tests/run-make/no-builtins-attribute/rmake.rs | 13 +++++++++++++ 4 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 tests/run-make/no-builtins-attribute/Makefile create mode 100644 tests/run-make/no-builtins-attribute/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 3ee3bf65cfa..d47d1b46fe1 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -35,7 +35,6 @@ run-make/macos-deployment-target/Makefile run-make/min-global-align/Makefile run-make/native-link-modifier-bundle/Makefile run-make/no-alloc-shim/Makefile -run-make/no-builtins-attribute/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile run-make/pgo-gen-lto/Makefile run-make/pgo-indirect-call-promotion/Makefile diff --git a/tests/run-make/native-link-modifier-whole-archive/rmake.rs b/tests/run-make/native-link-modifier-whole-archive/rmake.rs index 4e1f34d112e..b8b814043e5 100644 --- a/tests/run-make/native-link-modifier-whole-archive/rmake.rs +++ b/tests/run-make/native-link-modifier-whole-archive/rmake.rs @@ -66,7 +66,8 @@ fn main() { .crate_type("rlib") .arg("-lstatic:-bundle,+whole-archive=c_static_lib_with_constructor") .run(); - // Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable + // Native lib linked into RLIB via `-l static:-bundle,+whole-archive` + // RLIB linked into executable rustc().input("indirectly_linked.rs").run(); // Native lib linked into rlib via `#[link()]` attribute on extern block. diff --git a/tests/run-make/no-builtins-attribute/Makefile b/tests/run-make/no-builtins-attribute/Makefile deleted file mode 100644 index 0ce95facaea..00000000000 --- a/tests/run-make/no-builtins-attribute/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -# We want to check if `no-builtins` is also added to the function declarations in the used crate. - -all: - $(RUSTC) no_builtins.rs --emit=link - $(RUSTC) main.rs --emit=llvm-ir - - cat "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck.main.txt diff --git a/tests/run-make/no-builtins-attribute/rmake.rs b/tests/run-make/no-builtins-attribute/rmake.rs new file mode 100644 index 00000000000..1e15b0c03f1 --- /dev/null +++ b/tests/run-make/no-builtins-attribute/rmake.rs @@ -0,0 +1,13 @@ +// `no_builtins` is an attribute related to LLVM's optimizations. In order to ensure that it has an +// effect on link-time optimizations (LTO), it should be added to function declarations in a crate. +// This test uses the `llvm-filecheck` tool to determine that this attribute is successfully +// being added to these function declarations. +// See https://github.com/rust-lang/rust/pull/113716 + +use run_make_support::{llvm_filecheck, rfs, rustc}; + +fn main() { + rustc().input("no_builtins.rs").emit("link").run(); + rustc().input("main.rs").emit("llvm-ir").run(); + llvm_filecheck().patterns("filecheck.main.txt").stdin(rfs::read("main.ll")).run(); +}