bug-make
[Top][All Lists]
Advanced

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

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


From: Martin Dorey
Subject: [bug #20513] # still needs to be escaped in a function like $(shell)
Date: Fri, 28 Sep 2018 21:32:09 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36

Follow-up Comment #4, bug #20513 (project make):

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

/usr/lib/linux-kbuild-3.16/scripts/Makefile.lib

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


c_flags        = ...
...
                 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)


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:

/usr/lib/linux-kbuild-3.16/scripts/Kbuild.include

... which puts the command line through:


make-cmd = $(subst \\,\\\\,$(subst \#,\\\#,$(subst $$,$$$$,$(call
escsq,$(cmd_$(1))))))


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:


cmd_$(dir)/$(basename).o = cc ... -D"KBUILD_STR(s)=#s" -c $(basename).c -o
$(basename).o


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:

https://github.com/torvalds/linux/commit/b42841b7bb6286da56b4fa79835c27166b7e228b

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.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?20513>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]