blob: 62dc1b5f60602907b6d5d8d3552ca2a508adf1e1 [file] [log] [blame]
-include ../../run-make-fulldeps/tools.mk
# ignore-cross-compile
# only-linux
# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive.
# We're using the llvm-nm instead of the system nm to ensure it is compatible
# with the LLVM bitcode generated by rustc.
NM = "$(LLVM_BIN_DIR)"/llvm-nm
all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(call NATIVE_STATICLIB,native_dep_4)
# test cfg with packed bundle
$(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs
$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add
$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a"
$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a"
$(AR) t $(TMPDIR)/libmain.a | $(CGREP) -e "libnative_dep_1.o"
$(AR) t $(TMPDIR)/libmain.a | $(CGREP) -ev "libnative_dep_2.o"
# test bundle with whole_archive
$(RUSTC) rust_dep.rs --crate-type=rlib
$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_1"
$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_3"
$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_2"
$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_4"
# Make sure compiler doesn't use files, that it shouldn't know about.
rm $(TMPDIR)/libnative_dep_1.a
rm $(TMPDIR)/libnative_dep_3.a
$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib --print link-args > $(TMPDIR)/link_args
cat $(TMPDIR)/link_args | $(CGREP) -ev "native_dep_3"
cat $(TMPDIR)/link_args | $(CGREP) -e "--whole-archive.*native_dep_1.*--whole-archive.*lnative_dep_2.*no-whole-archive.*lnative_dep_4"