* [PATCH] kbuild: use -S instead of -E for precise cc-option test in Kconfig
@ 2020-01-17 17:14 Masahiro Yamada
2020-01-21 15:47 ` Masahiro Yamada
0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2020-01-17 17:14 UTC (permalink / raw)
To: linux-kbuild; +Cc: Arnd Bergmann, Masahiro Yamada, linux-kernel
Currently, -E (stop after the preprocessing stage) is used to check
whether the given compiler flag is supported.
While it is faster than -S (or -c), it can be false-positive. You need
to run the compilation proper to check the flag more precisely.
For example, when testing "--param asan-instrument-allocas=1", my gcc
gives a different result for -E vs -S.
$ gcc -Werror --param asan-instrument-allocas=1 -E -x c /dev/null -o /dev/null
$ echo $?
0
$ gcc -Werror --param asan-instrument-allocas=1 -S -x c /dev/null -o /dev/null
cc1: error: invalid --param name ‘asan-instrument-allocas’; did you mean ‘asan-instrument-writes’?
$ echo $?
1
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Kconfig.include | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index d4adfbe42690..bfb44b265a94 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y)
# $(cc-option,<flag>)
# Return y if the compiler supports <flag>, n otherwise
-cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null)
+cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null)
# $(ld-option,<flag>)
# Return y if the linker supports <flag>, n otherwise
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kbuild: use -S instead of -E for precise cc-option test in Kconfig
2020-01-17 17:14 [PATCH] kbuild: use -S instead of -E for precise cc-option test in Kconfig Masahiro Yamada
@ 2020-01-21 15:47 ` Masahiro Yamada
0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2020-01-21 15:47 UTC (permalink / raw)
To: Linux Kbuild mailing list; +Cc: Arnd Bergmann, Linux Kernel Mailing List
On Sat, Jan 18, 2020 at 2:16 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Currently, -E (stop after the preprocessing stage) is used to check
> whether the given compiler flag is supported.
>
> While it is faster than -S (or -c), it can be false-positive. You need
> to run the compilation proper to check the flag more precisely.
>
> For example, when testing "--param asan-instrument-allocas=1", my gcc
> gives a different result for -E vs -S.
>
> $ gcc -Werror --param asan-instrument-allocas=1 -E -x c /dev/null -o /dev/null
> $ echo $?
> 0
>
> $ gcc -Werror --param asan-instrument-allocas=1 -S -x c /dev/null -o /dev/null
> cc1: error: invalid --param name ‘asan-instrument-allocas’; did you mean ‘asan-instrument-writes’?
> $ echo $?
> 1
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
Applied to linux-kbuild.
> scripts/Kconfig.include | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
> index d4adfbe42690..bfb44b265a94 100644
> --- a/scripts/Kconfig.include
> +++ b/scripts/Kconfig.include
> @@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y)
>
> # $(cc-option,<flag>)
> # Return y if the compiler supports <flag>, n otherwise
> -cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null)
> +cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null)
>
> # $(ld-option,<flag>)
> # Return y if the linker supports <flag>, n otherwise
> --
> 2.17.1
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-21 15:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 17:14 [PATCH] kbuild: use -S instead of -E for precise cc-option test in Kconfig Masahiro Yamada
2020-01-21 15:47 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).