blob: c126f2a22d333dd5ccf5e8826d4cb706fb6e3e89 [file] [log] [blame]
Jan Kundrát302a8512020-10-16 20:57:59 +00001From 0307515dad49ee108b10053757e43187debe0642 Mon Sep 17 00:00:00 2001
2From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
3Date: Wed, 19 Sep 2018 11:35:56 +0900
4Subject: [PATCH 2/3] Kbuild: fix # escaping in .cmd files for future Make
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9[ commit 9564a8cf422d7b58f6e857e3546d346fa970191e in Linux ]
10
11I tried building using a freshly built Make (4.2.1-69-g8a731d1), but
12already the objtool build broke with
13
14orc_dump.c: In function orc_dump’:
15orc_dump.c:106:2: error: elf_getshnum is deprecated [-Werror=deprecated-declarations]
16 if (elf_getshdrnum(elf, &nr_sections)) {
17
18Turns out that with that new Make, the backslash was not removed, so cpp
19didn't see a #include directive, grep found nothing, and
20-DLIBELF_USE_DEPRECATED was wrongly put in CFLAGS.
21
22Now, that new Make behaviour is documented in their NEWS file:
23
24 * WARNING: Backward-incompatibility!
25 Number signs (#) appearing inside a macro reference or function invocation
26 no longer introduce comments and should not be escaped with backslashes:
27 thus a call such as:
28 foo := $(shell echo '#')
29 is legal. Previously the number sign needed to be escaped, for example:
30 foo := $(shell echo '\#')
31 Now this latter will resolve to "\#". If you want to write makefiles
32 portable to both versions, assign the number sign to a variable:
33 C := \#
34 foo := $(shell echo '$C')
35 This was claimed to be fixed in 3.81, but wasn't, for some reason.
36 To detect this change search for 'nocomment' in the .FEATURES variable.
37
38This also fixes up the two make-cmd instances to replace # with $(pound)
39rather than with \#. There might very well be other places that need
40similar fixup in preparation for whatever future Make release contains
41the above change, but at least this builds an x86_64 defconfig with the
42new make.
43
44Link: https://bugzilla.kernel.org/show_bug.cgi?id=197847
45Cc: Randy Dunlap <rdunlap@infradead.org>
46Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
47Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
48---
49 scripts/Kbuild.include | 5 +++--
50 1 file changed, 3 insertions(+), 2 deletions(-)
51
52diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
53index 2c7918ad37..13ebddda65 100644
54--- a/scripts/Kbuild.include
55+++ b/scripts/Kbuild.include
56@@ -7,6 +7,7 @@ quote := "
57 squote := '
58 empty :=
59 space := $(empty) $(empty)
60+pound := \#
61
62 ###
63 # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
64@@ -242,11 +243,11 @@ endif
65
66 # Replace >$< with >$$< to preserve $ when reloading the .cmd file
67 # (needed for make)
68-# Replace >#< with >\#< to avoid starting a comment in the .cmd file
69+# Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file
70 # (needed for make)
71 # Replace >'< with >'\''< to be able to enclose the whole string in '...'
72 # (needed for the shell)
73-make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1)))))
74+make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
75
76 # Find any prerequisites that is newer than target or that does not exist.
77 # PHONY targets skipped in both cases.
78--
792.28.0
80