bugmake - Bugs: bug #20513, # still needs to be escaped in a...


bug #20513: # still needs to be escaped in a function like $(shell)

Submitted by:  Lionel Elie Mamane <lmamane>
Submitted on:  Wed 18 Jul 2007 03:50:08 PM UTC  
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  Paul D. Smith <psmith> Open/Closed:  Closed
Component Version:  3.81 Operating System:  POSIX-Based
Fixed Release:  SCM Triage Status:  Medium Effort

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sat 29 Sep 2018 01:32:09 AM UTC, comment #4:

Back in the day, the Linux kernel makefiles, for example:


... defined a KBUILD_STR macro with a # escaped like this:

Such a # would still need escaping today. The command line used to compile each .o file is written into a .$(basename).o.cmd file by some code mainly in the like of:


... which puts the command line through:

The # characters there used to need escaping like that but now the backslashes are being taken literally. This means that the code looks for \# but only finds #, so doesn't perform the substitution. The .$(basename).o.cmd file ends up containing an assignment like:

That # was supposed to be a \#. It still needs escaping today. The rest of the line is treated as a comment and omitted from the assignment.

There's some arg-check code which compares the cmd_ assigned in the .cmd file with the command line that would be run now. If that command line has changed, then the .o file is rebuilt. Now the command line always seems to change, because the latter part of the old one has been omitted, so the .o file is always rebuilt.

If you pass some kind of V=2 parameter to the build, you can see that each .o file rebuilds "$(basename).o - due to command line change".

If you pass KBUILD_NOCMDDEP=1, then you skip the arg-check code and get an incremental build as intended.

I think KBUILD_STR disappeared with:


Perhaps the labels there are telling me that it disappeared as early as 4.7-rc1, so that's gone from Debian by Stretch (linux-image-amd64 4.9). I think this change in Make isn't yet in Debian. To be clear: it doesn't break builds of modules for earlier kernels, so we're unlikely to have:

https://savannah.gnu.org/bugs/index.php?33034: "Makefile:23: *** mixed implicit and normal rules. Stop." for Linux kernel out of source builds

... all over again. It just stops them from being incremental.

I imagine no-one will ever notice, but hopefully this post will stop anyone else wasting as much time on it as I did today.

Martin Dorey <mdorey>
Mon 26 Dec 2016 02:34:03 PM UTC, comment #3:

This is finally fixed. However, it is a backward-compat break. We'll have to see how serious it is; it's possible we'll have to introduce some way to recognize both formats for a while, or something.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Sat 10 May 2008 10:42:26 PM UTC, comment #2:

I get the exact same error when building jhbuild:

make[1]: Leaving directory `/home/gezim/projects/jhbuild/po'
make[1]: Entering directory `/home/gezim/projects/jhbuild'
test z"." = z"." && make -f Makefile.plain || true
make[2]: Entering directory `/home/gezim/projects/jhbuild'
Run "make install" to install.
make[2]: Leaving directory `/home/gezim/projects/jhbuild'
make[2]: Entering directory `/home/gezim/projects/jhbuild'
test z"." = z"." && make -f Makefile.plain install || true
make[3]: Entering directory `/home/gezim/projects/jhbuild'
cd po && make -f Makefile.plain install
make[4]: Entering directory `/home/gezim/projects/jhbuild/po'
Makefile.plain:8: *** unterminated call to function `shell': missing `)'. Stop.
make[4]: Leaving directory `/home/gezim/projects/jhbuild/po'
make[3]: *** [install] Error 2
make[3]: Leaving directory `/home/gezim/projects/jhbuild'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/gezim/projects/jhbuild'
make[1]: Leaving directory `/home/gezim/projects/jhbuild'

make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A

This program built for i486-pc-linux-gnu

On ubuntu 8.04

Gezim <haxhia>
Wed 18 Jul 2007 03:51:07 PM UTC, comment #1:

Forgot to mention: Debian GNU/Linux sid i386 and amd64.

Lionel Elie Mamane <lmamane>
Wed 18 Jul 2007 03:50:08 PM UTC, original submission:

The NEWS file says:

Version 3.81

  • WARNING: Backward-incompatibility!

Some previous versions of GNU make had a bug where "#" in a function
invocation such as $(shell ...) was treated as a make comment. A
workaround was to escape these with backslashes. This bug has been
fixed: if your makefile uses "\#" in a function invocation the
backslash is now preserved, so you'll need to remove it.

But I still get that bug with 3.81 and with CVS HEAD. The following makefile:

FOO:=$(shell echo '#')
echo '$(FOO)'


Makefile:1: *** unterminated call to function `shell': missing `)'. Stop.


FOO:=$(shell echo '\#')
echo '$(FOO)'

works, and the backslash is not passed to the shell.

Lionel Elie Mamane <lmamane>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mdorey (Posted a comment)
  • -email is unavailable- added by psmith (Updated the item)
  • -email is unavailable- added by haxhia (Posted a comment)
  • -email is unavailable- added by lmamane (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-12-26 psmith StatusNone => Fixed
        Assigned toNone => psmith
        Open/ClosedOpen => Closed
        Fixed ReleaseNone => SCM
        Triage StatusVerified => Medium Effort
    2012-09-10 psmith Triage StatusNone => Verified

    Back to the top

    Powered by Savane 3.3