]>
Commit | Line | Data |
---|---|---|
b1b13083 GKH |
1 | From 9564a8cf422d7b58f6e857e3546d346fa970191e Mon Sep 17 00:00:00 2001 |
2 | From: Rasmus Villemoes <linux@rasmusvillemoes.dk> | |
3 | Date: Sun, 8 Apr 2018 23:35:28 +0200 | |
4 | Subject: Kbuild: fix # escaping in .cmd files for future Make | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | From: Rasmus Villemoes <linux@rasmusvillemoes.dk> | |
10 | ||
11 | commit 9564a8cf422d7b58f6e857e3546d346fa970191e upstream. | |
12 | ||
13 | I tried building using a freshly built Make (4.2.1-69-g8a731d1), but | |
14 | already the objtool build broke with | |
15 | ||
16 | orc_dump.c: In function ‘orc_dump’: | |
17 | orc_dump.c:106:2: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations] | |
18 | if (elf_getshdrnum(elf, &nr_sections)) { | |
19 | ||
20 | Turns out that with that new Make, the backslash was not removed, so cpp | |
21 | didn't see a #include directive, grep found nothing, and | |
22 | -DLIBELF_USE_DEPRECATED was wrongly put in CFLAGS. | |
23 | ||
24 | Now, that new Make behaviour is documented in their NEWS file: | |
25 | ||
26 | * WARNING: Backward-incompatibility! | |
27 | Number signs (#) appearing inside a macro reference or function invocation | |
28 | no longer introduce comments and should not be escaped with backslashes: | |
29 | thus a call such as: | |
30 | foo := $(shell echo '#') | |
31 | is legal. Previously the number sign needed to be escaped, for example: | |
32 | foo := $(shell echo '\#') | |
33 | Now this latter will resolve to "\#". If you want to write makefiles | |
34 | portable to both versions, assign the number sign to a variable: | |
35 | C := \# | |
36 | foo := $(shell echo '$C') | |
37 | This was claimed to be fixed in 3.81, but wasn't, for some reason. | |
38 | To detect this change search for 'nocomment' in the .FEATURES variable. | |
39 | ||
40 | This also fixes up the two make-cmd instances to replace # with $(pound) | |
41 | rather than with \#. There might very well be other places that need | |
42 | similar fixup in preparation for whatever future Make release contains | |
43 | the above change, but at least this builds an x86_64 defconfig with the | |
44 | new make. | |
45 | ||
46 | Link: https://bugzilla.kernel.org/show_bug.cgi?id=197847 | |
47 | Cc: Randy Dunlap <rdunlap@infradead.org> | |
48 | Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> | |
49 | Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> | |
50 | Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> | |
51 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
52 | ||
53 | --- | |
54 | scripts/Kbuild.include | 5 +++-- | |
55 | tools/build/Build.include | 5 +++-- | |
56 | tools/scripts/Makefile.include | 2 ++ | |
57 | 3 files changed, 8 insertions(+), 4 deletions(-) | |
58 | ||
59 | --- a/scripts/Kbuild.include | |
60 | +++ b/scripts/Kbuild.include | |
61 | @@ -7,6 +7,7 @@ quote := " | |
62 | squote := ' | |
63 | empty := | |
64 | space := $(empty) $(empty) | |
65 | +pound := \# | |
66 | ||
67 | ### | |
68 | # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o | |
69 | @@ -236,11 +237,11 @@ endif | |
70 | ||
71 | # Replace >$< with >$$< to preserve $ when reloading the .cmd file | |
72 | # (needed for make) | |
73 | -# Replace >#< with >\#< to avoid starting a comment in the .cmd file | |
74 | +# Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file | |
75 | # (needed for make) | |
76 | # Replace >'< with >'\''< to be able to enclose the whole string in '...' | |
77 | # (needed for the shell) | |
78 | -make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) | |
79 | +make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) | |
80 | ||
81 | # Find any prerequisites that is newer than target or that does not exist. | |
82 | # PHONY targets skipped in both cases. | |
83 | --- a/tools/build/Build.include | |
84 | +++ b/tools/build/Build.include | |
85 | @@ -12,6 +12,7 @@ | |
86 | # Convenient variables | |
87 | comma := , | |
88 | squote := ' | |
89 | +pound := \# | |
90 | ||
91 | ### | |
92 | # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o | |
93 | @@ -43,11 +44,11 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\ | |
94 | ### | |
95 | # Replace >$< with >$$< to preserve $ when reloading the .cmd file | |
96 | # (needed for make) | |
97 | -# Replace >#< with >\#< to avoid starting a comment in the .cmd file | |
98 | +# Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file | |
99 | # (needed for make) | |
100 | # Replace >'< with >'\''< to be able to enclose the whole string in '...' | |
101 | # (needed for the shell) | |
102 | -make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) | |
103 | +make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) | |
104 | ||
105 | ### | |
106 | # Find any prerequisites that is newer than target or that does not exist. | |
107 | --- a/tools/scripts/Makefile.include | |
108 | +++ b/tools/scripts/Makefile.include | |
109 | @@ -92,3 +92,5 @@ ifneq ($(silent),1) | |
110 | QUIET_INSTALL = @printf ' INSTALL %s\n' $1; | |
111 | endif | |
112 | endif | |
113 | + | |
114 | +pound := \# |