All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Marek <mmarek@suse.cz>
To: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-kbuild <linux-kbuild@vger.kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	"x86@kernel.org" <x86@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] kbuild: escape single backslashes in macro make-cmd
Date: Wed, 06 Aug 2014 17:01:57 +0200	[thread overview]
Message-ID: <53E24365.6020405@suse.cz> (raw)
In-Reply-To: <CALYGNiO=oiiLgJRrpycO=CWyMMf8-AiDyW=Ch3ajV5W=9dtZfA@mail.gmail.com>

On 2014-08-06 14:19, Konstantin Khlebnikov wrote:
> On Wed, Aug 6, 2014 at 3:45 PM, Michal Marek <mmarek@suse.cz> wrote:
>> On 2014-07-26 18:35, Konstantin Khlebnikov wrote:
>>> This already has been fixed in commit c353acba28fb3fa1fd05fd
>>> ("kbuild: make: fix if_changed when command contains backslashes")
>>> but escaping still isn't perfect and triggers false-positive rebuilds.
>>>
>>> For x86 problem happens every time, because rules in arch/x86/realmode/rm/
>>> and arch/x86/boot/ contains commands like sed -n -e 's/foo\(.*\)/\1/p'.
>>> Backslash in \1 isn't escaped and turns into ascii symbol with code 1.
>>> Macro if_changed detects command change and rebuilds target again and again.
>>>
>>> Backslash escaping conflicts with other passes because it's used for escaping
>>> other symbols. To avoid that current macro handles only double backslashes.
>>> Obviously this doesn't work for \1 like above.
>>>
>>> This patch reorders passes. It doubles all backslashes before escaping # and '
>>>
>>> Visible effect in rebuilding x86/defconfig without changes, before patch:
>>>
>>> blind@zurg:~/src/linux$ make V=2
>>>   CHK     include/config/kernel.release
>>>   CHK     include/generated/uapi/linux/version.h
>>>   CHK     include/generated/utsrelease.h
>>>   CALL    scripts/checksyscalls.sh - due to target missing
>>>   CHK     include/generated/compile.h
>>>   PASYMS  arch/x86/realmode/rm/pasyms.h - due to command line change
>>
>> With which make and shell version are you seeing this? While the patch
>> looks correct, I can't reproduce the error here:
> 
> /bin/sh points to dash (debian default setup).
> 
> I cannot reproduce this using bash. That explains why this bug is still here.

So the difference between the shells is that their 'echo' builtin treats
\<number> differently:
$ ./dash -c "echo '\2'"
\x02\x02
$ ./dash -c "echo '\2'" | xxd
0000000: 020a                                     ..
$ /bin/bash -c "echo '\2'"
\2

For some reason we fail to escape the \ and dash treats \2 as \02. POSIX
says that this is implementation-defined, so none of the shells is wrong.

I need to look into this a bit further. I'll most likely end up applying
your patch, but I'd like to understand the fix in detail first.

Thanks,
Michal

  reply	other threads:[~2014-08-06 15:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-26 16:35 [PATCH] kbuild: escape single backslashes in macro make-cmd Konstantin Khlebnikov
2014-08-06 11:45 ` Michal Marek
2014-08-06 12:19   ` Konstantin Khlebnikov
2014-08-06 15:01     ` Michal Marek [this message]
2014-08-07 16:07       ` Michal Marek
2014-08-07 16:54         ` Konstantin Khlebnikov
2014-08-07 17:08         ` Sam Ravnborg
2014-08-07 19:56           ` [PATCH] kbuild: Fix handling of backslashes in *.cmd files Michal Marek

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=53E24365.6020405@suse.cz \
    --to=mmarek@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=koct9i@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=x86@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.