You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auto merge of #7637 : pnkfelix/rust/fsk-guard-against-stale-libraries-issue3225-safeguarded, r=graydon
When building Rust libraries (e.g. librustc, libstd, etc), checks for
and verbosely removes previous build products before invoking rustc.
(Also, when Make variable VERBOSE is defined, it will list all of the
libraries matching the object library's glob after the rustc
invocation has completed.)
When installing Rust libraries, checks for previous libraries in
target install directory, but does not remove them.
The thinking behind these two different modes of operation is that the
installation target, unlike the build tree, is not under the control
of this infrastructure and it is not up to this Makefile to decide if
the previous libraries should be removed.
Fixes#3225 (at least in terms of mitigating the multiple library
problem by proactively warning the user about it.)
# $(3) is filename (usually the target being created) to filter out from match
241
+
# (i.e. filename is not out-of-date artifact from prior Rust version/build)
242
+
#
243
+
# Note that a common bug is to accidentally construct the glob denoted
244
+
# by $(2) with a space character prefix, which invalidates the
245
+
# construction $(1)$(2).
246
+
defineCHECK_FOR_OLD_GLOB_MATCHES_EXCEPT
247
+
$(Q)MATCHES="$(filter-out%$(3),$(wildcard$(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "Warning: there are previous" \'$(2)\' "libraries:" $$MATCHES; fi
248
+
endef
249
+
250
+
# Same interface as above, but deletes rather than just listing the files.
251
+
defineREMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT
252
+
$(Q)MATCHES="$(filter-out%$(3),$(wildcard$(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "Warning: removing previous" \'$(2)\' "libraries:" $$MATCHES; rm -v $$MATCHES ; fi
253
+
endef
254
+
255
+
# We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
256
+
# than in the macros above because it needs the result of running the
257
+
# `ls` command after other rules in the command list have run; the
258
+
# macro-expander for $(wildcard ...) would deliver its results too
259
+
# soon. (This is in contrast to the macros above, which are meant to
260
+
# be run at the outset of a command list in a rule.)
261
+
ifdefVERBOSE
262
+
defineLIST_ALL_OLD_GLOB_MATCHES_EXCEPT
263
+
@echo "Info: now are following matches for" '$(2)' "libraries:"
264
+
@( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) || true )
0 commit comments