|
| 1 | +From e5e701c2b8470de044c5c71d2a54ecfc72680d59 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Rasmus Villemoes < [email protected]> |
| 3 | +Date: Wed, 19 Sep 2018 11:35:56 +0900 |
| 4 | +Subject: [PATCH] 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 | +[ commit 9564a8cf422d7b58f6e857e3546d346fa970191e in Linux ] |
| 10 | + |
| 11 | +I tried building using a freshly built Make (4.2.1-69-g8a731d1), but |
| 12 | +already the objtool build broke with |
| 13 | + |
| 14 | +orc_dump.c: In function ‘orc_dump’: |
| 15 | +orc_dump.c:106:2: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations] |
| 16 | + if (elf_getshdrnum(elf, &nr_sections)) { |
| 17 | + |
| 18 | +Turns out that with that new Make, the backslash was not removed, so cpp |
| 19 | +didn't see a #include directive, grep found nothing, and |
| 20 | +-DLIBELF_USE_DEPRECATED was wrongly put in CFLAGS. |
| 21 | + |
| 22 | +Now, 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 | + |
| 38 | +This also fixes up the two make-cmd instances to replace # with $(pound) |
| 39 | +rather than with \#. There might very well be other places that need |
| 40 | +similar fixup in preparation for whatever future Make release contains |
| 41 | +the above change, but at least this builds an x86_64 defconfig with the |
| 42 | +new make. |
| 43 | + |
| 44 | +Link: https://bugzilla.kernel.org/show_bug.cgi?id=197847 |
| 45 | +Cc: Randy Dunlap < [email protected]> |
| 46 | +Signed-off-by: Rasmus Villemoes < [email protected]> |
| 47 | +Signed-off-by: Masahiro Yamada < [email protected]> |
| 48 | +--- |
| 49 | + scripts/Kbuild.include | 5 +++-- |
| 50 | + 1 file changed, 3 insertions(+), 2 deletions(-) |
| 51 | + |
| 52 | +diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include |
| 53 | +index 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 | +-- |
| 79 | +2.27.0 |
| 80 | + |
0 commit comments