From 1335398624ef5774bc1773c813a72fb045e7da27 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 24 Jul 2017 17:54:03 +0000 Subject: [PATCH] PROGS: Fix ESTALE errors on NFS while cleaning in directories with PROGS. - Only recurse on cleanobj/cleandir if there is no .OBJDIR being used. If we don't recurse then bsd.obj.mk will just rm -rf the OBJDIR dir. - When recursing on cleanobj/cleandir don't remove dependfiles/dirs redundantly from the child and main processes. Meaning '.depend', and 'tags', and '.depend.*' will now only be removed from the main process. - Stop recursing on 'cleandepend' since the main process can handle removing all files via the default glob patterns in CLEANDEPENDFILES. - This reverts r288201, by readding recursion on 'cleanobj', due to r291635 changing how bsd.subdir.mk handles recursion. This is primarily targeting ESTALE NFS errors from rm(1) during a buildworld but is also a performance optimization as both issues fixed were redundant anyway. Reported by: cperciva, scottl MFC after: 2 weeks Sponsored by: Dell EMC Isilon --- share/mk/bsd.obj.mk | 1 + share/mk/bsd.progs.mk | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/share/mk/bsd.obj.mk b/share/mk/bsd.obj.mk index b8f4b1b2352..1ce59964310 100644 --- a/share/mk/bsd.obj.mk +++ b/share/mk/bsd.obj.mk @@ -157,6 +157,7 @@ whereobj: @echo ${.OBJDIR} .endif +# Same check in bsd.progs.mk .if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/) cleanobj: -rm -rf ${CANONICALOBJDIR} diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk index c50410dfc82..be000f91f8a 100644 --- a/share/mk/bsd.progs.mk +++ b/share/mk/bsd.progs.mk @@ -116,7 +116,16 @@ ${_PROGS_COMMON_OBJS}: .NOMETA .if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG) # tell progs.mk we might want to install things -PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install +PROGS_TARGETS+= checkdpadd clean depend install +# Only handle removing depend files from the main process. +_PROG_MK.cleandir= CLEANDEPENDFILES= CLEANDEPENDDIRS= +_PROG_MK.cleanobj= CLEANDEPENDFILES= CLEANDEPENDDIRS= +# Only recurse on these if there is no objdir, meaning a normal +# 'clean' gets ran via the target defined in bsd.obj.mk. +# Same check from cleanobj: in bsd.obj.mk +.if ${CANONICALOBJDIR} == ${.CURDIR} || !exists(${CANONICALOBJDIR}/) +PROGS_TARGETS+= cleandir cleanobj +.endif # Ensure common objects are built before recursing. .if !empty(_PROGS_COMMON_OBJS) @@ -142,7 +151,7 @@ $p.$t: .PHONY .MAKE (cd ${.CURDIR} && \ DEPENDFILE=.depend.$p \ NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \ - PROG=$p ${x.$p} ${@:E}) + ${_PROG_MK.${t}} PROG=$p ${x.$p} ${@:E}) .endfor .endfor -- 2.45.0