From patchwork Sun Apr 8 21:35:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10328633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E93A360385 for ; Sun, 8 Apr 2018 21:35:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDFAB2892D for ; Sun, 8 Apr 2018 21:35:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B0EB2893A; Sun, 8 Apr 2018 21:35:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D16D2892D for ; Sun, 8 Apr 2018 21:35:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752935AbeDHVfe (ORCPT ); Sun, 8 Apr 2018 17:35:34 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:35227 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752847AbeDHVfd (ORCPT ); Sun, 8 Apr 2018 17:35:33 -0400 Received: by mail-wm0-f50.google.com with SMTP id r82so12420352wme.0 for ; Sun, 08 Apr 2018 14:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O6TmLElCpQfFXjTNdMwIBgWMl6SnsNOLJulke0LqujY=; b=HwYhkZroqaaYrkgGMPXUmYpGJ8P3iyxpXHOdCeMl/ebsZGghCJ5DywpQ/0mpVQl6oN TIM/+VFD6bVH+uL89fkeu6yF83wkkAkRqYdvme8jeJZmRBO8ryfnxyxx4rrR0/eCsmZE i0gizoHAkgiDimSFjsiFYjKuSMp/cH47e77q8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O6TmLElCpQfFXjTNdMwIBgWMl6SnsNOLJulke0LqujY=; b=mOyJDFcV6mtRbvaighPjtKJ217jePczjOPtUJWWK9Mu9r3rINiAwNDmvjzwpg3VKUf lMhnn7VBtwuvYO5M8zCGmWp+59er7QE8ON3f7fEeFCMRnzrq1YZB72WSG+4I1gCvpkzp CwaYWwpdMcrizVvoHtxbZd7H2RluoOqQRzdkNxRyq2PTrXUCwZ60AjwW7/Iui1r93U+k omOtuvImyq2dGlcW8flDKg23OrxYsaWhs7RtxMlZfVJ/yUGgJ/1tmm4WKuhVghGO33/b WmORFKKqb6mb1eU8RqxrtVbWw+WfoEk2uuVAAB99GnLbIwl7zNVXtq4eEe32w6ULEk/g lWvA== X-Gm-Message-State: ALQs6tAZq7QLBAKqkTBYu8sViy34jOPdSCypM2vwZcGrHoB0ZUaZ9ts8 xf+EJgb89uBw2FFER+QT8w0gPA== X-Google-Smtp-Source: AIpwx48tQFsWGQW0IrIRGYzzeB/Eh0iSyZnM11c0Jh4RSJZfluo94cjlH5Rfqi+Gxcs4he4JVSvQbg== X-Received: by 10.80.247.129 with SMTP id h1mr9653794edn.293.1523223332034; Sun, 08 Apr 2018 14:35:32 -0700 (PDT) Received: from prevas-ravi.waoo.dk (dhcp-5-186-126-104.cgn.ip.fibianet.dk. [5.186.126.104]) by smtp.gmail.com with ESMTPSA id i93sm4209382edc.55.2018.04.08.14.35.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Apr 2018 14:35:31 -0700 (PDT) From: Rasmus Villemoes To: Masahiro Yamada , Josh Poimboeuf , Peter Zijlstra Cc: Linux Kbuild mailing list , Rasmus Villemoes , Randy Dunlap , linux-kernel@vger.kernel.org Subject: [PATCH v2] Kbuild: fix # escaping in .cmd files for future Make Date: Sun, 8 Apr 2018 23:35:28 +0200 Message-Id: <20180408213528.26758-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.15.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I tried building using a freshly built Make (4.2.1-69-g8a731d1), but already the objtool build broke with orc_dump.c: In function ‘orc_dump’: orc_dump.c:106:2: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations] if (elf_getshdrnum(elf, &nr_sections)) { Turns out that with that new Make, the backslash was not removed, so cpp didn't see a #include directive, grep found nothing, and -DLIBELF_USE_DEPRECATED was wrongly put in CFLAGS. Now, that new Make behaviour is documented in their NEWS file: * WARNING: Backward-incompatibility! Number signs (#) appearing inside a macro reference or function invocation no longer introduce comments and should not be escaped with backslashes: thus a call such as: foo := $(shell echo '#') is legal. Previously the number sign needed to be escaped, for example: foo := $(shell echo '\#') Now this latter will resolve to "\#". If you want to write makefiles portable to both versions, assign the number sign to a variable: C := \# foo := $(shell echo '$C') This was claimed to be fixed in 3.81, but wasn't, for some reason. To detect this change search for 'nocomment' in the .FEATURES variable. This also fixes up the two make-cmd instances to replace # with $(pound) rather than with \#. There might very well be other places that need similar fixup in preparation for whatever future Make release contains the above change, but at least this builds an x86_64 defconfig with the new make. Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=197847 Cc: Randy Dunlap Signed-off-by: Rasmus Villemoes --- v2: - squash the original objtool-only patch with the patch fixing up make-cmd, to avoid repeating the reference to the Make NEWS. - use $(pound) in .cmd files to avoid backslash-counting issues (Masahiro). - add bugzilla link (Randy). scripts/Kbuild.include | 5 +++-- tools/build/Build.include | 5 +++-- tools/objtool/Makefile | 2 +- tools/scripts/Makefile.include | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index cce31ee876b6..50cee534fd64 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -10,6 +10,7 @@ space := $(empty) $(empty) space_escape := _-_SPACE_-_ right_paren := ) left_paren := ( +pound := \# ### # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o @@ -322,11 +323,11 @@ endif # Replace >$< with >$$< to preserve $ when reloading the .cmd file # (needed for make) -# Replace >#< with >\#< to avoid starting a comment in the .cmd file +# Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file # (needed for make) # Replace >'< with >'\''< to be able to enclose the whole string in '...' # (needed for the shell) -make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) +make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) # Find any prerequisites that is newer than target or that does not exist. # PHONY targets skipped in both cases. diff --git a/tools/build/Build.include b/tools/build/Build.include index 418871d02ebf..a4bbb984941d 100644 --- a/tools/build/Build.include +++ b/tools/build/Build.include @@ -12,6 +12,7 @@ # Convenient variables comma := , squote := ' +pound := \# ### # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o @@ -43,11 +44,11 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\ ### # Replace >$< with >$$< to preserve $ when reloading the .cmd file # (needed for make) -# Replace >#< with >\#< to avoid starting a comment in the .cmd file +# Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file # (needed for make) # Replace >'< with >'\''< to be able to enclose the whole string in '...' # (needed for the shell) -make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) +make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) ### # Find any prerequisites that is newer than target or that does not exist. diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index e6acc281dd37..8ae824dbfca3 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -35,7 +35,7 @@ CFLAGS += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES) LDFLAGS += -lelf $(LIBSUBCMD) # Allow old libelf to be used: -elfshdr := $(shell echo '\#include ' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) +elfshdr := $(shell echo '$(pound)include ' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) AWK = awk diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index dd614463d4d6..495066bafbe3 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -120,3 +120,5 @@ ifneq ($(silent),1) QUIET_UNINST = @printf ' UNINST %s\n' $1; endif endif + +pound := \#