2018-04-17 13:38:19 +02:00
|
|
|
|
2018-05-15 16:39:21 -07:00
|
|
|
-include ../tools.mk
|
2018-04-17 13:38:19 +02:00
|
|
|
|
2018-07-06 13:58:25 +02:00
|
|
|
# This test makes sure that the object files we generate are actually
|
|
|
|
# LLVM bitcode files (as used by linker LTO plugins) when compiling with
|
|
|
|
# -Z cross-lang-lto.
|
2018-04-16 16:26:40 +02:00
|
|
|
|
2019-01-21 17:47:57 -07:00
|
|
|
# this only succeeds for bitcode files
|
|
|
|
ASSERT_IS_BITCODE_OBJ=($(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-bcanalyzer $(1))
|
|
|
|
EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; $(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-ar x $(1))
|
2018-04-16 16:26:40 +02:00
|
|
|
|
2018-07-06 13:58:25 +02:00
|
|
|
BUILD_LIB=$(RUSTC) lib.rs -Copt-level=2 -Z cross-lang-lto=on -Ccodegen-units=1
|
|
|
|
BUILD_EXE=$(RUSTC) main.rs -Copt-level=2 -Z cross-lang-lto=on -Ccodegen-units=1 --emit=obj
|
2018-04-16 16:26:40 +02:00
|
|
|
|
|
|
|
all: staticlib staticlib-fat-lto staticlib-thin-lto rlib exe cdylib rdylib
|
|
|
|
|
|
|
|
staticlib: lib.rs
|
2018-04-23 11:48:51 +02:00
|
|
|
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib.a
|
2018-07-06 13:58:25 +02:00
|
|
|
$(call EXTRACT_OBJS, liblib.a)
|
2019-01-21 17:47:57 -07:00
|
|
|
for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
|
2018-04-16 16:26:40 +02:00
|
|
|
|
|
|
|
staticlib-fat-lto: lib.rs
|
|
|
|
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-fat-lto.a -Clto=fat
|
2018-07-06 13:58:25 +02:00
|
|
|
$(call EXTRACT_OBJS, liblib-fat-lto.a)
|
2019-01-21 17:47:57 -07:00
|
|
|
for file in $(TMPDIR)/liblib-fat-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
|
2018-04-16 16:26:40 +02:00
|
|
|
|
|
|
|
staticlib-thin-lto: lib.rs
|
|
|
|
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-thin-lto.a -Clto=thin
|
2018-07-06 13:58:25 +02:00
|
|
|
$(call EXTRACT_OBJS, liblib-thin-lto.a)
|
2019-01-21 17:47:57 -07:00
|
|
|
for file in $(TMPDIR)/liblib-thin-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
|
2018-04-16 16:26:40 +02:00
|
|
|
|
|
|
|
rlib: lib.rs
|
2018-04-23 11:48:51 +02:00
|
|
|
$(BUILD_LIB) --crate-type=rlib -o $(TMPDIR)/liblib.rlib
|
2018-07-06 13:58:25 +02:00
|
|
|
$(call EXTRACT_OBJS, liblib.rlib)
|
2019-01-21 17:47:57 -07:00
|
|
|
for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
|
2018-04-16 16:26:40 +02:00
|
|
|
|
|
|
|
cdylib: lib.rs
|
|
|
|
$(BUILD_LIB) --crate-type=cdylib --emit=obj -o $(TMPDIR)/cdylib.o
|
2019-01-21 17:47:57 -07:00
|
|
|
$(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/cdylib.o)
|
2018-04-16 16:26:40 +02:00
|
|
|
|
|
|
|
rdylib: lib.rs
|
|
|
|
$(BUILD_LIB) --crate-type=dylib --emit=obj -o $(TMPDIR)/rdylib.o
|
2019-01-21 17:47:57 -07:00
|
|
|
$(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/rdylib.o)
|
2018-04-16 16:26:40 +02:00
|
|
|
|
|
|
|
exe: lib.rs
|
|
|
|
$(BUILD_EXE) -o $(TMPDIR)/exe.o
|
2019-01-21 17:47:57 -07:00
|
|
|
$(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/exe.o)
|