Skip to contentSkip to conversation

actually delete the as-instr/ld-option tmp file

PATCH New Horst Schirmeier 1 participant 1 message Dec 4, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 actually delete the as-instr/ld-option tmp file

I noticed another problem in the kbuild-dont-put-temp-files-in-the-source-tree.patch: A "normal" make variable is being expanded recursively on each use, therefore multiple uses of $(ASTMP) yield different temporary files. So $(AS) -o $(ASTMP) writes to a file other than the one rm -f $(ASTMP) deletes, leaving behind the first file in /tmp.

Using "simply expanded variables" (by assigning the mktemp output with := instead of =) can be problematic, as parallel make processes would all write to and delete the very same tmp file, so I chose to fix this by storing the $(ASTMP) output in a shell variable and reusing it.

---

 Kbuild.include |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
scripts/Kbuild.include renamed from scripts/Kbuild.include.current-mm +6 -5
@@ -67,9 +67,10 @@ as-option = $(shell if $(CC) $(CFLAGS) $
 # Usage: cflags-y += $(call as-instr, instr, option1, option2)
 
 ASTMP = $(shell mktemp $${TMPDIR:-/tmp}/asXXXXXX)
-as-instr = $(shell if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o $(ASTMP) ; \
+as-instr = $(shell ASTMP=$(ASTMP); \
+		   if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o $$ASTMP ; \
 		   then echo "$(2)"; else echo "$(3)"; fi; \
-	           rm -f $(ASTMP))
+	           rm -f $$ASTMP)
 
 # cc-option
 # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
@@ -99,10 +100,10 @@ cc-ifversion = $(shell if [ $(call cc-ve
 # ld-option
 # Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both)
 LDTMP = $(shell mktemp $${TMPDIR:-/tmp}/ldXXXXXX)
-ld-option = $(shell if $(CC) $(1) \
-			     -nostdlib -o $(LDTMP) -xc /dev/null \
+ld-option = $(shell LDTMP=$(LDTMP); \
+	     if $(CC) $(1) -nostdlib -o $$LDTMP -xc /dev/null \
              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi; \
-	     rm -f $(LDTMP))
+	     rm -f $$LDTMP)
 
 ###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
Signature · 1 line
PGP-Key 0xD40E0E7A