Here I list the common ways to speed up building packages. You can use one or more of these methods if you choose to.
An easy way to reduce disk access and prolonging the life of the disk, by using faster ram for compilation time.
Note you need a decent amount of ram that is dynamically used so this figure won't be used when you are not building a package.
Recommended but not required. Add a pkgmk user and fakeroot to prt-get.conf as on FakerootPorts then return to this page.
If you are using a pkgmk user for building find your user ID for pkgmk
$ id pkgmk
Edit /etc/fstab and add this line. Setting your preferred size size=... in M for megabytes or G for gigabytes and user ID of the previous command uid=...
pkgmk /usr/ports/work tmpfs size=1G,uid=XX,defaults 0 0
Mount the tmpfs, (saves rebooting).
# mount -t tmpfs -o size=1G,uid=XX,defaults /usr/ports/work
Edit /etc/pkgmk.conf and set where you put your ram file system from your /etc/fstab file.
Edit /etc/pkgmk.conf and remove -pipe from all your *FLAGS=.
CFLAGS='-O2 -march=i686 -fomit-frame-pointer' CXXFLAGS='-O2 -march=i686 -fomit-frame-pointer'
Another way to speed up compiling is to set the number of parallel jobs to do at the same time, set the number of jobs to the number of processors you have. In this example I have chosen 4 concurrent jobs for a quad core processor. Set this in pkgmk.conf
Alternatively use this to set the number of jobs to how many processors you have running.
export MAKEFLAGS="-j$(/usr/bin/getconf _NPROCESSORS_ONLN)"
This is how you can cache C and C++ objects to speed up compiles, particularly useful if you rebuild the same package over and over, or bumping the version regularly.
ports -u opt prt-get depinst ccache
Add these lines to /etc/profile
export PATH="/usr/lib/ccache/:$PATH" export CCACHE_DIR="/var/cache/ccache" export CCACHE_COMPILERCHECK="%compiler% -dumpversion; crux"
For distcc users see Distcc on how to set the number of jobs to suit your distcc cluster.
Inspired by treach for giving me the idea and cptn for suggesting I write wiki pages.