Revert "kbuild: improve cc-option to clean up all temporary files"
This reverts commit 803d114e8f19cb5e9e40b5c26d8ea33829916d09.
Having above commit leads to failure in unpacking stage for different
packages during `./build_packages --board=lakitu` stage. Some of the
packages are docker and fuse. When tried locally, it leads to 100%
failure in the `build_packages` stage. Reverting the above commit leads
to successful `build_packages` stage.
BUG=b/161872405
TEST=sponge2/a03ff451-82f3-438b-b01d-5f97327275c5
Change-Id: I6592701bad9ef2b5fa70d9d6904483a13441d2a9
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/2861
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
Reviewed-by: Roy Yang <royyang@google.com>
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 7da10af..d1dd4a6 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -82,21 +82,20 @@
$(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c))))
# output directory for tests below
-TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$
+TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
# try-run
# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
# Exit code chooses option. "$$TMP" serves as a temporary file and is
# automatically cleaned up.
try-run = $(shell set -e; \
- TMP=$(TMPOUT)/tmp; \
- TMPO=$(TMPOUT)/tmp.o; \
- mkdir -p $(TMPOUT); \
- trap "rm -rf $(TMPOUT)" EXIT; \
+ TMP="$(TMPOUT).$$$$.tmp"; \
+ TMPO="$(TMPOUT).$$$$.o"; \
if ($(1)) >/dev/null 2>&1; \
then echo "$(2)"; \
else echo "$(3)"; \
- fi)
+ fi; \
+ rm -f "$$TMP" "$$TMPO")
# as-option
# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)