~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/kbuild/gcc-plugins.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/kbuild/gcc-plugins.rst (Version linux-6.12-rc7) and /Documentation/kbuild/gcc-plugins.rst (Version linux-5.14.21)


  1 =========================                           1 =========================
  2 GCC plugin infrastructure                           2 GCC plugin infrastructure
  3 =========================                           3 =========================
  4                                                     4 
  5                                                     5 
  6 Introduction                                        6 Introduction
  7 ============                                        7 ============
  8                                                     8 
  9 GCC plugins are loadable modules that provide       9 GCC plugins are loadable modules that provide extra features to the
 10 compiler [1]_. They are useful for runtime ins     10 compiler [1]_. They are useful for runtime instrumentation and static analysis.
 11 We can analyse, change and add further code du     11 We can analyse, change and add further code during compilation via
 12 callbacks [2]_, GIMPLE [3]_, IPA [4]_ and RTL      12 callbacks [2]_, GIMPLE [3]_, IPA [4]_ and RTL passes [5]_.
 13                                                    13 
 14 The GCC plugin infrastructure of the kernel su     14 The GCC plugin infrastructure of the kernel supports building out-of-tree
 15 modules, cross-compilation and building in a s     15 modules, cross-compilation and building in a separate directory.
 16 Plugin source files have to be compilable by a     16 Plugin source files have to be compilable by a C++ compiler.
 17                                                    17 
 18 Currently the GCC plugin infrastructure suppor     18 Currently the GCC plugin infrastructure supports only some architectures.
 19 Grep "select HAVE_GCC_PLUGINS" to find out whi     19 Grep "select HAVE_GCC_PLUGINS" to find out which architectures support
 20 GCC plugins.                                       20 GCC plugins.
 21                                                    21 
 22 This infrastructure was ported from grsecurity     22 This infrastructure was ported from grsecurity [6]_ and PaX [7]_.
 23                                                    23 
 24 --                                                 24 --
 25                                                    25 
 26 .. [1] https://gcc.gnu.org/onlinedocs/gccint/P     26 .. [1] https://gcc.gnu.org/onlinedocs/gccint/Plugins.html
 27 .. [2] https://gcc.gnu.org/onlinedocs/gccint/P     27 .. [2] https://gcc.gnu.org/onlinedocs/gccint/Plugin-API.html#Plugin-API
 28 .. [3] https://gcc.gnu.org/onlinedocs/gccint/G     28 .. [3] https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html
 29 .. [4] https://gcc.gnu.org/onlinedocs/gccint/I     29 .. [4] https://gcc.gnu.org/onlinedocs/gccint/IPA.html
 30 .. [5] https://gcc.gnu.org/onlinedocs/gccint/R     30 .. [5] https://gcc.gnu.org/onlinedocs/gccint/RTL.html
 31 .. [6] https://grsecurity.net/                     31 .. [6] https://grsecurity.net/
 32 .. [7] https://pax.grsecurity.net/                 32 .. [7] https://pax.grsecurity.net/
 33                                                    33 
 34                                                    34 
 35 Purpose                                        << 
 36 =======                                        << 
 37                                                << 
 38 GCC plugins are designed to provide a place to << 
 39 compiler features that are neither in GCC nor  << 
 40 their utility is proven, the goal is to upstre << 
 41 (and Clang), and then to finally remove them f << 
 42 feature is available in all supported versions << 
 43                                                << 
 44 Specifically, new plugins should implement onl << 
 45 upstream compiler support (in either GCC or Cl << 
 46                                                << 
 47 When a feature exists in Clang but not GCC, ef << 
 48 bring the feature to upstream GCC (rather than << 
 49 GCC plugin), so the entire ecosystem can benef << 
 50                                                << 
 51 Similarly, even if a feature provided by a GCC << 
 52 in Clang, but the feature is proven to be usef << 
 53 to upstream the feature to GCC (and Clang).    << 
 54                                                << 
 55 After a feature is available in upstream GCC,  << 
 56 unbuildable for the corresponding GCC version  << 
 57 kernel-supported versions of GCC provide the f << 
 58 be removed from the kernel.                    << 
 59                                                << 
 60                                                << 
 61 Files                                              35 Files
 62 =====                                              36 =====
 63                                                    37 
 64 **$(src)/scripts/gcc-plugins**                     38 **$(src)/scripts/gcc-plugins**
 65                                                    39 
 66         This is the directory of the GCC plugi     40         This is the directory of the GCC plugins.
 67                                                    41 
 68 **$(src)/scripts/gcc-plugins/gcc-common.h**        42 **$(src)/scripts/gcc-plugins/gcc-common.h**
 69                                                    43 
 70         This is a compatibility header for GCC     44         This is a compatibility header for GCC plugins.
 71         It should be always included instead o     45         It should be always included instead of individual gcc headers.
 72                                                    46 
 73 **$(src)/scripts/gcc-plugins/gcc-generate-gimp     47 **$(src)/scripts/gcc-plugins/gcc-generate-gimple-pass.h,
 74 $(src)/scripts/gcc-plugins/gcc-generate-ipa-pa     48 $(src)/scripts/gcc-plugins/gcc-generate-ipa-pass.h,
 75 $(src)/scripts/gcc-plugins/gcc-generate-simple     49 $(src)/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h,
 76 $(src)/scripts/gcc-plugins/gcc-generate-rtl-pa     50 $(src)/scripts/gcc-plugins/gcc-generate-rtl-pass.h**
 77                                                    51 
 78         These headers automatically generate t     52         These headers automatically generate the registration structures for
 79         GIMPLE, SIMPLE_IPA, IPA and RTL passes     53         GIMPLE, SIMPLE_IPA, IPA and RTL passes.
 80         They should be preferred to creating t     54         They should be preferred to creating the structures by hand.
 81                                                    55 
 82                                                    56 
 83 Usage                                              57 Usage
 84 =====                                              58 =====
 85                                                    59 
 86 You must install the gcc plugin headers for yo     60 You must install the gcc plugin headers for your gcc version,
 87 e.g., on Ubuntu for gcc-10::                       61 e.g., on Ubuntu for gcc-10::
 88                                                    62 
 89         apt-get install gcc-10-plugin-dev          63         apt-get install gcc-10-plugin-dev
 90                                                    64 
 91 Or on Fedora::                                     65 Or on Fedora::
 92                                                    66 
 93         dnf install gcc-plugin-devel libmpc-de !!  67         dnf install gcc-plugin-devel
 94                                                << 
 95 Or on Fedora when using cross-compilers that i << 
 96                                                << 
 97         dnf install libmpc-devel               << 
 98                                                    68 
 99 Enable the GCC plugin infrastructure and some      69 Enable the GCC plugin infrastructure and some plugin(s) you want to use
100 in the kernel config::                             70 in the kernel config::
101                                                    71 
102         CONFIG_GCC_PLUGINS=y                       72         CONFIG_GCC_PLUGINS=y
                                                   >>  73         CONFIG_GCC_PLUGIN_CYC_COMPLEXITY=y
103         CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y         74         CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
104         ...                                        75         ...
105                                                    76 
106 Run gcc (native or cross-compiler) to ensure p << 
107                                                << 
108         gcc -print-file-name=plugin            << 
109         CROSS_COMPILE=arm-linux-gnu- ${CROSS_C << 
110                                                << 
111 The word "plugin" means they are not detected: << 
112                                                << 
113         plugin                                 << 
114                                                << 
115 A full path means they are detected::          << 
116                                                << 
117        /usr/lib/gcc/x86_64-redhat-linux/12/plu << 
118                                                << 
119 To compile the minimum tool set including the      77 To compile the minimum tool set including the plugin(s)::
120                                                    78 
121         make scripts                               79         make scripts
122                                                    80 
123 or just run the kernel make and compile the wh     81 or just run the kernel make and compile the whole kernel with
124 the cyclomatic complexity GCC plugin.              82 the cyclomatic complexity GCC plugin.
125                                                    83 
126                                                    84 
127 4. How to add a new GCC plugin                     85 4. How to add a new GCC plugin
128 ==============================                     86 ==============================
129                                                    87 
130 The GCC plugins are in scripts/gcc-plugins/. Y     88 The GCC plugins are in scripts/gcc-plugins/. You need to put plugin source files
131 right under scripts/gcc-plugins/. Creating sub     89 right under scripts/gcc-plugins/. Creating subdirectories is not supported.
132 It must be added to scripts/gcc-plugins/Makefi     90 It must be added to scripts/gcc-plugins/Makefile, scripts/Makefile.gcc-plugins
133 and a relevant Kconfig file.                       91 and a relevant Kconfig file.
                                                   >>  92 See the cyc_complexity_plugin.c (CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) GCC plugin.
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php