2019-01-11 06:43:18 -06:00
|
|
|
# needs-matching-clang
|
|
|
|
|
|
|
|
# This test makes sure that cross-language inlining actually works by checking
|
|
|
|
# the generated machine code.
|
|
|
|
|
2022-08-22 19:00:00 -05:00
|
|
|
include ../tools.mk
|
2019-01-11 06:43:18 -06:00
|
|
|
|
|
|
|
all: cpp-executable rust-executable
|
|
|
|
|
|
|
|
cpp-executable:
|
2019-02-01 08:15:43 -06:00
|
|
|
$(RUSTC) -Clinker-plugin-lto=on -o $(TMPDIR)/librustlib-xlto.a -Copt-level=2 -Ccodegen-units=1 ./rustlib.rs
|
2019-04-29 07:40:07 -05:00
|
|
|
$(CLANG) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lrustlib-xlto -o $(TMPDIR)/cmain ./cmain.c -O3
|
2019-01-11 06:43:18 -06:00
|
|
|
# Make sure we don't find a call instruction to the function we expect to
|
|
|
|
# always be inlined.
|
2019-04-29 07:40:07 -05:00
|
|
|
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -v -e "call.*rust_always_inlined"
|
2019-01-11 06:43:18 -06:00
|
|
|
# As a sanity check, make sure we do find a call instruction to a
|
|
|
|
# non-inlined function
|
2019-04-29 07:40:07 -05:00
|
|
|
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -e "call.*rust_never_inlined"
|
2019-01-11 06:43:18 -06:00
|
|
|
|
|
|
|
rust-executable:
|
2019-04-29 07:40:07 -05:00
|
|
|
$(CLANG) ./clib.c -flto=thin -c -o $(TMPDIR)/clib.o -O2
|
2019-01-11 06:43:18 -06:00
|
|
|
(cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
|
2019-02-01 08:15:43 -06:00
|
|
|
$(RUSTC) -Clinker-plugin-lto=on -L$(TMPDIR) -Copt-level=2 -Clinker=$(CLANG) -Clink-arg=-fuse-ld=lld ./main.rs -o $(TMPDIR)/rsmain
|
2019-04-29 07:40:07 -05:00
|
|
|
"$(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"
|