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

TOMOYO Linux Cross Reference
Linux/Documentation/kbuild/llvm.rst

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/kbuild/llvm.rst (Version linux-6.11.5) and /Documentation/kbuild/llvm.rst (Version linux-4.20.17)


  1 .. _kbuild_llvm:                                  
  2                                                   
  3 ==============================                    
  4 Building Linux with Clang/LLVM                    
  5 ==============================                    
  6                                                   
  7 This document covers how to build the Linux ke    
  8 utilities.                                        
  9                                                   
 10 About                                             
 11 -----                                             
 12                                                   
 13 The Linux kernel has always traditionally been    
 14 such as GCC and binutils. Ongoing work has all    
 15 <https://clang.llvm.org/>`_ and `LLVM <https:/    
 16 used as viable substitutes. Distributions such    
 17 <https://www.android.com/>`_, `ChromeOS           
 18 <https://www.chromium.org/chromium-os>`_, `Ope    
 19 <https://www.openmandriva.org/>`_, and `Chimer    
 20 <https://chimera-linux.org/>`_ use Clang built    
 21 datacenter fleets also run kernels built with     
 22                                                   
 23 `LLVM is a collection of toolchain components     
 24 objects <https://www.aosabook.org/en/llvm.html    
 25 that supports C and the GNU C extensions requi    
 26 pronounced "klang," not "see-lang."               
 27                                                   
 28 Building with LLVM                                
 29 ------------------                                
 30                                                   
 31 Invoke ``make`` via::                             
 32                                                   
 33         make LLVM=1                               
 34                                                   
 35 to compile for the host target. For cross comp    
 36                                                   
 37         make LLVM=1 ARCH=arm64                    
 38                                                   
 39 The LLVM= argument                                
 40 ------------------                                
 41                                                   
 42 LLVM has substitutes for GNU binutils utilitie    
 43 individually. The full list of supported make     
 44                                                   
 45         make CC=clang LD=ld.lld AR=llvm-ar NM=    
 46           OBJCOPY=llvm-objcopy OBJDUMP=llvm-ob    
 47           HOSTCC=clang HOSTCXX=clang++ HOSTAR=    
 48                                                   
 49 ``LLVM=1`` expands to the above.                  
 50                                                   
 51 If your LLVM tools are not available in your P    
 52 location using the LLVM variable with a traili    
 53                                                   
 54         make LLVM=/path/to/llvm/                  
 55                                                   
 56 which will use ``/path/to/llvm/clang``, ``/pat    
 57 following may also be used::                      
 58                                                   
 59         PATH=/path/to/llvm:$PATH make LLVM=1      
 60                                                   
 61 If your LLVM tools have a version suffix and y    
 62 explicit version rather than the unsuffixed ex    
 63 can pass the suffix using the ``LLVM`` variabl    
 64                                                   
 65         make LLVM=-14                             
 66                                                   
 67 which will use ``clang-14``, ``ld.lld-14``, et    
 68                                                   
 69 To support combinations of out of tree paths w    
 70 recommend::                                       
 71                                                   
 72         PATH=/path/to/llvm/:$PATH make LLVM=-1    
 73                                                   
 74 ``LLVM=0`` is not the same as omitting ``LLVM`    
 75 ``LLVM=1``. If you only wish to use certain LL    
 76 respective make variables.                        
 77                                                   
 78 The same value used for ``LLVM=`` should be se    
 79 if configuring and building via distinct comma    
 80 as an environment variable when running script    
 81 ``make``.                                         
 82                                                   
 83 Cross Compiling                                   
 84 ---------------                                   
 85                                                   
 86 A single Clang compiler binary (and correspond    
 87 typically contain all supported back ends, whi    
 88 compiling especially when ``LLVM=1`` is used.     
 89 ``CROSS_COMPILE`` or target-triple-prefixes be    
 90                                                   
 91         make LLVM=1 ARCH=arm64                    
 92                                                   
 93 As an example of mixing LLVM and GNU utilities    
 94 which does not yet have ``ld.lld`` or ``llvm-o    
 95 invoke ``make`` via::                             
 96                                                   
 97         make LLVM=1 ARCH=s390 LD=s390x-linux-g    
 98           OBJCOPY=s390x-linux-gnu-objcopy         
 99                                                   
100 This example will invoke ``s390x-linux-gnu-ld.    
101 ``s390x-linux-gnu-objcopy``, so ensure those a    
102                                                   
103 ``CROSS_COMPILE`` is not used to prefix the Cl    
104 corresponding LLVM utilities) as is the case f    
105 is not set.                                       
106                                                   
107 The LLVM_IAS= argument                            
108 ----------------------                            
109                                                   
110 Clang can assemble assembler code. You can pas    
111 behavior and have Clang invoke the correspondi    
112 instead. Example::                                
113                                                   
114         make LLVM=1 LLVM_IAS=0                    
115                                                   
116 ``CROSS_COMPILE`` is necessary when cross comp    
117 is used in order to set ``--prefix=`` for the     
118 corresponding non-integrated assembler (typica    
119 system assembler when targeting another archit    
120                                                   
121         make LLVM=1 ARCH=arm LLVM_IAS=0 CROSS_    
122                                                   
123                                                   
124 Ccache                                            
125 ------                                            
126                                                   
127 ``ccache`` can be used with ``clang`` to impro    
128 KBUILD_BUILD_TIMESTAMP_ should be set to a det    
129 in order to avoid 100% cache misses, see Repro    
130                                                   
131         KBUILD_BUILD_TIMESTAMP='' make LLVM=1     
132                                                   
133 .. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild    
134 .. _Reproducible_builds: reproducible-builds.h    
135                                                   
136 Supported Architectures                           
137 -----------------------                           
138                                                   
139 LLVM does not target all of the architectures     
140 just because a target is supported in LLVM doe    
141 will build or work without any issues. Below i    
142 architectures that currently work with ``CC=cl    
143 of support corresponds to "S" values in the MA    
144 architecture is not present, it either means t    
145 it or there are known issues. Using the latest    
146 even the development tree will generally yield    
147 An architecture's ``defconfig`` is generally e    
148 certain configurations may have problems that     
149 yet. Bug reports are always welcome at the iss    
150                                                   
151 .. list-table::                                   
152    :widths: 10 10 10                              
153    :header-rows: 1                                
154                                                   
155    * - Architecture                               
156      - Level of support                           
157      - ``make`` command                           
158    * - arm                                        
159      - Supported                                  
160      - ``LLVM=1``                                 
161    * - arm64                                      
162      - Supported                                  
163      - ``LLVM=1``                                 
164    * - hexagon                                    
165      - Maintained                                 
166      - ``LLVM=1``                                 
167    * - loongarch                                  
168      - Maintained                                 
169      - ``LLVM=1``                                 
170    * - mips                                       
171      - Maintained                                 
172      - ``LLVM=1``                                 
173    * - powerpc                                    
174      - Maintained                                 
175      - ``LLVM=1``                                 
176    * - riscv                                      
177      - Supported                                  
178      - ``LLVM=1``                                 
179    * - s390                                       
180      - Maintained                                 
181      - ``LLVM=1`` (LLVM >= 18.1.0), ``CC=clang    
182    * - um (User Mode)                             
183      - Maintained                                 
184      - ``LLVM=1``                                 
185    * - x86                                        
186      - Supported                                  
187      - ``LLVM=1``                                 
188                                                   
189 Getting Help                                      
190 ------------                                      
191                                                   
192 - `Website <https://clangbuiltlinux.github.io/    
193 - `Mailing List <https://lore.kernel.org/llvm/>    
194 - `Old Mailing List Archives <https://groups.g    
195 - `Issue Tracker <https://github.com/ClangBuil    
196 - IRC: #clangbuiltlinux on irc.libera.chat        
197 - `Telegram <https://t.me/ClangBuiltLinux>`_:     
198 - `Wiki <https://github.com/ClangBuiltLinux/li    
199 - `Beginner Bugs <https://github.com/ClangBuil    
200                                                   
201 .. _getting_llvm:                                 
202                                                   
203 Getting LLVM                                      
204 -------------                                     
205                                                   
206 We provide prebuilt stable versions of LLVM on    
207 <https://kernel.org/pub/tools/llvm/>`_. These     
208 data for building Linux kernels, which should     
209 relative to other distributions of LLVM.          
210                                                   
211 Below are links that may be useful for buildin    
212 it through a distribution's package manager.      
213                                                   
214 - https://releases.llvm.org/download.html         
215 - https://github.com/llvm/llvm-project            
216 - https://llvm.org/docs/GettingStarted.html       
217 - https://llvm.org/docs/CMake.html                
218 - https://apt.llvm.org/                           
219 - https://www.archlinux.org/packages/extra/x86    
220 - https://github.com/ClangBuiltLinux/tc-build     
221 - https://github.com/ClangBuiltLinux/linux/wik    
222 - https://android.googlesource.com/platform/pr    
                                                      

~ [ 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