xref: /OK3568_Linux_fs/buildroot/docs/manual/common-usage.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun// -*- mode:doc; -*-
2*4882a593Smuzhiyun// vim: set syntax=asciidoc:
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun== General Buildroot usage
5*4882a593Smuzhiyun
6*4882a593Smuzhiyuninclude::make-tips.txt[]
7*4882a593Smuzhiyun
8*4882a593Smuzhiyuninclude::rebuilding-packages.txt[]
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun=== Offline builds
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunIf you intend to do an offline build and just want to download
13*4882a593Smuzhiyunall sources that you previously selected in the configurator
14*4882a593Smuzhiyun('menuconfig', 'nconfig', 'xconfig' or 'gconfig'), then issue:
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun--------------------
17*4882a593Smuzhiyun $ make source
18*4882a593Smuzhiyun--------------------
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunYou can now disconnect or copy the content of your +dl+
21*4882a593Smuzhiyundirectory to the build-host.
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun=== Building out-of-tree
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunAs default, everything built by Buildroot is stored in the directory
26*4882a593Smuzhiyun+output+ in the Buildroot tree.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunBuildroot also supports building out of tree with a syntax similar to
29*4882a593Smuzhiyunthe Linux kernel. To use it, add +O=<directory>+ to the make command
30*4882a593Smuzhiyunline:
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun--------------------
33*4882a593Smuzhiyun $ make O=/tmp/build
34*4882a593Smuzhiyun--------------------
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunOr:
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun--------------------
39*4882a593Smuzhiyun $ cd /tmp/build; make O=$PWD -C path/to/buildroot
40*4882a593Smuzhiyun--------------------
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunAll the output files will be located under +/tmp/build+. If the +O+
43*4882a593Smuzhiyunpath does not exist, Buildroot will create it.
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun*Note:* the +O+ path can be either an absolute or a relative path, but if it's
46*4882a593Smuzhiyunpassed as a relative path, it is important to note that it is interpreted
47*4882a593Smuzhiyunrelative to the main Buildroot source directory, *not* the current working
48*4882a593Smuzhiyundirectory.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunWhen using out-of-tree builds, the Buildroot +.config+ and temporary
51*4882a593Smuzhiyunfiles are also stored in the output directory. This means that you can
52*4882a593Smuzhiyunsafely run multiple builds in parallel using the same source tree as
53*4882a593Smuzhiyunlong as they use unique output directories.
54*4882a593Smuzhiyun
55*4882a593SmuzhiyunFor ease of use, Buildroot generates a Makefile wrapper in the output
56*4882a593Smuzhiyundirectory - so after the first run, you no longer need to pass +O=<...>+
57*4882a593Smuzhiyunand +-C <...>+, simply run (in the output directory):
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun--------------------
60*4882a593Smuzhiyun $ make <target>
61*4882a593Smuzhiyun--------------------
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun[[env-vars]]
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun=== Environment variables
66*4882a593Smuzhiyun
67*4882a593SmuzhiyunBuildroot also honors some environment variables, when they are passed
68*4882a593Smuzhiyunto +make+ or set in the environment:
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun* +HOSTCXX+, the host C++ compiler to use
71*4882a593Smuzhiyun* +HOSTCC+, the host C compiler to use
72*4882a593Smuzhiyun* +UCLIBC_CONFIG_FILE=<path/to/.config>+, path to
73*4882a593Smuzhiyun  the uClibc configuration file, used to compile uClibc, if an
74*4882a593Smuzhiyun  internal toolchain is being built.
75*4882a593Smuzhiyun  +
76*4882a593Smuzhiyun  Note that the uClibc configuration file can also be set from the
77*4882a593Smuzhiyun  configuration interface, so through the Buildroot +.config+ file; this
78*4882a593Smuzhiyun  is the recommended way of setting it.
79*4882a593Smuzhiyun  +
80*4882a593Smuzhiyun* +BUSYBOX_CONFIG_FILE=<path/to/.config>+, path to
81*4882a593Smuzhiyun  the BusyBox configuration file.
82*4882a593Smuzhiyun  +
83*4882a593Smuzhiyun  Note that the BusyBox configuration file can also be set from the
84*4882a593Smuzhiyun  configuration interface, so through the Buildroot +.config+ file; this
85*4882a593Smuzhiyun  is the recommended way of setting it.
86*4882a593Smuzhiyun  +
87*4882a593Smuzhiyun* +BR2_CCACHE_DIR+ to override the directory where
88*4882a593Smuzhiyun  Buildroot stores the cached files when using ccache.
89*4882a593Smuzhiyun  +
90*4882a593Smuzhiyun* +BR2_DL_DIR+ to override the directory in which
91*4882a593Smuzhiyun  Buildroot stores/retrieves downloaded files.
92*4882a593Smuzhiyun  +
93*4882a593Smuzhiyun  Note that the Buildroot download directory can also be set from the
94*4882a593Smuzhiyun  configuration interface, so through the Buildroot +.config+ file. See
95*4882a593Smuzhiyun  xref:download-location[] for more details on how you can set the download
96*4882a593Smuzhiyun  directory.
97*4882a593Smuzhiyun* +BR2_GRAPH_ALT+, if set and non-empty, to use an alternate color-scheme in
98*4882a593Smuzhiyun  build-time graphs
99*4882a593Smuzhiyun* +BR2_GRAPH_OUT+ to set the filetype of generated graphs, either +pdf+ (the
100*4882a593Smuzhiyun  default), or +png+.
101*4882a593Smuzhiyun* +BR2_GRAPH_DEPS_OPTS+ to pass extra options to the dependency graph; see
102*4882a593Smuzhiyun  xref:graph-depends[] for the accepted options
103*4882a593Smuzhiyun* +BR2_GRAPH_DOT_OPTS+ is passed verbatim as options to the +dot+ utility to
104*4882a593Smuzhiyun  draw the dependency graph.
105*4882a593Smuzhiyun* +BR2_GRAPH_SIZE_OPTS+ to pass extra options to the size graph; see
106*4882a593Smuzhiyun  xref:graph-size[] for the acepted options
107*4882a593Smuzhiyun
108*4882a593SmuzhiyunAn example that uses config files located in the toplevel directory and
109*4882a593Smuzhiyunin your $HOME:
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun--------------------
112*4882a593Smuzhiyun $ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
113*4882a593Smuzhiyun--------------------
114*4882a593Smuzhiyun
115*4882a593SmuzhiyunIf you want to use a compiler other than the default +gcc+
116*4882a593Smuzhiyunor +g+++ for building helper-binaries on your host, then do
117*4882a593Smuzhiyun
118*4882a593Smuzhiyun--------------------
119*4882a593Smuzhiyun $ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
120*4882a593Smuzhiyun--------------------
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun=== Dealing efficiently with filesystem images
123*4882a593Smuzhiyun
124*4882a593SmuzhiyunFilesystem images can get pretty big, depending on the filesystem you choose,
125*4882a593Smuzhiyunthe number of packages, whether you provisioned free space... Yet, some
126*4882a593Smuzhiyunlocations in the filesystems images may just be _empty_ (e.g. a long run of
127*4882a593Smuzhiyun'zeroes'); such a file is called a _sparse_ file.
128*4882a593Smuzhiyun
129*4882a593SmuzhiyunMost tools can handle sparse files efficiently, and will only store or write
130*4882a593Smuzhiyunthose parts of a sparse file that are not empty.
131*4882a593Smuzhiyun
132*4882a593SmuzhiyunFor example:
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun* +tar+ accepts the +-S+ option to tell it to only store non-zero blocks
135*4882a593Smuzhiyun  of sparse files:
136*4882a593Smuzhiyun** +tar cf archive.tar -S [files...]+ will efficiently store sparse files
137*4882a593Smuzhiyun   in a tarball
138*4882a593Smuzhiyun** +tar xf archive.tar -S+ will efficiently store sparse files extracted
139*4882a593Smuzhiyun   from a tarball
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun* +cp+ accepts the +--sparse=WHEN+ option (+WHEN+ is one of +auto+,
142*4882a593Smuzhiyun  +never+ or +always+):
143*4882a593Smuzhiyun** +cp --sparse=always source.file dest.file+ will make +dest.file+ a
144*4882a593Smuzhiyun   sparse file if +source.file+ has long runs of zeroes
145*4882a593Smuzhiyun
146*4882a593SmuzhiyunOther tools may have similar options. Please consult their respective man
147*4882a593Smuzhiyunpages.
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunYou can use sparse files if you need to store the filesystem images (e.g.
150*4882a593Smuzhiyunto transfer from one machine to another), or if you need to send them (e.g.
151*4882a593Smuzhiyunto the Q&A team).
152*4882a593Smuzhiyun
153*4882a593SmuzhiyunNote however that flashing a filesystem image to a device while using the
154*4882a593Smuzhiyunsparse mode of +dd+ may result in a broken filesystem (e.g. the block bitmap
155*4882a593Smuzhiyunof an ext2 filesystem may be corrupted; or, if you have sparse files in
156*4882a593Smuzhiyunyour filesystem, those parts may not be all-zeroes when read back). You
157*4882a593Smuzhiyunshould only use sparse files when handling files on the build machine, not
158*4882a593Smuzhiyunwhen transferring them to an actual device that will be used on the target.
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun=== Details about packages
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun[[package-details]]
163*4882a593Smuzhiyun
164*4882a593SmuzhiyunBuildroot can produce a JSON blurb that describes the set of enabled
165*4882a593Smuzhiyunpackages in the current configuration, together with their
166*4882a593Smuzhiyundependencies, licenses and other metadata. This JSON blurb is produced
167*4882a593Smuzhiyunby using the +show-info+ make target:
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun------------------------
170*4882a593Smuzhiyunmake show-info
171*4882a593Smuzhiyun------------------------
172*4882a593Smuzhiyun
173*4882a593SmuzhiyunBuildroot can also produce details about packages as HTML and JSON
174*4882a593Smuzhiyunoutput using the +pkg-stats+ make target. Amongst other things, these
175*4882a593Smuzhiyundetails include whether known CVEs (security vulnerabilities) affect
176*4882a593Smuzhiyunthe packages in your current configuration. It also shows if there is
177*4882a593Smuzhiyuna newer upstream version for those packages.
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun------------------------
180*4882a593Smuzhiyunmake pkg-stats
181*4882a593Smuzhiyun------------------------
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun=== Graphing the dependencies between packages
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun[[graph-depends]]
186*4882a593Smuzhiyun
187*4882a593SmuzhiyunOne of Buildroot's jobs is to know the dependencies between packages,
188*4882a593Smuzhiyunand make sure they are built in the right order. These dependencies
189*4882a593Smuzhiyuncan sometimes be quite complicated, and for a given system, it is
190*4882a593Smuzhiyunoften not easy to understand why such or such package was brought into
191*4882a593Smuzhiyunthe build by Buildroot.
192*4882a593Smuzhiyun
193*4882a593SmuzhiyunIn order to help understanding the dependencies, and therefore better
194*4882a593Smuzhiyununderstand what is the role of the different components in your
195*4882a593Smuzhiyunembedded Linux system, Buildroot is capable of generating dependency
196*4882a593Smuzhiyungraphs.
197*4882a593Smuzhiyun
198*4882a593SmuzhiyunTo generate a dependency graph of the full system you have compiled,
199*4882a593Smuzhiyunsimply run:
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun------------------------
202*4882a593Smuzhiyunmake graph-depends
203*4882a593Smuzhiyun------------------------
204*4882a593Smuzhiyun
205*4882a593SmuzhiyunYou will find the generated graph in
206*4882a593Smuzhiyun+output/graphs/graph-depends.pdf+.
207*4882a593Smuzhiyun
208*4882a593SmuzhiyunIf your system is quite large, the dependency graph may be too complex
209*4882a593Smuzhiyunand difficult to read. It is therefore possible to generate the
210*4882a593Smuzhiyundependency graph just for a given package:
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun------------------------
213*4882a593Smuzhiyunmake <pkg>-graph-depends
214*4882a593Smuzhiyun------------------------
215*4882a593Smuzhiyun
216*4882a593SmuzhiyunYou will find the generated graph in
217*4882a593Smuzhiyun+output/graph/<pkg>-graph-depends.pdf+.
218*4882a593Smuzhiyun
219*4882a593SmuzhiyunNote that the dependency graphs are generated using the +dot+ tool
220*4882a593Smuzhiyunfrom the _Graphviz_ project, which you must have installed on your
221*4882a593Smuzhiyunsystem to use this feature. In most distributions, it is available as
222*4882a593Smuzhiyunthe +graphviz+ package.
223*4882a593Smuzhiyun
224*4882a593SmuzhiyunBy default, the dependency graphs are generated in the PDF
225*4882a593Smuzhiyunformat. However, by passing the +BR2_GRAPH_OUT+ environment variable, you
226*4882a593Smuzhiyuncan switch to other output formats, such as PNG, PostScript or
227*4882a593SmuzhiyunSVG. All formats supported by the +-T+ option of the +dot+ tool are
228*4882a593Smuzhiyunsupported.
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun--------------------------------
231*4882a593SmuzhiyunBR2_GRAPH_OUT=svg make graph-depends
232*4882a593Smuzhiyun--------------------------------
233*4882a593Smuzhiyun
234*4882a593SmuzhiyunThe +graph-depends+ behaviour can be controlled by setting options in the
235*4882a593Smuzhiyun+BR2_GRAPH_DEPS_OPTS+ environment variable. The accepted options are:
236*4882a593Smuzhiyun
237*4882a593Smuzhiyun* +--depth N+, +-d N+, to limit the dependency depth to +N+ levels. The
238*4882a593Smuzhiyun  default, +0+, means no limit.
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun* +--stop-on PKG+, +-s PKG+, to stop the graph on the package +PKG+.
241*4882a593Smuzhiyun  +PKG+ can be an actual package name, a glob, the keyword 'virtual'
242*4882a593Smuzhiyun  (to stop on virtual packages), or the keyword 'host' (to stop on
243*4882a593Smuzhiyun  host packages). The package is still present on the graph, but its
244*4882a593Smuzhiyun  dependencies are not.
245*4882a593Smuzhiyun
246*4882a593Smuzhiyun* +--exclude PKG+, +-x PKG+, like +--stop-on+, but also omits +PKG+ from
247*4882a593Smuzhiyun  the graph.
248*4882a593Smuzhiyun
249*4882a593Smuzhiyun* +--transitive+, +--no-transitive+, to draw (or not) the transitive
250*4882a593Smuzhiyun  dependencies. The default is to not draw transitive dependencies.
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun* +--colors R,T,H+, the comma-separated list of colors to draw the
253*4882a593Smuzhiyun  root package (+R+), the target packages (+T+) and the host packages
254*4882a593Smuzhiyun  (+H+). Defaults to: +lightblue,grey,gainsboro+
255*4882a593Smuzhiyun
256*4882a593Smuzhiyun--------------------------------
257*4882a593SmuzhiyunBR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colors=red,green,blue' make graph-depends
258*4882a593Smuzhiyun--------------------------------
259*4882a593Smuzhiyun
260*4882a593Smuzhiyun=== Graphing the build duration
261*4882a593Smuzhiyun
262*4882a593Smuzhiyun[[graph-duration]]
263*4882a593Smuzhiyun
264*4882a593SmuzhiyunWhen the build of a system takes a long time, it is sometimes useful
265*4882a593Smuzhiyunto be able to understand which packages are the longest to build, to
266*4882a593Smuzhiyunsee if anything can be done to speed up the build. In order to help
267*4882a593Smuzhiyunsuch build time analysis, Buildroot collects the build time of each
268*4882a593Smuzhiyunstep of each package, and allows to generate graphs from this data.
269*4882a593Smuzhiyun
270*4882a593SmuzhiyunTo generate the build time graph after a build, run:
271*4882a593Smuzhiyun
272*4882a593Smuzhiyun----------------
273*4882a593Smuzhiyunmake graph-build
274*4882a593Smuzhiyun----------------
275*4882a593Smuzhiyun
276*4882a593SmuzhiyunThis will generate a set of files in +output/graphs+ :
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun* +build.hist-build.pdf+, a histogram of the build time for each
279*4882a593Smuzhiyun  package, ordered in the build order.
280*4882a593Smuzhiyun
281*4882a593Smuzhiyun* +build.hist-duration.pdf+, a histogram of the build time for each
282*4882a593Smuzhiyun  package, ordered by duration (longest first)
283*4882a593Smuzhiyun
284*4882a593Smuzhiyun* +build.hist-name.pdf+, a histogram of the build time for each
285*4882a593Smuzhiyun  package, order by package name.
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun* +build.pie-packages.pdf+, a pie chart of the build time per package
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun* +build.pie-steps.pdf+, a pie chart of the global time spent in each
290*4882a593Smuzhiyun  step of the packages build process.
291*4882a593Smuzhiyun
292*4882a593SmuzhiyunThis +graph-build+ target requires the Python Matplotlib and Numpy
293*4882a593Smuzhiyunlibraries to be installed (+python-matplotlib+ and +python-numpy+ on
294*4882a593Smuzhiyunmost distributions), and also the +argparse+ module if you're using a
295*4882a593SmuzhiyunPython version older than 2.7 (+python-argparse+ on most
296*4882a593Smuzhiyundistributions).
297*4882a593Smuzhiyun
298*4882a593SmuzhiyunBy default, the output format for the graph is PDF, but a different
299*4882a593Smuzhiyunformat can be selected using the +BR2_GRAPH_OUT+ environment variable. The
300*4882a593Smuzhiyunonly other format supported is PNG:
301*4882a593Smuzhiyun
302*4882a593Smuzhiyun----------------
303*4882a593SmuzhiyunBR2_GRAPH_OUT=png make graph-build
304*4882a593Smuzhiyun----------------
305*4882a593Smuzhiyun
306*4882a593Smuzhiyun[[graph-size]]
307*4882a593Smuzhiyun=== Graphing the filesystem size contribution of packages
308*4882a593Smuzhiyun
309*4882a593SmuzhiyunWhen your target system grows, it is sometimes useful to understand
310*4882a593Smuzhiyunhow much each Buildroot package is contributing to the overall root
311*4882a593Smuzhiyunfilesystem size. To help with such an analysis, Buildroot collects
312*4882a593Smuzhiyundata about files installed by each package and using this data,
313*4882a593Smuzhiyungenerates a graph and CSV files detailing the size contribution of
314*4882a593Smuzhiyunthe different packages.
315*4882a593Smuzhiyun
316*4882a593SmuzhiyunTo generate these data after a build, run:
317*4882a593Smuzhiyun
318*4882a593Smuzhiyun----------------
319*4882a593Smuzhiyunmake graph-size
320*4882a593Smuzhiyun----------------
321*4882a593Smuzhiyun
322*4882a593SmuzhiyunThis will generate:
323*4882a593Smuzhiyun
324*4882a593Smuzhiyun* +output/graphs/graph-size.pdf+, a pie chart of the contribution of
325*4882a593Smuzhiyun  each package to the overall root filesystem size
326*4882a593Smuzhiyun
327*4882a593Smuzhiyun* +output/graphs/package-size-stats.csv+, a CSV file giving the size
328*4882a593Smuzhiyun  contribution of each package to the overall root filesystem size
329*4882a593Smuzhiyun
330*4882a593Smuzhiyun* +output/graphs/file-size-stats.csv+, a CSV file giving the size
331*4882a593Smuzhiyun  contribution of each installed file to the package it belongs, and
332*4882a593Smuzhiyun  to the overall filesystem size.
333*4882a593Smuzhiyun
334*4882a593SmuzhiyunThis +graph-size+ target requires the Python Matplotlib library to be
335*4882a593Smuzhiyuninstalled (+python-matplotlib+ on most distributions), and also the
336*4882a593Smuzhiyun+argparse+ module if you're using a Python version older than 2.7
337*4882a593Smuzhiyun(+python-argparse+ on most distributions).
338*4882a593Smuzhiyun
339*4882a593SmuzhiyunJust like for the duration graph, a +BR2_GRAPH_OUT+ environment variable
340*4882a593Smuzhiyunis supported to adjust the output file format. See xref:graph-depends[]
341*4882a593Smuzhiyunfor details about this environment variable.
342*4882a593Smuzhiyun
343*4882a593SmuzhiyunAdditionally, one may set the environment variable +BR2_GRAPH_SIZE_OPTS+
344*4882a593Smuzhiyunto further control the generated graph. Accepted options are:
345*4882a593Smuzhiyun
346*4882a593Smuzhiyun* `--size-limit X`, `-l X`, will group all packages which individual
347*4882a593Smuzhiyun  contribution is below `X` percent, to a single entry labelled _Others_
348*4882a593Smuzhiyun  in the graph. By default, `X=0.01`, which means packages each
349*4882a593Smuzhiyun  contributing less than 1% are grouped under _Others_. Accepted values
350*4882a593Smuzhiyun  are in the range `[0.0..1.0]`.
351*4882a593Smuzhiyun
352*4882a593Smuzhiyun* `--iec`, `--binary`, `--si`, `--decimal`, to use IEC (binary, powers
353*4882a593Smuzhiyun  of 1024) or SI (decimal, powers of 1000; the default) prefixes.
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun* `--biggest-first`, to sort packages in decreasing size order, rather
356*4882a593Smuzhiyun  than in increasing size order.
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun.Note
359*4882a593SmuzhiyunThe collected filesystem size data is only meaningful after a complete
360*4882a593Smuzhiyunclean rebuild. Be sure to run +make clean all+ before using +make
361*4882a593Smuzhiyungraph-size+.
362*4882a593Smuzhiyun
363*4882a593SmuzhiyunTo compare the root filesystem size of two different Buildroot compilations,
364*4882a593Smuzhiyunfor example after adjusting the configuration or when switching to another
365*4882a593SmuzhiyunBuildroot release, use the +size-stats-compare+ script. It takes two
366*4882a593Smuzhiyun+file-size-stats.csv+ files (produced by +make graph-size+) as input.
367*4882a593SmuzhiyunRefer to the help text of this script for more details:
368*4882a593Smuzhiyun
369*4882a593Smuzhiyun----------------
370*4882a593Smuzhiyunutils/size-stats-compare -h
371*4882a593Smuzhiyun----------------
372*4882a593Smuzhiyun
373*4882a593Smuzhiyun[[top-level-parallel-build]]
374*4882a593Smuzhiyun=== Top-level parallel build
375*4882a593Smuzhiyun
376*4882a593Smuzhiyun.Note
377*4882a593SmuzhiyunThis section deals with a very experimental feature, which is known to
378*4882a593Smuzhiyunbreak even in some non-unusual situations. Use at your own risk.
379*4882a593Smuzhiyun
380*4882a593SmuzhiyunBuildroot has always been capable of using parallel build on a per
381*4882a593Smuzhiyunpackage basis: each package is built by Buildroot using +make -jN+ (or
382*4882a593Smuzhiyunthe equivalent invocation for non-make-based build systems). The level
383*4882a593Smuzhiyunof parallelism is by default number of CPUs + 1, but it can be
384*4882a593Smuzhiyunadjusted using the +BR2_JLEVEL+ configuration option.
385*4882a593Smuzhiyun
386*4882a593SmuzhiyunUntil 2020.02, Buildroot was however building packages in a serial
387*4882a593Smuzhiyunfashion: each package was built one after the other, without
388*4882a593Smuzhiyunparallelization of the build between packages. As of 2020.02,
389*4882a593SmuzhiyunBuildroot has experimental support for *top-level parallel build*,
390*4882a593Smuzhiyunwhich allows some signicant build time savings by building packages
391*4882a593Smuzhiyunthat have no dependency relationship in parallel. This feature is
392*4882a593Smuzhiyunhowever marked as experimental and is known not to work in some cases.
393*4882a593Smuzhiyun
394*4882a593SmuzhiyunIn order to use top-level parallel build, one must:
395*4882a593Smuzhiyun
396*4882a593Smuzhiyun. Enable the option +BR2_PER_PACKAGE_DIRECTORIES+ in the Buildroot
397*4882a593Smuzhiyunconfiguration
398*4882a593Smuzhiyun
399*4882a593Smuzhiyun. Use +make -jN+ when starting the Buildroot build
400*4882a593Smuzhiyun
401*4882a593SmuzhiyunInternally, the +BR2_PER_PACKAGE_DIRECTORIES+ will enable a mechanism
402*4882a593Smuzhiyuncalled *per-package directories*, which will have the following
403*4882a593Smuzhiyuneffects:
404*4882a593Smuzhiyun
405*4882a593Smuzhiyun* Instead of a global _target_ directory and a global _host_ directory
406*4882a593Smuzhiyun  common to all packages, per-package _target_ and _host_ directories
407*4882a593Smuzhiyun  will be used, in +$(O)/per-package/<pkg>/target/+ and
408*4882a593Smuzhiyun  +$(O)/per-package/<pkg>/host/+ respectively. Those folders will be
409*4882a593Smuzhiyun  populated from the corresponding folders of the package dependencies
410*4882a593Smuzhiyun  at the beginning of +<pkg>+ build. The compiler and all other tools
411*4882a593Smuzhiyun  will therefore only be able to see and access files installed by
412*4882a593Smuzhiyun  dependencies explicitly listed by +<pkg>+.
413*4882a593Smuzhiyun
414*4882a593Smuzhiyun* At the end of the build, the global _target_ and _host_ directories
415*4882a593Smuzhiyun  will be populated, located in +$(O)/target+ and +$(O)/host+
416*4882a593Smuzhiyun  respectively. This means that during the build, those folders will
417*4882a593Smuzhiyun  be empty and it's only at the very end of the build that they will
418*4882a593Smuzhiyun  be populated.
419*4882a593Smuzhiyun
420*4882a593Smuzhiyuninclude::eclipse-integration.txt[]
421*4882a593Smuzhiyun
422*4882a593Smuzhiyuninclude::advanced.txt[]
423