@@ -11,16 +11,13 @@ compiler [1]_. They are useful for runtime instrumentation and static analysis.
1111We can analyse, change and add further code during compilation via
1212callbacks [2 ]_, GIMPLE [3 ]_, IPA [4 ]_ and RTL passes [5 ]_.
1313
14- The GCC plugin infrastructure of the kernel supports all gcc versions from
15- 4.5 to 6.0, building out-of-tree modules, cross-compilation and building in a
16- separate directory.
17- Plugin source files have to be compilable by both a C and a C++ compiler as well
18- because gcc versions 4.5 and 4.6 are compiled by a C compiler,
19- gcc-4.7 can be compiled by a C or a C++ compiler,
20- and versions 4.8+ can only be compiled by a C++ compiler.
14+ The GCC plugin infrastructure of the kernel supports building out-of-tree
15+ modules, cross-compilation and building in a separate directory.
16+ Plugin source files have to be compilable by a C++ compiler.
2117
22- Currently the GCC plugin infrastructure supports only the x86, arm, arm64 and
23- powerpc architectures.
18+ Currently the GCC plugin infrastructure supports only some architectures.
19+ Grep "select HAVE_GCC_PLUGINS" to find out which architectures support
20+ GCC plugins.
2421
2522This infrastructure was ported from grsecurity [6 ]_ and PaX [7 ]_.
2623
@@ -47,42 +44,39 @@ Files
4744 This is a compatibility header for GCC plugins.
4845 It should be always included instead of individual gcc headers.
4946
50- **$(src)/scripts/gcc-plugin.sh **
51-
52- This script checks the availability of the included headers in
53- gcc-common.h and chooses the proper host compiler to build the plugins
54- (gcc-4.7 can be built by either gcc or g++).
55-
5647**$(src)/scripts/gcc-plugins/gcc-generate-gimple-pass.h,
5748$(src)/scripts/gcc-plugins/gcc-generate-ipa-pass.h,
5849$(src)/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h,
5950$(src)/scripts/gcc-plugins/gcc-generate-rtl-pass.h **
6051
6152 These headers automatically generate the registration structures for
62- GIMPLE, SIMPLE_IPA, IPA and RTL passes. They support all gcc versions
63- from 4.5 to 6.0.
53+ GIMPLE, SIMPLE_IPA, IPA and RTL passes.
6454 They should be preferred to creating the structures by hand.
6555
6656
6757Usage
6858=====
6959
7060You must install the gcc plugin headers for your gcc version,
71- e.g., on Ubuntu for gcc-4.9 ::
61+ e.g., on Ubuntu for gcc-10 ::
7262
73- apt-get install gcc-4.9 -plugin-dev
63+ apt-get install gcc-10 -plugin-dev
7464
7565Or on Fedora::
7666
7767 dnf install gcc-plugin-devel
7868
79- Enable a GCC plugin based feature in the kernel config::
69+ Enable the GCC plugin infrastructure and some plugin(s) you want to use
70+ in the kernel config::
8071
81- CONFIG_GCC_PLUGIN_CYC_COMPLEXITY = y
72+ CONFIG_GCC_PLUGINS=y
73+ CONFIG_GCC_PLUGIN_CYC_COMPLEXITY=y
74+ CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
75+ ...
8276
83- To compile only the plugin(s)::
77+ To compile the minimum tool set including the plugin(s)::
8478
85- make gcc-plugins
79+ make scripts
8680
8781or just run the kernel make and compile the whole kernel with
8882the cyclomatic complexity GCC plugin.
@@ -91,7 +85,8 @@ the cyclomatic complexity GCC plugin.
91854. How to add a new GCC plugin
9286==============================
9387
94- The GCC plugins are in $(src)/scripts/gcc-plugins/. You can use a file or a directory
95- here. It must be added to $(src)/scripts/gcc-plugins/Makefile,
96- $(src)/scripts/Makefile.gcc-plugins and $(src)/arch/Kconfig.
88+ The GCC plugins are in scripts/gcc-plugins/. You need to put plugin source files
89+ right under scripts/gcc-plugins/. Creating subdirectories is not supported.
90+ It must be added to scripts/gcc-plugins/Makefile, scripts/Makefile.gcc-plugins
91+ and a relevant Kconfig file.
9792See the cyc_complexity_plugin.c (CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) GCC plugin.
0 commit comments