Skip to contentSkip to conversation

gcc-plugins: require GCC

PATCH In review Stefan Agner 3 participants 6 messages Aug 11, 2018 – Aug 14, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gcc-plugins: require GCC

Unsurprisingly GCC plugins require GCC as a compiler. This avoids GCC plugins being selectable when using clang.

---
 arch/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/Kconfig +1 -1
index 1aa59063f1fd..8c693a837ed7 100644
@@ -422,7 +422,7 @@ config HAVE_GCC_PLUGINS
 
 menuconfig GCC_PLUGINS
 	bool "GCC plugins"
-	depends on HAVE_GCC_PLUGINS
+	depends on HAVE_GCC_PLUGINS && CC_IS_GCC
 	depends on PLUGIN_HOSTCC != ""
 	help
 	  GCC plugins are loadable modules that provide extra features to the
Signature · 1 line
2.18.0
#1 lore raw

2018-08-11 18:48 GMT+09:00 Stefan Agner <[email protected]>:

Quoted 22 lines

Unsurprisingly GCC plugins require GCC as a compiler. This avoids GCC plugins being selectable when using clang.

---
 arch/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/Kconfig +1 -2
index 1aa59063f1fd..8c693a837ed7 100644
@@ -422,7 +422,7 @@ config HAVE_GCC_PLUGINS
 
 menuconfig GCC_PLUGINS
        bool "GCC plugins"
-       depends on HAVE_GCC_PLUGINS
+       depends on HAVE_GCC_PLUGINS && CC_IS_GCC
        depends on PLUGIN_HOSTCC != ""
        help
          GCC plugins are loadable modules that provide extra features to the
--
Quoted 2 lines

2.18.0

I guess the more correct way is to fix
scripts/gcc-plugin.sh

This shell script should exit 0
only when GCC plugin is supported.

Kees?

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 29 lines · Masahiro Yamada

2018-08-11 18:48 GMT+09:00 Stefan Agner <[email protected]>:

Quoted 22 lines

Unsurprisingly GCC plugins require GCC as a compiler. This avoids GCC plugins being selectable when using clang.

---
 arch/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/Kconfig +1 -2
index 1aa59063f1fd..8c693a837ed7 100644
@@ -422,7 +422,7 @@ config HAVE_GCC_PLUGINS
 
 menuconfig GCC_PLUGINS
        bool "GCC plugins"
-       depends on HAVE_GCC_PLUGINS
+       depends on HAVE_GCC_PLUGINS && CC_IS_GCC
        depends on PLUGIN_HOSTCC != ""
        help
          GCC plugins are loadable modules that provide extra features to the
--
Quoted 2 lines

2.18.0

I guess the more correct way is to fix
scripts/gcc-plugin.sh

Quoted 2 lines

This shell script should exit 0
only when GCC plugin is supported.

I'm of two minds: we already have the gcc test in Kconfig so we might want to avoid redundant checks, but maybe the script should be a "complete" test. I guess the latter. I will send a patch.

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
#3 lore raw
Quoted 31 lines · Kees Cook
Quoted 29 lines · Masahiro Yamada

2018-08-11 18:48 GMT+09:00 Stefan Agner <[email protected]>:

Quoted 22 lines

Unsurprisingly GCC plugins require GCC as a compiler. This avoids GCC plugins being selectable when using clang.

---
 arch/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/Kconfig +1 -2
index 1aa59063f1fd..8c693a837ed7 100644
@@ -422,7 +422,7 @@ config HAVE_GCC_PLUGINS
 
 menuconfig GCC_PLUGINS
        bool "GCC plugins"
-       depends on HAVE_GCC_PLUGINS
+       depends on HAVE_GCC_PLUGINS && CC_IS_GCC
        depends on PLUGIN_HOSTCC != ""
        help
          GCC plugins are loadable modules that provide extra features to the
--
Quoted 2 lines

2.18.0

I guess the more correct way is to fix
scripts/gcc-plugin.sh

Quoted 6 lines
Quoted 2 lines

This shell script should exit 0
only when GCC plugin is supported.

I'm of two minds: we already have the gcc test in Kconfig so we might want to avoid redundant checks, but maybe the script should be a "complete" test. I guess the latter. I will send a patch.

Actually, how about we do the test in Kconfig, but ahead of the script? That will reduce redundancy:

arch/Kconfig +0 -0
index 1aa59063f1fd..18f518624e41 100644
@@ -409,7 +409,7 @@ preferred-plugin-hostcc := $(if-success,[

$(gcc-version) -ge 40800 ],$(HOSTCXX),

config PLUGIN_HOSTCC
string
- default "$(shell,$(srctree)/scripts/gcc-plugin.sh
"$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")"
+ default "$(shell,$(srctree)/scripts/gcc-plugin.sh
"$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" if CC_IS_GCC

        help
          Host compiler used to build GCC plugins.  This can be $(HOSTCXX),
          $(HOSTCC), or a null string if GCC plugin is unsupported.

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
#4 lore raw
Quoted 55 lines · Kees Cook
Quoted 31 lines · Kees Cook
Quoted 29 lines · Masahiro Yamada

2018-08-11 18:48 GMT+09:00 Stefan Agner <[email protected]>:

Quoted 22 lines

Unsurprisingly GCC plugins require GCC as a compiler. This avoids GCC plugins being selectable when using clang.

---
 arch/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/Kconfig +1 -2
index 1aa59063f1fd..8c693a837ed7 100644
@@ -422,7 +422,7 @@ config HAVE_GCC_PLUGINS
 
 menuconfig GCC_PLUGINS
        bool "GCC plugins"
-       depends on HAVE_GCC_PLUGINS
+       depends on HAVE_GCC_PLUGINS && CC_IS_GCC
        depends on PLUGIN_HOSTCC != ""
        help
          GCC plugins are loadable modules that provide extra features to the
--
Quoted 2 lines

2.18.0

I guess the more correct way is to fix
scripts/gcc-plugin.sh

Quoted 6 lines
Quoted 2 lines

This shell script should exit 0
only when GCC plugin is supported.

I'm of two minds: we already have the gcc test in Kconfig so we might want to avoid redundant checks, but maybe the script should be a "complete" test. I guess the latter. I will send a patch.

Actually, how about we do the test in Kconfig, but ahead of the script? That will reduce redundancy:

arch/Kconfig +0 -1
index 1aa59063f1fd..18f518624e41 100644
@@ -409,7 +409,7 @@ preferred-plugin-hostcc := $(if-success,[
 $(gcc-version) -ge 40800 ],$(HOSTCXX),
 
 config PLUGIN_HOSTCC
        string
-       default "$(shell,$(srctree)/scripts/gcc-plugin.sh

"$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")"
+ default "$(shell,$(srctree)/scripts/gcc-plugin.sh
"$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" if CC_IS_GCC

Quoted 3 lines
        help
          Host compiler used to build GCC plugins.  This can be $(HOSTCXX),
          $(HOSTCC), or a null string if GCC plugin is unsupported.

I like this better. A script which is called gcc-plugin.sh should only be called if gcc is used...

--
Stefan

Quoted 3 lines

-Kees

Reviewed-by
#5 lore raw

2018-08-14 6:29 GMT+09:00 Stefan Agner <[email protected]>:

Quoted 50 lines · Kees Cook
Quoted 49 lines · Kees Cook
Quoted 31 lines
Quoted 29 lines · Masahiro Yamada

2018-08-11 18:48 GMT+09:00 Stefan Agner <[email protected]>:

Quoted 22 lines

Unsurprisingly GCC plugins require GCC as a compiler. This avoids GCC plugins being selectable when using clang.

---
 arch/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/Kconfig +1 -2
index 1aa59063f1fd..8c693a837ed7 100644
@@ -422,7 +422,7 @@ config HAVE_GCC_PLUGINS
 
 menuconfig GCC_PLUGINS
        bool "GCC plugins"
-       depends on HAVE_GCC_PLUGINS
+       depends on HAVE_GCC_PLUGINS && CC_IS_GCC
        depends on PLUGIN_HOSTCC != ""
        help
          GCC plugins are loadable modules that provide extra features to the
--
Quoted 2 lines

2.18.0

I guess the more correct way is to fix
scripts/gcc-plugin.sh

Quoted 6 lines
Quoted 2 lines

This shell script should exit 0
only when GCC plugin is supported.

I'm of two minds: we already have the gcc test in Kconfig so we might want to avoid redundant checks, but maybe the script should be a "complete" test. I guess the latter. I will send a patch.

Actually, how about we do the test in Kconfig, but ahead of the script? That will reduce redundancy:

arch/Kconfig +0 -0
index 1aa59063f1fd..18f518624e41 100644
@@ -409,7 +409,7 @@ preferred-plugin-hostcc := $(if-success,[
 $(gcc-version) -ge 40800 ],$(HOSTCXX),
 
Quoted 13 lines
Quoted 9 lines
arch/Kconfig +0 -1
 config PLUGIN_HOSTCC
        string
-       default "$(shell,$(srctree)/scripts/gcc-plugin.sh

"$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")"
+ default "$(shell,$(srctree)/scripts/gcc-plugin.sh
"$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" if CC_IS_GCC

        help
          Host compiler used to build GCC plugins.  This can be $(HOSTCXX),
          $(HOSTCC), or a null string if GCC plugin is unsupported.

I like this better. A script which is called gcc-plugin.sh should only be called if gcc is used...

This does not work like that.

$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")

is expanded in the parse stage regardless of CC_IS_GCC.

If nobody comes up with a better way, I am fine with this.

Quoted 6 lines

--
Stefan

Quoted 3 lines

-Kees

Signature · 2 lines
Best Regards
Masahiro Yamada