public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <mmarek@suse.com>
Cc: x86@kernel.org, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org, dianders@chromium.org,
	Michael Davidson <md@google.com>,
	Greg Hackmann <ghackmann@google.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Stephen Hines <srhines@google.com>,
	Kees Cook <keescook@chromium.org>, Arnd Bergmann <arnd@arndb.de>,
	Bernhard.Rosenkranzer@linaro.org
Subject: Re: [PATCH 1/2] kbuild: Add macros cc-option-3 and __cc-option-3
Date: Wed, 2 Aug 2017 09:46:50 -0700	[thread overview]
Message-ID: <20170802164650.GG84665@google.com> (raw)
In-Reply-To: <20170721215657.81631-1-mka@chromium.org>

El Fri, Jul 21, 2017 at 02:56:56PM -0700 Matthias Kaehlcke ha dit:

> The macro cc-option receives two parameters (the second may be empty). It
> returns the first parameter if it is a valid compiler option, otherwise
> the second one. It is not evaluated if the second parameter is a valid
> compiler option. This seems to be fine in virtually all cases, however
> there are scenarios where the second paramater needs to be evaluated too,
> and an empty value (or a third option) should be returned if it is not
> valid.
> 
> The macro cc-option-3 receives three parameters and returns parameter 1
> or 2 (in this order) if one of them is found to be a valid compiler
> option, and otherwise paramater 3. The macro __cc-option-3 works
> analogously.

Any comment on this?

Thanks

Matthias

> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  scripts/Kbuild.include | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> index dd8e2dde0b34..dc83635f2317 100644
> --- a/scripts/Kbuild.include
> +++ b/scripts/Kbuild.include
> @@ -113,6 +113,11 @@ as-instr = $(call try-run,\
>  __cc-option = $(call try-run,\
>  	$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
>  
> +# __cc-option-3
> +# Usage: MY_CFLAGS += $(call __cc-option-3,$(CC),$(MY_CFLAGS),\
> +#	-mpreferred-stack-boundary=2,-mstack-alignment=4,)
> +__cc-option-3 = $(call __cc-option,$(1),$(2),$(3),$(call __cc-option,$(1),$(2),$(4),$(5)))
> +
>  # Do not attempt to build with gcc plugins during cc-option tests.
>  # (And this uses delayed resolution so the flags will be up to date.)
>  CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
> @@ -123,6 +128,10 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
>  cc-option = $(call __cc-option, $(CC),\
>  	$(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2))
>  
> +# cc-option-3
> +# Usage: cflags-y += $(call cc-option-3,-mpreferred-stack-boundary=3,-mstack-alignment=8,)
> +cc-option-3 = $(call cc-option,$(1),$(call cc-option,$(2),$(3)))
> +
>  # hostcc-option
>  # Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
>  hostcc-option = $(call __cc-option, $(HOSTCC),\

  parent reply	other threads:[~2017-08-02 16:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21 21:56 [PATCH 1/2] kbuild: Add macros cc-option-3 and __cc-option-3 Matthias Kaehlcke
2017-07-21 21:56 ` [PATCH 2/2] x86/build: Fix stack alignment for CLang Matthias Kaehlcke
2017-08-02 16:46 ` Matthias Kaehlcke [this message]
2017-08-07  1:01   ` [PATCH 1/2] kbuild: Add macros cc-option-3 and __cc-option-3 Masahiro Yamada
2017-08-07 18:33     ` Matthias Kaehlcke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170802164650.GG84665@google.com \
    --to=mka@chromium.org \
    --cc=Bernhard.Rosenkranzer@linaro.org \
    --cc=arnd@arndb.de \
    --cc=dianders@chromium.org \
    --cc=ghackmann@google.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=md@google.com \
    --cc=mingo@redhat.com \
    --cc=mmarek@suse.com \
    --cc=ndesaulniers@google.com \
    --cc=srhines@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox