summaryrefslogtreecommitdiffstats
path: root/tests/run-make/cross-lang-lto-clang/Makefile
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/run-make/cross-lang-lto-clang/Makefile
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/cross-lang-lto-clang/Makefile')
-rw-r--r--tests/run-make/cross-lang-lto-clang/Makefile25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/run-make/cross-lang-lto-clang/Makefile b/tests/run-make/cross-lang-lto-clang/Makefile
new file mode 100644
index 000000000..acaebf439
--- /dev/null
+++ b/tests/run-make/cross-lang-lto-clang/Makefile
@@ -0,0 +1,25 @@
+# needs-matching-clang
+
+# This test makes sure that cross-language inlining actually works by checking
+# the generated machine code.
+
+include ../tools.mk
+
+all: cpp-executable rust-executable
+
+cpp-executable:
+ $(RUSTC) -Clinker-plugin-lto=on -o $(TMPDIR)/librustlib-xlto.a -Copt-level=2 -Ccodegen-units=1 ./rustlib.rs
+ $(CLANG) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lrustlib-xlto -o $(TMPDIR)/cmain ./cmain.c -O3
+ # Make sure we don't find a call instruction to the function we expect to
+ # always be inlined.
+ "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -v -e "call.*rust_always_inlined"
+ # As a sanity check, make sure we do find a call instruction to a
+ # non-inlined function
+ "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -e "call.*rust_never_inlined"
+
+rust-executable:
+ $(CLANG) ./clib.c -flto=thin -c -o $(TMPDIR)/clib.o -O2
+ (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
+ $(RUSTC) -Clinker-plugin-lto=on -L$(TMPDIR) -Copt-level=2 -Clinker=$(CLANG) -Clink-arg=-fuse-ld=lld ./main.rs -o $(TMPDIR)/rsmain
+ "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -e "call.*c_never_inlined"
+ "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -v -e "call.*c_always_inlined"