[PATCH -mm] actually delete the as-instr/ld-option tmp file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Horst Schirmeier <[email protected]>
---

 Kbuild.include |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- linux/scripts/Kbuild.include.current-mm	2006-12-04 11:31:55.000000000 +0100
+++ linux/scripts/Kbuild.include	2006-12-04 11:40:10.000000000 +0100
@@ -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=

-- 
PGP-Key 0xD40E0E7A

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux