Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753561AbdFMQp4 (ORCPT ); Tue, 13 Jun 2017 12:45:56 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:34392 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752695AbdFMQpy (ORCPT ); Tue, 13 Jun 2017 12:45:54 -0400 Date: Tue, 13 Jun 2017 09:45:52 -0700 From: Matthias Kaehlcke To: Masahiro Yamada Cc: Arnd Bergmann , Michal Marek , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , "H . J . Lu" , David Woodhouse , the arch/x86 maintainers , Linux Kbuild mailing list , Linux Kernel Mailing List , Michael Davidson , Greg Hackmann , Nick Desaulniers , Stephen Hines , Kees Cook , Bernhard.Rosenkranzer@linaro.org, Peter Foley , Behan Webster , Douglas Anderson Subject: Re: [PATCH 1/3] kbuild: Add cc-option-no-kbuild macro Message-ID: <20170613164552.GK141096@google.com> References: <20170613005531.77656-1-mka@chromium.org> <20170613005531.77656-2-mka@chromium.org> <638b79cf-a0e8-7986-d8b4-26d3a3808ec4@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2702 Lines: 60 El Tue, Jun 13, 2017 at 07:13:55PM +0900 Masahiro Yamada ha dit: > 2017-06-13 17:31 GMT+09:00 Arnd Bergmann : > > On Tue, Jun 13, 2017 at 9:49 AM, Michal Marek wrote: > >> On 2017-06-13 02:55, Matthias Kaehlcke wrote: > >>> cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines > >>> whether an option is supported or not. This is fine for options used to > >>> build the kernel itself, however some components like the x86 boot code > >>> use a different set of flags. > >>> > >>> Add the new macro cc-option-no-kbuild which does the same as cc-option > >>> except that it has an additional parameter with the compiler options > >>> which are used instead of KBUILD_CFLAGS and KBUILD_CPPFLAGS. > >>> > >>> Signed-off-by: Matthias Kaehlcke > >>> --- > >>> scripts/Kbuild.include | 5 +++++ > >>> 1 file changed, 5 insertions(+) > >>> > >>> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include > >>> index 61f87a99bf0a..d9fdc740105f 100644 > >>> --- a/scripts/Kbuild.include > >>> +++ b/scripts/Kbuild.include > >>> @@ -128,6 +128,11 @@ cc-option-yn = $(call try-run,\ > >>> cc-option-align = $(subst -functions=0,,\ > >>> $(call cc-option,-falign-functions=0,-malign-functions=0)) > >>> > >>> +# cc-option-no-kbuild > >>> +# Usage: cflags-no-kbuild-y += $(call cc-option-no-kbuild,,-march=winchip-c6,-march=i586) > >>> +cc-option-no-kbuild = $(call try-run,\ > >>> + $(CC) -Werror $(filter-out $(GCC_PLUGINS_CFLAGS),$(1)) $(2) -c -x c /dev/null -o "$$TMP",$(2),$(3)) > >> > >> As this is a version of cc-option with an extrra argument, how about > >> implementing cc-option as a shorthand for cc-option-no-kbuild? It would > >> make it more obvious what cc-option-no-kbuild does differently (it's > >> probably just me, but I was unable to infer the semantics from its name). > > > > Agreed, also the hostcc-option could be based on the same I think, if we > > also make the $(CC) an argument of the low-level helper. > > > > Agree. One possible implementation: > > cc-option-raw = $(call try-run,\ > $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) > > cc-option = $(call cc-option-raw, $(CC), $(KBUILD_CPPFLAGS) > $(CC_OPTION_CFLAGS),\ > $(1), $(2)) > > This will allow us to do: > hostcc-option = $(call cc-option-raw, $(HOSTCC), $(HOSTCFLAGS), $(1), $(2)) Looks good, thanks all for the suggestions. > Suggestion for a better name is welcome... Yeah, this tends to be the difficult part, I didn't like the initial 'cc-option-no-kbuild' either ... 'cc-option-raw' seems ok if nothing better pops up.