2023-03-30 07:58:50 -05:00
|
|
|
include ../tools.mk
|
2023-01-26 08:10:13 -06:00
|
|
|
|
|
|
|
# ignore-cross-compile
|
|
|
|
# only-linux
|
|
|
|
|
2023-07-03 14:26:05 -05:00
|
|
|
# Make sure -Zpacked_bundled_libs-like behavior activates with +bundle,+whole-archive.
|
2023-01-26 08:10:13 -06:00
|
|
|
|
|
|
|
# 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
|
2023-07-03 14:26:05 -05:00
|
|
|
$(RUSTC) rust_dep_cfg.rs --crate-type=rlib
|
2023-01-26 08:10:13 -06:00
|
|
|
$(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"
|