pkgsrc and CPU specific optimizations
*BSD, Open Source, pkgsrc 1 Comment »For a while now I’ve been using devel/cpuflags to optimize my pkgsrc-built binaries. It determines the best compiler flags based upon the current CPU type, thereby creating a binary optimized for the current CPU. It’s a little “rice“, but for certain packages, like OpenSSL, it can make quite a difference (and yes, I know that for the majority of software on the majority of CPUs it won’t make any noticeable difference). To make package organization easier, I’ve made a few additions to my mk.conf(5) to group my packages by target CPU type.
To call cpuflags for every build, I have the following in /etc/mk.conf (my LOCALBASE is /usr/local):
.sinclude "/usr/local/share/mk/cpuflags.mk"
CPUTYPE:=`/usr/local/bin/cpuflags | sed 's/-mcpu=//'`
The second line sets the value of the CPUTYPE variable to the CPU type we’re optimizing for (for example, “supersparc” for SuperSPARC CPUs).
Packages are then installed into the following location:
PACKAGES?=${WRKOBJDIR}/packages/${OS_VERSION}/${MACHINE_ARCH}/${CPUTYPE}
This installs packages into directories based on the operating system version, machine architecture and target CPU. For example, a target directory could be “packages/3.0_STABLE/sparc/supersparc”. Works nicely when one has a number of different architectures and target CPUs.

Recent Comments