When I update a Gentoo system, does Portage fetch new sources, extract them and recompile everything from scratch, or does it extract it to existing sources and compile only changed files?

2 Answers 2


While make(1) and many buildsystems, such as autotools, do support incremental compilation, Gentoo with stock Portage does not take advantage of it. After a package is compiled and installed, the working directory is discarded.

The actual difficulty with using incremental compilation would be getting packages to build reliably in this fashion. It is much easier to be assured that a build will be both successful, correct, and reproducible if you always do a clean build. Many buildsystems would break subtly if Gentoo tried to support rebuilding incrementally. And, in many cases, one would have to re-run ./configure (or its equivalent) which would likely create a new config.h or update environment variables such as CFLAGS and CPPFLAGS in the generated Makefiles (or equivalents if other buildsystems are used). Touching config.h would require most sources to be rebuilt. And if PACKAGE_VERSION changes, which might be passed by Makefile via CPPFLAGS if the package doesn’t use config.h, all sources should be rebuilt to see the new values—unless you can somehow figure that certain source files wouldn’t need to be recompiled because they don’t reference a particular C preprocessor macro.

So, in the end, even if Gentoo devs went to all the work to try to support incremental compilation between package version updates, many packages would either need to be fully recompiled or make(1) would end up fully recompiling them anyway (e.g. if config.h’s timestamp changes). So this would be a high cost effort for a very marginal gain—and even likely introduce a lot of subtle bugs, in my best understanding. Thus, I do not expect such a feature to ever be introduced.

My answer mostly refers to autotools/simple Makefile-type packages, but not everything builds this way, so the exact reasons would likely differ depending on the exact package in question.


Portage compiles full sources of the new package as delivered by upstream (sometimes gentoo team patches the source themselves, but that is another story).

The binaries of the old package are usually removed, although some old libraries may stay if deleting them would harm other packages. To remove old sources you need to run eclean -d distfiles yourself.

  • That is so redundant. Isn't just overwriting existing source with new one and then running, for ex. make, which does a diff check and compiles what changed. Seems silly for me that i need to spend 2 hours every time Chromium gets an update. Jun 18, 2016 at 22:01
  • 1
    @Gala If you don't want to spend your time recompiling programs, don't use Gentoo! That's the whole point of Gentoo. Jun 19, 2016 at 0:12
  • @Gala I agree that would be better, but it is not so easy to implement. First of all, how do you know if the source has been modified? You would need to prepare control sum for all source files - that's a lot of work and time. Comparing those sums before compilation takes time too, not to mention waste of space on hard disk.
    – jimmij
    Jun 19, 2016 at 0:41
  • I recall "make" doing it. I was modifying something in coreutils, and after modifying and typing in make it would just compile what I modified. Jun 19, 2016 at 10:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .