diff mbox

[v2,1/4] kbuild: Add cc-option-raw macro

Message ID 20170613230854.112282-2-mka@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Matthias Kaehlcke June 13, 2017, 11:08 p.m. UTC
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-raw which serves the same purpose as
cc-option but has additional parameters. One parameter is the compiler
with which the check should be performed, the other the compiler options
to be used instead KBUILD_C*FLAGS. The compiler parameter allows other
macros like hostcc-option to be implemented on top of cc-option-raw.

Also rework cc-option to make use of cc-option-raw.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
Changes in v2:
- Changed macro name from Add cc-option-no-kbuild to cc-option-raw
- Added compiler as parameter to the macro
- Reworked cc-option to make use of cc-option-raw
- Updated commit message

 scripts/Kbuild.include | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Masahiro Yamada June 14, 2017, 1:27 a.m. UTC | #1
2017-06-14 8:08 GMT+09:00 Matthias Kaehlcke <mka@chromium.org>:
> 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-raw which serves the same purpose as
> cc-option but has additional parameters. One parameter is the compiler
> with which the check should be performed, the other the compiler options
> to be used instead KBUILD_C*FLAGS. The compiler parameter allows other
> macros like hostcc-option to be implemented on top of cc-option-raw.
>
> Also rework cc-option to make use of cc-option-raw.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> Changes in v2:
> - Changed macro name from Add cc-option-no-kbuild to cc-option-raw
> - Added compiler as parameter to the macro
> - Reworked cc-option to make use of cc-option-raw
> - Updated commit message
>
>  scripts/Kbuild.include | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>

Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
(if nothing better pops up)
Arnd Bergmann June 14, 2017, 7:31 a.m. UTC | #2
On Wed, Jun 14, 2017 at 3:27 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 2017-06-14 8:08 GMT+09:00 Matthias Kaehlcke <mka@chromium.org>:
>> 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-raw which serves the same purpose as
>> cc-option but has additional parameters. One parameter is the compiler
>> with which the check should be performed, the other the compiler options
>> to be used instead KBUILD_C*FLAGS. The compiler parameter allows other
>> macros like hostcc-option to be implemented on top of cc-option-raw.
>>
>> Also rework cc-option to make use of cc-option-raw.
>>
>> Suggested-by: Arnd Bergmann <arnd@arndb.de>
>> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
>> ---
>> Changes in v2:
>> - Changed macro name from Add cc-option-no-kbuild to cc-option-raw
>> - Added compiler as parameter to the macro
>> - Reworked cc-option to make use of cc-option-raw
>> - Updated commit message
>>
>>  scripts/Kbuild.include | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>
> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> (if nothing better pops up)

Acked-by: Arnd Bergmann <arnd@arndb.de>

Regarding the naming, __cc-option might be better than cc-option-raw,
but the current version is fine too.

          Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada June 14, 2017, 7:44 a.m. UTC | #3
Hi Arnd,


2017-06-14 16:31 GMT+09:00 Arnd Bergmann <arnd@arndb.de>:
> On Wed, Jun 14, 2017 at 3:27 AM, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> 2017-06-14 8:08 GMT+09:00 Matthias Kaehlcke <mka@chromium.org>:
>>> 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-raw which serves the same purpose as
>>> cc-option but has additional parameters. One parameter is the compiler
>>> with which the check should be performed, the other the compiler options
>>> to be used instead KBUILD_C*FLAGS. The compiler parameter allows other
>>> macros like hostcc-option to be implemented on top of cc-option-raw.
>>>
>>> Also rework cc-option to make use of cc-option-raw.
>>>
>>> Suggested-by: Arnd Bergmann <arnd@arndb.de>
>>> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
>>> ---
>>> Changes in v2:
>>> - Changed macro name from Add cc-option-no-kbuild to cc-option-raw
>>> - Added compiler as parameter to the macro
>>> - Reworked cc-option to make use of cc-option-raw
>>> - Updated commit message
>>>
>>>  scripts/Kbuild.include | 9 +++++++--
>>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>
>> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> (if nothing better pops up)
>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
>
> Regarding the naming, __cc-option might be better than cc-option-raw,
> but the current version is fine too.


Thank you for your suggestion.

Yes, double-underscore prefix is often used in the kernel coding,
so I like your idea.

I will leave it up to Matthias, though.
Either will be fine for me.

Thanks!
Michal Marek June 14, 2017, 8:32 a.m. UTC | #4
Dne 14.6.2017 v 09:31 Arnd Bergmann napsal(a):
> On Wed, Jun 14, 2017 at 3:27 AM, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> 2017-06-14 8:08 GMT+09:00 Matthias Kaehlcke <mka@chromium.org>:
>>> 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-raw which serves the same purpose as
>>> cc-option but has additional parameters. One parameter is the compiler
>>> with which the check should be performed, the other the compiler options
>>> to be used instead KBUILD_C*FLAGS. The compiler parameter allows other
>>> macros like hostcc-option to be implemented on top of cc-option-raw.
>>>
>>> Also rework cc-option to make use of cc-option-raw.
>>>
>>> Suggested-by: Arnd Bergmann <arnd@arndb.de>
>>> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
>>> ---
>>> Changes in v2:
>>> - Changed macro name from Add cc-option-no-kbuild to cc-option-raw
>>> - Added compiler as parameter to the macro
>>> - Reworked cc-option to make use of cc-option-raw
>>> - Updated commit message
>>>
>>>  scripts/Kbuild.include | 9 +++++++--
>>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>
>> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> (if nothing better pops up)
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Michal Marek <mmarek@suse.com>


> Regarding the naming, __cc-option might be better than cc-option-raw,
> but the current version is fine too.

I have no strong opinion either way :).

Michal

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Matthias Kaehlcke June 14, 2017, 4:38 p.m. UTC | #5
El Wed, Jun 14, 2017 at 10:32:20AM +0200 Michal Marek ha dit:

> Dne 14.6.2017 v 09:31 Arnd Bergmann napsal(a):
> > On Wed, Jun 14, 2017 at 3:27 AM, Masahiro Yamada
> > <yamada.masahiro@socionext.com> wrote:
> >> 2017-06-14 8:08 GMT+09:00 Matthias Kaehlcke <mka@chromium.org>:
> >>> 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-raw which serves the same purpose as
> >>> cc-option but has additional parameters. One parameter is the compiler
> >>> with which the check should be performed, the other the compiler options
> >>> to be used instead KBUILD_C*FLAGS. The compiler parameter allows other
> >>> macros like hostcc-option to be implemented on top of cc-option-raw.
> >>>
> >>> Also rework cc-option to make use of cc-option-raw.
> >>>
> >>> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> >>> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> >>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> >>> ---
> >>> Changes in v2:
> >>> - Changed macro name from Add cc-option-no-kbuild to cc-option-raw
> >>> - Added compiler as parameter to the macro
> >>> - Reworked cc-option to make use of cc-option-raw
> >>> - Updated commit message
> >>>
> >>>  scripts/Kbuild.include | 9 +++++++--
> >>>  1 file changed, 7 insertions(+), 2 deletions(-)
> >>>
> >>
> >> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> >> (if nothing better pops up)
> > 
> > Acked-by: Arnd Bergmann <arnd@arndb.de>
> 
> Acked-by: Michal Marek <mmarek@suse.com>
> 
> 
> > Regarding the naming, __cc-option might be better than cc-option-raw,
> > but the current version is fine too.
> 
> I have no strong opinion either way :).

I'm going to change it to __cc-option since there is a slight
preference for it and I have to respin the series anyway. I'll wait
a bit for feedback from the x86 folks before sending the new version.
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 61f87a99bf0a..6dd0d1a921d6 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -108,6 +108,11 @@  as-option = $(call try-run,\
 as-instr = $(call try-run,\
 	printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
 
+# cc-option-raw
+# Usage: MY_CFLAGS += $(call cc-option-raw,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
+cc-option-raw = $(call try-run,\
+	$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
+
 # 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))
@@ -115,8 +120,8 @@  CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
 # cc-option
 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
 
-cc-option = $(call try-run,\
-	$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
+cc-option = $(call cc-option-raw, $(CC), $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),\
+	$(1), $(2))
 
 # cc-option-yn
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)