LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Horst Schirmeier <horst@schirmeier.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Andi Kleen <ak@suse.de>, Jan Beulich <jbeulich@novell.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	jpdenheijer@gmail.com, linux-kernel@vger.kernel.org,
	dsd@gentoo.org, draconx@gmail.com, kernel@gentoo.org
Subject: [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch
Date: Sun, 29 Oct 2006 01:07:30 +0200	[thread overview]
Message-ID: <20061028230730.GA28966@quickstop.soohrt.org> (raw)

Hello,

the kbuild-dont-put-temp-files-in-the-source-tree.patch (-mm patches) is
implemented faultily and fails in its intention to put temporary files
in $TMPDIR (or /tmp by default).

This is the code as it results from the patch:

ASTMP = $(shell mktemp ${TMPDIR:-/tmp}/asXXXXXX)
as-instr = $(shell if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o $ASTMP ; \
 		   then echo "$(2)"; else echo "$(3)"; fi; \
	           rm -f $ASTMP)

1) $ needs to be escaped in the shell function call, otherwise make
   tries to substitute with a (in this case not existing) make variable
   with this name.

2) Makefile variable names need to be put in parentheses; $ASTMP is
   being interpreted as $(A)STMP, resulting in as-instr writing to a file
   named after whatever is in $(A), followed by "STMP".

3) ld-option also writes to a temporary file and needs the same
   treatment.

Please consider using the corrected patch below instead. Alternatively,
we could also simply use -o /dev/null, as we are not interested in the
output anyways. Daniel Drake already suggested this in a LKML post
(message-id 452F9602.1050906@gentoo.org).

It would also be nice if this would make it into the mainline kernel
before 2.6.19 gets released; this would help avoiding the sandbox
violation problems on Gentoo Linux [1] [2].

Kind regards,
 Horst Schirmeier

[1] http://bugs.gentoo.org/show_bug.cgi?id=149307
[2] LKML Message-ID: <451ABE0E.2030904@web.de>

---
http://bugzilla.kernel.org/show_bug.cgi?id=7261 berates us for putting a
temporary file into the kernel source tree.  Use mktemp instead.

Cc: Andi Kleen <ak@suse.de>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: jpdenheijer@gmail.com,
Signed-off-by: Horst Schirmeier <horst@schirmeier.com>
---

 Kbuild.include |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--- linux-mm/scripts/Kbuild.include.orig	2006-10-29 00:39:35.000000000 +0200
+++ linux-mm/scripts/Kbuild.include	2006-10-29 00:41:43.000000000 +0200
@@ -66,9 +66,10 @@ as-option = $(shell if $(CC) $(CFLAGS) $
 # as-instr
 # Usage: cflags-y += $(call as-instr, instr, option1, option2)
 
-as-instr = $(shell if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o astest$$$$.out ; \
+ASTMP = $(shell mktemp $${TMPDIR:-/tmp}/asXXXXXX)
+as-instr = $(shell if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o $(ASTMP) ; \
 		   then echo "$(2)"; else echo "$(3)"; fi; \
-	           rm -f astest$$$$.out)
+	           rm -f $(ASTMP))
 
 # cc-option
 # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
@@ -97,10 +98,11 @@ 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 ldtest$$$$.out -xc /dev/null \
+			     -nostdlib -o $(LDTMP) -xc /dev/null \
              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi; \
-	     rm -f ldtest$$$$.out)
+	     rm -f $(LDTMP))
 
 ###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=

             reply	other threads:[~2006-10-28 23:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-28 23:07 Horst Schirmeier [this message]
2006-10-29  2:07 ` Andi Kleen
2006-10-29 12:08   ` Horst Schirmeier
2006-10-29 16:16     ` Andi Kleen
2006-10-29 17:52       ` Oleg Verych
2006-10-29 22:52         ` Sam Ravnborg
2006-10-30  8:16           ` Jan Beulich
2006-10-30 13:16             ` Oleg Verych
     [not found]               ` <45460E6C.76E4.0078.0@novell.com>
2006-10-30 14:42                 ` Oleg Verych
2006-10-30 15:22                   ` Valdis.Kletnieks
2006-10-30 16:06                     ` Oleg Verych
2006-10-30 22:12                       ` Oleg Verych
2006-10-31  0:12                         ` Horst Schirmeier
2006-10-31  0:19                           ` Andi Kleen
2006-10-31  1:14                             ` Horst Schirmeier
2006-10-31 13:51                               ` Oleg Verych
2006-11-02 12:46                                 ` Jan Peter den Heijer
2006-11-17  5:17                                 ` kbuild: O= with M= (Re: [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch) Oleg Verych
2007-01-23  7:36                                   ` [fix, rfc] " Oleg Verych
2007-01-24  8:54                                 ` [patch] kbuild: improving option checking " Oleg Verych
2007-01-24 16:06                                   ` Randy Dunlap
2007-01-24 19:28                                     ` [patch] spell 4 kbuild: improving option checking Oleg Verych
2006-10-31  0:27                         ` [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch Horst Schirmeier
2006-10-31 13:32                           ` Oleg Verych
2006-11-15 14:17                           ` kbuild-mm: $(objtree)/knull vs mktemp (was Re: [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch) Oleg Verych

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061028230730.GA28966@quickstop.soohrt.org \
    --to=horst@schirmeier.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=draconx@gmail.com \
    --cc=dsd@gentoo.org \
    --cc=jbeulich@novell.com \
    --cc=jpdenheijer@gmail.com \
    --cc=kernel@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    --subject='Re: [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).