summaryrefslogtreecommitdiffstats
path: root/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile
blob: 9ba077b18547e509b871bd3ad000b325b6ff853b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
include ../tools.mk

# ignore-cross-compile
# only-linux

# Make sure -Zpacked_bundled_libs-like behavior activates with +bundle,+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
	$(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"