2018-04-17 06:38:19 -05:00
|
|
|
|
2022-08-22 19:00:00 -05:00
|
|
|
include ../tools.mk
|
2018-04-17 06:38:19 -05:00
|
|
|
|
2019-01-24 13:17:02 -06:00
|
|
|
# ignore windows due to libLLVM being present in PATH and the PATH and library path being the same
|
|
|
|
# (so fixing it is harder). See #57765 for context
|
|
|
|
ifndef IS_WINDOWS
|
|
|
|
|
2018-07-06 06:58:25 -05: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
|
2019-02-01 08:15:43 -06:00
|
|
|
# -Clinker-plugin-lto.
|
2018-04-16 09:26:40 -05:00
|
|
|
|
2019-01-21 18:47:57 -06:00
|
|
|
# this only succeeds for bitcode files
|
2019-04-29 07:40:07 -05:00
|
|
|
ASSERT_IS_BITCODE_OBJ=("$(LLVM_BIN_DIR)"/llvm-bcanalyzer $(1))
|
|
|
|
EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; "$(LLVM_BIN_DIR)"/llvm-ar x $(1))
|
2018-04-16 09:26:40 -05:00
|
|
|
|
2019-02-01 08:15:43 -06:00
|
|
|
BUILD_LIB=$(RUSTC) lib.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1
|
|
|
|
BUILD_EXE=$(RUSTC) main.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1 --emit=obj
|
2018-04-16 09:26:40 -05:00
|
|
|
|
|
|
|
all: staticlib staticlib-fat-lto staticlib-thin-lto rlib exe cdylib rdylib
|
|
|
|
|
|
|
|
staticlib: lib.rs
|
2018-04-23 04:48:51 -05:00
|
|
|
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib.a
|
2018-07-06 06:58:25 -05:00
|
|
|
$(call EXTRACT_OBJS, liblib.a)
|
2019-01-21 18:47:57 -06:00
|
|
|
for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
|
2018-04-16 09:26:40 -05:00
|
|
|
|
|
|
|
staticlib-fat-lto: lib.rs
|
|
|
|
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-fat-lto.a -Clto=fat
|
2018-07-06 06:58:25 -05:00
|
|
|
$(call EXTRACT_OBJS, liblib-fat-lto.a)
|
2019-01-21 18:47:57 -06:00
|
|
|
for file in $(TMPDIR)/liblib-fat-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
|
2018-04-16 09:26:40 -05:00
|
|
|
|
|
|
|
staticlib-thin-lto: lib.rs
|
|
|
|
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-thin-lto.a -Clto=thin
|
2018-07-06 06:58:25 -05:00
|
|
|
$(call EXTRACT_OBJS, liblib-thin-lto.a)
|
2019-01-21 18:47:57 -06:00
|
|
|
for file in $(TMPDIR)/liblib-thin-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
|
2018-04-16 09:26:40 -05:00
|
|
|
|
|
|
|
rlib: lib.rs
|
2018-04-23 04:48:51 -05:00
|
|
|
$(BUILD_LIB) --crate-type=rlib -o $(TMPDIR)/liblib.rlib
|
2018-07-06 06:58:25 -05:00
|
|
|
$(call EXTRACT_OBJS, liblib.rlib)
|
2019-01-21 18:47:57 -06:00
|
|
|
for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
|
2018-04-16 09:26:40 -05:00
|
|
|
|
|
|
|
cdylib: lib.rs
|
|
|
|
$(BUILD_LIB) --crate-type=cdylib --emit=obj -o $(TMPDIR)/cdylib.o
|
2019-01-21 18:47:57 -06:00
|
|
|
$(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/cdylib.o)
|
2018-04-16 09:26:40 -05:00
|
|
|
|
|
|
|
rdylib: lib.rs
|
|
|
|
$(BUILD_LIB) --crate-type=dylib --emit=obj -o $(TMPDIR)/rdylib.o
|
2019-01-21 18:47:57 -06:00
|
|
|
$(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/rdylib.o)
|
2018-04-16 09:26:40 -05:00
|
|
|
|
|
|
|
exe: lib.rs
|
|
|
|
$(BUILD_EXE) -o $(TMPDIR)/exe.o
|
2019-01-21 18:47:57 -06:00
|
|
|
$(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/exe.o)
|
2019-01-24 13:17:02 -06:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
all:
|
|
|
|
|
|
|
|
endif
|