CPU_FLAGS_X86 is a USE_EXPAND variable containing instruction set and other CPU-specific features.
CPU_FLAGS_PPC is a USE_EXPAND variable containing instruction set and other CPU-specific features.
CPU_FLAGS_ARM is a USE_EXPAND variable containing instruction set and other CPU-specific features.
Difference between CFLAGS and CPU_FLAGS*
A common question is "what's the difference between CFLAGS=... and e.g. CPU_FLAGS_X86=...?"
CPU_FLAGS*is an example of a 'USE expand'. It enables specific options in ebuilds which are passed onto the build system. For example,
CPU_FLAGS_X86_SSE2, if defined for a package, will enable handwritten ASM. These options enable specific code which already exists within the package.
CFLAGS, on the other hand, are simply used to tell the compiler it is allowed to try generate code using such instructions if it is able. It does not mean it will be successful in doing so. e.g. -msse2 in
CFLAGSdoes not mean the compiler will be clever enough to generate SSE2 for a certain function. These options just permit the compiler to generate certain code with certain instructions.
It is therefore important to configure CPU_FLAGS_* appropriately to get the best performance out of packages.
CPU_FLAGS_X86="mmx mmxext sse sse2 sse3"
The same CPU_FLAGS_X86 variable is used both on x86 and amd64 architectures on Intel and AMD CPUs.
When in doubt, consult the flag descriptions using one of the commonly available tools, e.g. equery uses from app-portage/gentoolkit:
equery uses media-video/ffmpeg
Most of the flag names match /proc/cpuinfo names, with the notable exception of
sse3 which is called
pni in /proc/cpuinfo (please also do not confuse it with distinct
emerge --ask app-portage/cpuid2cpuflags
CPU_FLAGS_X86: mmx mmxext sse sse2 sse3
Example to apply globally:
echo "*/* $(cpuid2cpuflags)" > /etc/portage/package.use/00cpu-flags
Migration from deprecated USE flags
In order not to lose CPU-specific optimizations, users will be required to update the make.conf (and potentially package.use) file. For example, if the following USE flags were present:
USE="mmx mmxext sse sse2 sse3"
They should be moved to the relevant CPU_FLAGS_* variable.
Saving deprecated USE flags
Previous USE flags corresponding to the instruction sets and other features specific to the x86/amd64, ppc/ppc64 and arm/arm64 architectures are being moved into separate USE_EXPAND variables.
In order to ensure safe migration and maintain compatibility with external repositories, it is recommended to preserve the old USE settings for a period of one year or until no package of interest is still using them.
- News item: new CPU_FLAGS_PPC USE_EXPAND