1*4882a593Smuzhiyun// -*- mode:doc; -*- 2*4882a593Smuzhiyun// vim: set syntax=asciidoc: 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun[[full-rebuild]] 5*4882a593Smuzhiyun=== Understanding when a full rebuild is necessary 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunBuildroot does not attempt to detect what parts of the system should 8*4882a593Smuzhiyunbe rebuilt when the system configuration is changed through +make 9*4882a593Smuzhiyunmenuconfig+, +make xconfig+ or one of the other configuration 10*4882a593Smuzhiyuntools. In some cases, Buildroot should rebuild the entire system, in 11*4882a593Smuzhiyunsome cases, only a specific subset of packages. But detecting this in 12*4882a593Smuzhiyuna completely reliable manner is very difficult, and therefore the 13*4882a593SmuzhiyunBuildroot developers have decided to simply not attempt to do this. 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunInstead, it is the responsibility of the user to know when a full 16*4882a593Smuzhiyunrebuild is necessary. As a hint, here are a few rules of thumb that 17*4882a593Smuzhiyuncan help you understand how to work with Buildroot: 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun * When the target architecture configuration is changed, a complete 20*4882a593Smuzhiyun rebuild is needed. Changing the architecture variant, the binary 21*4882a593Smuzhiyun format or the floating point strategy for example has an impact on 22*4882a593Smuzhiyun the entire system. 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun * When the toolchain configuration is changed, a complete rebuild 25*4882a593Smuzhiyun generally is needed. Changing the toolchain configuration often 26*4882a593Smuzhiyun involves changing the compiler version, the type of C library or 27*4882a593Smuzhiyun its configuration, or some other fundamental configuration item, 28*4882a593Smuzhiyun and these changes have an impact on the entire system. 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun * When an additional package is added to the configuration, a full 31*4882a593Smuzhiyun rebuild is not necessarily needed. Buildroot will detect that this 32*4882a593Smuzhiyun package has never been built, and will build it. However, if this 33*4882a593Smuzhiyun package is a library that can optionally be used by packages that 34*4882a593Smuzhiyun have already been built, Buildroot will not automatically rebuild 35*4882a593Smuzhiyun those. Either you know which packages should be rebuilt, and you 36*4882a593Smuzhiyun can rebuild them manually, or you should do a full rebuild. For 37*4882a593Smuzhiyun example, let's suppose you have built a system with the +ctorrent+ 38*4882a593Smuzhiyun package, but without +openssl+. Your system works, but you realize 39*4882a593Smuzhiyun you would like to have SSL support in +ctorrent+, so you enable the 40*4882a593Smuzhiyun +openssl+ package in Buildroot configuration and restart the 41*4882a593Smuzhiyun build. Buildroot will detect that +openssl+ should be built and 42*4882a593Smuzhiyun will be build it, but it will not detect that +ctorrent+ should be 43*4882a593Smuzhiyun rebuilt to benefit from +openssl+ to add OpenSSL support. You will 44*4882a593Smuzhiyun either have to do a full rebuild, or rebuild +ctorrent+ itself. 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun * When a package is removed from the configuration, Buildroot does 47*4882a593Smuzhiyun not do anything special. It does not remove the files installed by 48*4882a593Smuzhiyun this package from the target root filesystem or from the toolchain 49*4882a593Smuzhiyun _sysroot_. A full rebuild is needed to get rid of this 50*4882a593Smuzhiyun package. However, generally you don't necessarily need this package 51*4882a593Smuzhiyun to be removed right now: you can wait for the next lunch break to 52*4882a593Smuzhiyun restart the build from scratch. 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun * When the sub-options of a package are changed, the package is not 55*4882a593Smuzhiyun automatically rebuilt. After making such changes, rebuilding only 56*4882a593Smuzhiyun this package is often sufficient, unless enabling the package 57*4882a593Smuzhiyun sub-option adds some features to the package that are useful for 58*4882a593Smuzhiyun another package which has already been built. Again, Buildroot does 59*4882a593Smuzhiyun not track when a package should be rebuilt: once a package has been 60*4882a593Smuzhiyun built, it is never rebuilt unless explicitly told to do so. 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun * When a change to the root filesystem skeleton is made, a full 63*4882a593Smuzhiyun rebuild is needed. However, when changes to the root filesystem 64*4882a593Smuzhiyun overlay, a post-build script or a post-image script are made, 65*4882a593Smuzhiyun there is no need for a full rebuild: a simple +make+ invocation 66*4882a593Smuzhiyun will take the changes into account. 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun * When a package listed in +FOO_DEPENDENCIES+ is rebuilt or removed, 69*4882a593Smuzhiyun the package +foo+ is not automatically rebuilt. For example, if a 70*4882a593Smuzhiyun package +bar+ is listed in +FOO_DEPENDENCIES+ with +FOO_DEPENDENCIES 71*4882a593Smuzhiyun = bar+ and the configuration of the +bar+ package is changed, the 72*4882a593Smuzhiyun configuration change would not result in a rebuild of package +foo+ 73*4882a593Smuzhiyun automatically. In this scenario, you may need to either rebuild any 74*4882a593Smuzhiyun packages in your build which reference +bar+ in their +DEPENDENCIES+, 75*4882a593Smuzhiyun or perform a full rebuild to ensure any +bar+ dependent packages are 76*4882a593Smuzhiyun up to date. 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunGenerally speaking, when you're facing a build error and you're unsure 79*4882a593Smuzhiyunof the potential consequences of the configuration changes you've 80*4882a593Smuzhiyunmade, do a full rebuild. If you get the same build error, then you are 81*4882a593Smuzhiyunsure that the error is not related to partial rebuilds of packages, 82*4882a593Smuzhiyunand if this error occurs with packages from the official Buildroot, do 83*4882a593Smuzhiyunnot hesitate to report the problem! As your experience with Buildroot 84*4882a593Smuzhiyunprogresses, you will progressively learn when a full rebuild is really 85*4882a593Smuzhiyunnecessary, and you will save more and more time. 86*4882a593Smuzhiyun 87*4882a593SmuzhiyunFor reference, a full rebuild is achieved by running: 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun--------------- 90*4882a593Smuzhiyun$ make clean all 91*4882a593Smuzhiyun--------------- 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun[[rebuild-pkg]] 94*4882a593Smuzhiyun=== Understanding how to rebuild packages 95*4882a593Smuzhiyun 96*4882a593SmuzhiyunOne of the most common questions asked by Buildroot users is how to 97*4882a593Smuzhiyunrebuild a given package or how to remove a package without rebuilding 98*4882a593Smuzhiyuneverything from scratch. 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunRemoving a package is unsupported by Buildroot without 101*4882a593Smuzhiyunrebuilding from scratch. This is because Buildroot doesn't keep track 102*4882a593Smuzhiyunof which package installs what files in the +output/staging+ and 103*4882a593Smuzhiyun+output/target+ directories, or which package would be compiled differently 104*4882a593Smuzhiyundepending on the availability of another package. 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunThe easiest way to rebuild a single package from scratch is to remove 107*4882a593Smuzhiyunits build directory in +output/build+. Buildroot will then re-extract, 108*4882a593Smuzhiyunre-configure, re-compile and re-install this package from scratch. You 109*4882a593Smuzhiyuncan ask buildroot to do this with the +make <package>-dirclean+ command. 110*4882a593Smuzhiyun 111*4882a593SmuzhiyunOn the other hand, if you only want to restart the build process of a 112*4882a593Smuzhiyunpackage from its compilation step, you can run +make <package>-rebuild+. It 113*4882a593Smuzhiyunwill restart the compilation and installation of the package, but not from 114*4882a593Smuzhiyunscratch: it basically re-executes +make+ and +make install+ inside the package, 115*4882a593Smuzhiyunso it will only rebuild files that changed. 116*4882a593Smuzhiyun 117*4882a593SmuzhiyunIf you want to restart the build process of a package from its configuration 118*4882a593Smuzhiyunstep, you can run +make <package>-reconfigure+. It will restart the 119*4882a593Smuzhiyunconfiguration, compilation and installation of the package. 120*4882a593Smuzhiyun 121*4882a593SmuzhiyunWhile +<package>-rebuild+ implies +<package>-reinstall+ and 122*4882a593Smuzhiyun+<package>-reconfigure+ implies +<package>-rebuild+, these targets as well 123*4882a593Smuzhiyunas +<package>+ only act on the said package, and do not trigger re-creating 124*4882a593Smuzhiyunthe root filesystem image. If re-creating the root filesystem in necessary, 125*4882a593Smuzhiyunone should in addition run +make+ or +make all+. 126*4882a593Smuzhiyun 127*4882a593SmuzhiyunInternally, Buildroot creates so-called _stamp files_ to keep track of 128*4882a593Smuzhiyunwhich build steps have been completed for each package. They are 129*4882a593Smuzhiyunstored in the package build directory, 130*4882a593Smuzhiyun+output/build/<package>-<version>/+ and are named 131*4882a593Smuzhiyun+.stamp_<step-name>+. The commands detailed above simply manipulate 132*4882a593Smuzhiyunthese stamp files to force Buildroot to restart a specific set of 133*4882a593Smuzhiyunsteps of a package build process. 134*4882a593Smuzhiyun 135*4882a593SmuzhiyunFurther details about package special make targets are explained in 136*4882a593Smuzhiyunxref:pkg-build-steps[]. 137