Skip to contentSkip to conversation

perf: Fix clean error

PATCH Superseded Lei YU 1 participant 1 message Aug 27, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lei YU

author
#0 lore raw

PATCH 1/1 perf: Fix clean error

When make perf with -O, it gets error when make clean with below log:

 $ make -C tools/perf O=<output/dir> # OK
 $ make -C tools/perf O=<output/dir>
    find: cannot delete ‘<output/dir>/builtin-script.o’: No such file or directory
    find: cannot delete ‘<output/dir>/.subcmd-config.o.cmd’: No such file or directory
    ...
    Makefile:38: recipe for target 'clean' failed
    make[2]: *** [clean] Error 1
    make[1]: *** [fixdep-clean] Error 2
    Makefile:90: recipe for target 'clean' failed
    make: *** [clean] Error 2

It happens because both fixdep-clean and libsubcmd-clean will delete files by find, where libsubcmd-clean uses | xargs $(RM) and fixdep-clean uses -delete.
When a file is find by fixdep-clean, and tries to delete it, it's found that the file does not exist because it is deleted by libsubcmd-clean.

This commit changes the delete method of fixdep-clean to use | xargs $(RM) as well, where RM is defined as rm -f so it does not return error when file does not exist.

---
 tools/build/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/build/Makefile +2 -1
index 5edf65e..ae38db2 100644
@@ -18,6 +18,7 @@ $(call allow-override,LD,$(CROSS_COMPILE)ld)
 HOSTCC ?= gcc
 HOSTLD ?= ld
 HOSTAR ?= ar
+RM = rm -f
 
 export HOSTCC HOSTLD HOSTAR
 
@@ -36,7 +37,7 @@ all: $(OUTPUT)fixdep
 
 clean:
 	$(call QUIET_CLEAN, fixdep)
-	$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
+	$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -o -name '\.*.cmd' -o -name '\.*.d' | xargs $(RM)
 	$(Q)rm -f $(OUTPUT)fixdep
 
 $(OUTPUT)fixdep-in.o: FORCE
Signature · 1 line
2.7.4