summaryrefslogtreecommitdiffstats
path: root/tests/run-make/rlib-format-packed-bundled-libs/Makefile
blob: f454da67893d09b5aa08e45edfc44f2d812196c1 (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
36
37
38
39
include ../tools.mk

# ignore-cross-compile

# Make sure rlib format with -Zpacked_bundled_libs is correct.

# We're using the llvm-nm instead of the system nm to ensure it is compatible
# with the LLVM bitcode generated by rustc.
# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm.
ifndef IS_WINDOWS
NM = "$(LLVM_BIN_DIR)"/llvm-nm
else
NM = nm
endif

all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3)
	$(RUSTC) rust_dep_up.rs --crate-type=rlib -Zpacked_bundled_libs
	$(NM) $(TMPDIR)/librust_dep_up.rlib | $(CGREP) -e "U.*native_f2"
	$(NM) $(TMPDIR)/librust_dep_up.rlib | $(CGREP) -e "U.*native_f3"
	$(NM) $(TMPDIR)/librust_dep_up.rlib | $(CGREP) -e "T.*rust_dep_up"
	$(AR) t $(TMPDIR)/librust_dep_up.rlib | $(CGREP) "native_dep_2"
	$(AR) t $(TMPDIR)/librust_dep_up.rlib | $(CGREP) "native_dep_3"
	$(RUSTC) rust_dep_local.rs --extern rlib=$(TMPDIR)/librust_dep_up.rlib -Zpacked_bundled_libs --crate-type=rlib
	$(NM) $(TMPDIR)/librust_dep_local.rlib | $(CGREP) -e "U.*native_f1"
	$(NM) $(TMPDIR)/librust_dep_local.rlib | $(CGREP) -e "T.*rust_dep_local"
	$(AR) t $(TMPDIR)/librust_dep_local.rlib | $(CGREP) "native_dep_1"

	# Make sure compiler doesn't use files, that it shouldn't know about.
	rm $(TMPDIR)/*native_dep_*

	$(RUSTC) main.rs --extern lib=$(TMPDIR)/librust_dep_local.rlib -o $(TMPDIR)/main.exe -Zpacked_bundled_libs --print link-args | $(CGREP) -e "native_dep_1.*native_dep_2.*native_dep_3"

ifndef IS_MSVC
	$(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*native_f1"
	$(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*native_f2"
	$(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*native_f3"
	$(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*rust_dep_local"
	$(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*rust_dep_up"
endif