Skip to content

Commit 1e86004

Browse files
masahir0ykees
authored andcommitted
gcc-plugins: simplify GCC plugin-dev capability test
Linus pointed out a third of the time in the Kconfig parse stage comes from the single invocation of cc1plus in scripts/gcc-plugin.sh [1], and directly testing plugin-version.h for existence cuts down the overhead a lot. [2] This commit takes one step further to kill the build test entirely. The small piece of code was probably intended to test the C++ designated initializer, which was not supported until C++20. In fact, with -pedantic option given, both GCC and Clang emit a warning. $ echo 'class test { public: int test; } test = { .test = 1 };' | g++ -x c++ -pedantic - -fsyntax-only <stdin>:1:43: warning: C++ designated initializers only available with '-std=c++2a' or '-std=gnu++2a' [-Wpedantic] $ echo 'class test { public: int test; } test = { .test = 1 };' | clang++ -x c++ -pedantic - -fsyntax-only <stdin>:1:43: warning: designated initializers are a C++20 extension [-Wc++20-designator] class test { public: int test; } test = { .test = 1 }; ^ 1 warning generated. Otherwise, modern C++ compilers should be able to build the code, and hopefully skipping this test should not make any practical problem. Checking the existence of plugin-version.h is still needed to ensure the plugin-dev package is installed. The test code is now small enough to be embedded in scripts/gcc-plugins/Kconfig. [1] https://lore.kernel.org/lkml/CAHk-=wjU4DCuwQ4pXshRbwDCUQB31ScaeuDo1tjoZ0_PjhLHzQ@mail.gmail.com/ [2] https://lore.kernel.org/lkml/CAHk-=whK0aQxs6Q5ijJmYF1n2ch8cVFSUzU5yUM_HOjig=+vnw@mail.gmail.com/ Reported-by: Linus Torvalds <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent af2d222 commit 1e86004

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

scripts/gcc-plugin.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

scripts/gcc-plugins/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ menuconfig GCC_PLUGINS
99
bool "GCC plugins"
1010
depends on HAVE_GCC_PLUGINS
1111
depends on CC_IS_GCC
12-
depends on $(success,$(srctree)/scripts/gcc-plugin.sh $(CC))
12+
depends on $(success,test -e $(shell,$(CC) -print-file-name=plugin)/include/plugin-version.h)
1313
default y
1414
help
1515
GCC plugins are loadable modules that provide extra features to the

0 commit comments

Comments
 (0)