1 ========================= 2 GCC plugin infrastructure 3 ========================= 4 5 6 Introduction 7 ============ 8 9 GCC plugins are loadable modules that provide 10 compiler [1]_. They are useful for runtime ins 11 We can analyse, change and add further code du 12 callbacks [2]_, GIMPLE [3]_, IPA [4]_ and RTL 13 14 The GCC plugin infrastructure of the kernel su 15 modules, cross-compilation and building in a s 16 Plugin source files have to be compilable by a 17 18 Currently the GCC plugin infrastructure suppor 19 Grep "select HAVE_GCC_PLUGINS" to find out whi 20 GCC plugins. 21 22 This infrastructure was ported from grsecurity 23 24 -- 25 26 .. [1] https://gcc.gnu.org/onlinedocs/gccint/P 27 .. [2] https://gcc.gnu.org/onlinedocs/gccint/P 28 .. [3] https://gcc.gnu.org/onlinedocs/gccint/G 29 .. [4] https://gcc.gnu.org/onlinedocs/gccint/I 30 .. [5] https://gcc.gnu.org/onlinedocs/gccint/R 31 .. [6] https://grsecurity.net/ 32 .. [7] https://pax.grsecurity.net/ 33 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 62 ===== 63 64 **$(src)/scripts/gcc-plugins** 65 66 This is the directory of the GCC plugi 67 68 **$(src)/scripts/gcc-plugins/gcc-common.h** 69 70 This is a compatibility header for GCC 71 It should be always included instead o 72 73 **$(src)/scripts/gcc-plugins/gcc-generate-gimp 74 $(src)/scripts/gcc-plugins/gcc-generate-ipa-pa 75 $(src)/scripts/gcc-plugins/gcc-generate-simple 76 $(src)/scripts/gcc-plugins/gcc-generate-rtl-pa 77 78 These headers automatically generate t 79 GIMPLE, SIMPLE_IPA, IPA and RTL passes 80 They should be preferred to creating t 81 82 83 Usage 84 ===== 85 86 You must install the gcc plugin headers for yo 87 e.g., on Ubuntu for gcc-10:: 88 89 apt-get install gcc-10-plugin-dev 90 91 Or on Fedora:: 92 93 dnf install gcc-plugin-devel libmpc-de 94 95 Or on Fedora when using cross-compilers that i 96 97 dnf install libmpc-devel 98 99 Enable the GCC plugin infrastructure and some 100 in the kernel config:: 101 102 CONFIG_GCC_PLUGINS=y 103 CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y 104 ... 105 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 120 121 make scripts 122 123 or just run the kernel make and compile the wh 124 the cyclomatic complexity GCC plugin. 125 126 127 4. How to add a new GCC plugin 128 ============================== 129 130 The GCC plugins are in scripts/gcc-plugins/. Y 131 right under scripts/gcc-plugins/. Creating sub 132 It must be added to scripts/gcc-plugins/Makefi 133 and a relevant Kconfig file.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.