Skip to content

Commit ab9dc62

Browse files
committed
Factored out commands to delete dylib/rlib into REMOVE_DYLIBS/REMOVE_RLIBS.
There were places where we were only calling `rm $(call DYLIB,foo)` even though we really needed to get rid of the whole glob (at least based on alex's findings on rust-lang#13753 that removing the symlink does not suffice). Therefore rather than peppering the code with the awkward `rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common `REMOVE_DYLIBS` user function that expands into that when called. After I adding an analogous `REMOVE_RLIBS`, I changed all of the existing calls that rm dylibs or rlibs to use these routines instead. Note that the latter is not a true refactoring since I may have changed cases where it was our intent to only remove the sym-link. (But if that is the case, then we need to more deeply investigate alex's findings on rust-lang#13753 where the system was still dynamically loading up the non-symlinked libraries that it finds on the load path.)
1 parent 22b20eb commit ab9dc62

File tree

13 files changed

+22
-18
lines changed

13 files changed

+22
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
-include ../tools.mk
22

33
all:
4+
env
45
$(RUSTC) lib.rs
56
ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot)
67
$(CC) main.c -o $(call RUN_BINFILE,main) -lboot
78
$(call RUN,main)
8-
rm $(call DYLIB,boot)
9+
$(call REMOVE_DYLIBS,boot)
910
$(call FAIL,main)

src/test/run-make/bootstrap-from-c-with-native/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ all:
55
ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot)
66
$(CC) main.c -o $(call RUN_BINFILE,main) -lboot
77
$(call RUN,main)
8-
rm $(call DYLIB,boot)
8+
$(call REMOVE_DYLIBS,boot)
99
$(call FAIL,main)

src/test/run-make/c-dynamic-dylib/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ all: $(call DYLIB,cfoo)
99
$(RUSTC) foo.rs
1010
$(RUSTC) bar.rs
1111
$(call RUN,bar)
12-
rm $(TMPDIR)/$(call DYLIB_GLOB,cfoo)
12+
$(call REMOVE_DYLIBS,cfoo)
1313
$(call FAIL,bar)
1414
endif

src/test/run-make/c-dynamic-rlib/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ all: $(call DYLIB,cfoo)
99
$(RUSTC) foo.rs
1010
$(RUSTC) bar.rs
1111
LD_LIBRARY_PATH=$(TMPDIR) $(call RUN,bar)
12-
rm $(TMPDIR)/$(call DYLIB_GLOB,cfoo)
12+
$(call REMOVE_DYLIBS,cfoo)
1313
$(call FAIL,bar)
1414
endif

src/test/run-make/c-link-to-rust-dylib/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ all:
55
ln -s $(call DYLIB,foo-*) $(call DYLIB,foo)
66
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -Wl,-rpath,$(TMPDIR)
77
$(call RUN,bar)
8-
rm $(call DYLIB,foo)
8+
$(call REMOVE_DYLIBS,foo)
99
$(call FAIL,bar)

src/test/run-make/c-static-dylib/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ all: $(call STATICLIB,cfoo)
55
$(RUSTC) bar.rs
66
rm $(TMPDIR)/$(call STATICLIB_GLOB,cfoo)
77
$(call RUN,bar)
8-
rm $(TMPDIR)/$(call DYLIB_GLOB,foo)
8+
$(call REMOVE_DYLIBS,foo)
99
$(call FAIL,bar)

src/test/run-make/c-static-rlib/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
all: $(call STATICLIB,cfoo)
44
$(RUSTC) foo.rs
55
$(RUSTC) bar.rs
6-
rm $(TMPDIR)/$(call RLIB_GLOB,foo)
6+
$(call REMOVE_RLIBS,foo)
77
rm $(TMPDIR)/$(call STATICLIB_GLOB,cfoo)
88
$(call RUN,bar)

src/test/run-make/dylib-chain/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ all:
66
$(RUSTC) m3.rs
77
$(RUSTC) m4.rs
88
$(call RUN,m4)
9-
rm $(TMPDIR)/$(call DYLIB_GLOB,m1)
10-
rm $(TMPDIR)/$(call DYLIB_GLOB,m2)
11-
rm $(TMPDIR)/$(call DYLIB_GLOB,m3)
9+
$(call REMOVE_DYLIBS,m1)
10+
$(call REMOVE_DYLIBS,m2)
11+
$(call REMOVE_DYLIBS,m3)
1212
$(call FAIL,m4)

src/test/run-make/missing-crate-dependency/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
all:
44
$(RUSTC) --crate-type=rlib crateA.rs
55
$(RUSTC) --crate-type=rlib crateB.rs
6-
rm $(TMPDIR)/$(call RLIB_GLOB,crateA)
6+
$(call REMOVE_RLIBS,crateA)
77
# Ensure crateC fails to compile since dependency crateA is missing
88
$(RUSTC) crateC.rs 2>&1 | \
99
grep "error: can't find crate for \`crateA\` which \`crateB\` depends on"

src/test/run-make/mixing-libs/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ all:
55
$(RUSTC) dylib.rs && exit 1 || exit 0
66
$(RUSTC) rlib.rs --crate-type=dylib
77
$(RUSTC) dylib.rs
8-
rm $(call DYLIB,rlib-*)
8+
$(call REMOVE_DYLIBS,rlib)
99
$(RUSTC) prog.rs && exit 1 || exit 0

src/test/run-make/obey-crate-type-flag/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# fail if an rlib was built
88
all:
99
$(RUSTC) test.rs
10-
rm $(TMPDIR)/$(call RLIB_GLOB,test)
11-
rm $(TMPDIR)/$(call DYLIB_GLOB,test)
10+
$(call REMOVE_RLIBS,test)
11+
$(call REMOVE_DYLIBS,test)
1212
$(RUSTC) --crate-type dylib test.rs
13-
rm $(TMPDIR)/$(call RLIB_GLOB,test) && exit 1 || exit 0
13+
$(call REMOVE_RLIBS,test) && exit 1 || exit 0

src/test/run-make/output-type-permutations/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
all:
44
$(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib
5-
rm $(TMPDIR)/$(call RLIB_GLOB,bar)
6-
rm $(TMPDIR)/$(call DYLIB_GLOB,bar)
5+
$(call REMOVE_RLIBS,bar)
6+
$(call REMOVE_DYLIBS,bar)
77
rm $(TMPDIR)/$(call STATICLIB_GLOB,bar)
88
$(RUSTC) foo.rs --crate-type=bin
99
rm $(TMPDIR)/$(call BIN,bar)
@@ -41,4 +41,4 @@ all:
4141
cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
4242
rm $(TMPDIR)/bar.bc
4343
rm $(TMPDIR)/foo.bc
44-
rm $(TMPDIR)/$(call RLIB_GLOB,bar)
44+
$(call REMOVE_RLIBS,bar)

src/test/run-make/tools.mk

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ DYLIB = $(TMPDIR)/lib$(1).so
3737
endif
3838
endif
3939

40+
REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
41+
REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
42+
4043
%.a: %.o
4144
ar crus $@ $<
4245
%.dylib: %.o

0 commit comments

Comments
 (0)