From patchwork Thu Oct 12 09:56:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115602 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1744719qgn; Thu, 12 Oct 2017 02:57:47 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB7arO6y9BbWudQgOlh/RFgfU4jxJFH7NQXYdh5eh012z3friJG22d2dzZwuIVJffGkoig4 X-Received: by 10.84.128.69 with SMTP id 63mr1784375pla.119.1507802267066; Thu, 12 Oct 2017 02:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507802267; cv=none; d=google.com; s=arc-20160816; b=zrtEq0J75qWLiui39FYIjVu6RIyW8rpQArmV6hPGTbLLIUSf/ijB8sHBFU5EkvtGkT CyflFj5ZFxnAB0Xkpk5Hc4lvzbFIJqxKWEoEuv2uhGKR9YmZVSn+mcEm/oSu0WRq4eW+ +OjhK2LhMsDjiPFzczk2JsxJeHrRaDsqoDaJSsClDpgbTlyGo3Pg7mIiJhEie4FmGeBW EYtTMkgb58rAQpK2+18xOx/yyWGX4BIx81HVDYArk+pCaWySmAfpgOQk6jBvl5Cg+941 pz/izfZLbLWyHJ9qhMSLu9r0iMi/dFtj/DKflic+RzxDxvwLos775+HZxLctftj5K7Qj 01wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=Qvjufx8+osW2OaHrl9kU4g2M/ttBP2djeCqMwHPmBng=; b=TOv9b5ZuaSbbz2sjij6gnZLdzmzqStraVsdGBxK1HX3tCY1AlNYDoHM9XJy7DoUSia lp/YhigzOOUJm1MdOp4TEAyC6tk4zMujD/E/Rc0CsweZnMODJMNmfzoRqEuIdQD/5Wx2 pRpdYH5pGBAg6RiupWUaj+WLG5b8k/IG4UEFY69kQcl8kJOjJgvaHMfXV+HZfoenOmCs lmjdQcqUuZgnfo+MJMndtujaBXZGshJju9Ck+yx+NGcUIR/SDSTUmkgaxITK6Hn7IV/y tkN2dKL5oIgkh5XBuwOXjzc6C0/wNu+HSV9eCO7rMtYcszx2gxkMfhGc0GS/0X45DGao grzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=bDtfCr5x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si12319609pfk.436.2017.10.12.02.57.46; Thu, 12 Oct 2017 02:57:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=bDtfCr5x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752580AbdJLJ5p (ORCPT + 27 others); Thu, 12 Oct 2017 05:57:45 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:26519 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750918AbdJLJ5e (ORCPT ); Thu, 12 Oct 2017 05:57:34 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9C9uHcm005959; Thu, 12 Oct 2017 18:56:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9C9uHcm005959 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507802181; bh=Qvjufx8+osW2OaHrl9kU4g2M/ttBP2djeCqMwHPmBng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bDtfCr5x0aMCZjWzU+74JAQ0OUE2915o4HHeP/paUb3ulOH2loaek+AQYT4TmJ9Kc X4OdJchdADCipIp3kmx1Lf5y0L//Xea4ViHEOakprg9IzZbN0w6HXFHvu0naz8lHnN EeTCDjEULyHP6r40W2fTxMu2mgccGCDiIvkS/zP7PXhDaRPTuBj7zx7iIf977+9DqU kNceIJ9yRy5pG0q9dyzzBjsXgM9zJnfatSG1DWhp5f6irSPEx+ErXrfdkaTa7PJGsS fRwiWjQf3gy15beal1sYdSmd4kjEMLn/yV2P0Z7Qdjrj2Sg4/6CfysTySL4/qDT7D/ KEd3EkRT3ZT3A== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Joe Perches , Tom Rini , Geert Uytterhoeven , Masahiro Yamada , Matthias Kaehlcke , Cao jin , Arnd Bergmann , James Hogan , linux-kernel@vger.kernel.org, =?utf-8?q?Jan-Simon_M=C3=B6ller?= , Michal Marek , Douglas Anderson , Josh Poimboeuf , Ingo Molnar , Mark Charlebois Subject: [PATCH 1/2] kbuild: add stringify helper to quote a string passed to C files Date: Thu, 12 Oct 2017 18:56:03 +0900 Message-Id: <1507802164-31614-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507802164-31614-1-git-send-email-yamada.masahiro@socionext.com> References: <1507802164-31614-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I want to reuse $(squote)$(quote)...$(quote)$(squote) in the next commit. Move it to a helper. Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 4 ++++ scripts/Makefile.lib | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index db81df3..0b97354 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -33,6 +33,10 @@ baseprereq = $(basename $(notdir $<)) escsq = $(subst $(squote),'\$(squote)',$1) ### +# Quote a string to pass it to C files. foo => '"foo"' +stringify = $(squote)$(quote)$1$(quote)$(squote) + +### # Easy method for doing a status message kecho := : quiet_kecho := echo diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 580e605..9bbb019 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -89,7 +89,7 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) # Note: Files that end up in two or more modules are compiled without the # KBUILD_MODNAME definition. The reason is that any made-up name would # differ in different configs. -name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) +name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1))) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = $(if $(filter 1,$(words $(modname))),\ -DKBUILD_MODNAME=$(call name-fix,$(modname))) From patchwork Thu Oct 12 09:56:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115600 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1744176qgn; Thu, 12 Oct 2017 02:57:01 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCK9lo013yI8Kic4keHitk8+nIYT0p8U2amQxl0pbK2P5+hQzDwdIO85ZakSSb01W/iWaUp X-Received: by 10.99.114.92 with SMTP id c28mr1665847pgn.342.1507802221692; Thu, 12 Oct 2017 02:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507802221; cv=none; d=google.com; s=arc-20160816; b=f9YaeXt0FJhFv9NplTbetGcKdfPnoQo9YGFkqz5aW7x0VWkOuMMRD419GvrfJewkS6 UWBjg1HF8cHoQ2/XnSA34YdW1vWVaB9BP4Uaq/GifYCddfyuXGGFGN0Sn/YbeUloiijQ Dckqc7U4cNvmi6gcnC1VDxCPHpq0XXtVUiTQlB6Ymf0hUkra90Jey6mv6Z7PtF3uNBRq ijCd+VEWWbyDcpNjFcP8b2cLQlxY7lwu3RfWn1kTVatJHokZOdv1sXIWpYPW+HOuOhtQ o/FDxOgnt3FSdCvx7IJAOSVxFSDyPQdm9w4v8u4WGKuFWQVcjtjJUQPluG3r/Bi5BCkF GHjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=Elzl/KgUZIx0gBuTNrqP4PegHU8/5dYlHpA274IafWQ=; b=qNCOXzGxGcEiW6fv6hwj06bF7x637WxlNk3IBuonfl1A87i/MXmOiGyOnj5JgUpNR7 XQxygnKELl6ix8ro7lTI4WiiXcZSIKSpLL3FEMj1W7bAHgc80PFMbALO3uQCTYVwHdoI gkki/CssE7QXKSHkmgyDSUHpNpWbmKGRmU73dbIXwXPLcEbf/dNfV82x3rsrkWT9nmS6 qSyzcG5QORm7CaEWw4tZqDpleZ5hD2cHVC1M5c/MbfP0i247iwMRUEfD6sAtGMQC8f/z w5eAx9hs3em0mHRa76LPrB+9hEO19XIyxt5A5pvd51p6a8XU1n9IqCQZ/kBdtL1Wco2B qjww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=yjal8HIh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p33si12159238pld.51.2017.10.12.02.57.01; Thu, 12 Oct 2017 02:57:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=yjal8HIh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752246AbdJLJ47 (ORCPT + 27 others); Thu, 12 Oct 2017 05:56:59 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:25465 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750722AbdJLJ46 (ORCPT ); Thu, 12 Oct 2017 05:56:58 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9C9uHcn005959; Thu, 12 Oct 2017 18:56:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9C9uHcn005959 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507802181; bh=Elzl/KgUZIx0gBuTNrqP4PegHU8/5dYlHpA274IafWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yjal8HIhF0aoJRKFlLp980ZLwRKtf8zn8beaP8MGXs56hvYTFXTiyuoa6ubmhsDk4 //NtQTx7pQAPfd8cmrh9vGQ+y69l1yc/3bwMupb2pM5L6pnKC3bi/ujrkQZM8wlWRp JPOnGz+bIGyRO9vzgiv9GEuJGeKmP5a1AziI9tJtICRJeg9/vQA8W8yaJLma/VFLDV R0wxcVARWxoFhAAuAGIDgKAvpNezdbk1eLkxTXbURdBiv7i2jkT4+UiLZQMsYyeCQC PZTcGR7i4o5Bhq4cb59T5quQf6VBdn+ifiYp2avq55keVhwAULm7G7ppbzybRPYzV4 dnE/yxnWlwoXw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Joe Perches , Tom Rini , Geert Uytterhoeven , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] kbuild: redefine __FILE__ as relative path from $(srctree) if possible Date: Thu, 12 Oct 2017 18:56:04 +0900 Message-Id: <1507802164-31614-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507802164-31614-1-git-send-email-yamada.masahiro@socionext.com> References: <1507802164-31614-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since Kbuild runs in the objtree, __FILE__ can be a very long path depending of $(srctree). Commit 9da0763bdd82 ("kbuild: Use relative path when building in a subdir of the source tree") made the situation better for cases where objtree is a child of srctree. ($(srctree) is "..") For other cases of out-of-tree build, filenames in WARN_ON() etc. are still an absolute path. It also means the kernel image depends on where it was built. Here, the idea is to redefine __FILE__ as the relative path from $(srctree), but doing so causes a compiler warning: warning: "__FILE__" redefined [-Wbuiltin-macro-redefined] The option -Wno-builtin-macro-redefined can suppress it, but it is only recognized by GCC 4.4 or newer. Re-define __FILE__ only when possible. Please note __FILE__ is always an absolute path for external modules. Signed-off-by: Masahiro Yamada --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.7.4 diff --git a/Makefile b/Makefile index 2c4a238..a3e8931 100644 --- a/Makefile +++ b/Makefile @@ -1091,6 +1091,15 @@ ifdef stackp-check endif @: +# If possible, redefne __FILE__ as relative path from $(srctree). +# $$ is needed to expand the following in submake +ifeq ($(call cc-option-yn,-Wno-builtin-macro-redefined),y) +KBUILD_CFLAGS += -Wno-builtin-macro-redefined \ + -D__FILE__=$$(call stringify,$$(src)/$$(notdir $$<)) +endif +# CAUTION: Do not add any reference to KBUILD_CFLAGS below this line. +# Any call of cc-option, etc. will fail. + # Generate some files # ---------------------------------------------------------------------------