CPU FLAGS X86

CPU_FLAGS_X86 is 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="-march=..." 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.
 * 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 CFLAGS does not mean the compiler will be clever enough to generate SSE2 for a certain function.

Configuration
These variables need to be set as CPU_FLAGS_X86 ( CPU_FLAGS_ARM, CPU_FLAGS_PPC ) variable in  or in :

When in doubt, consult the flag descriptions using one of the commonly available tools, e.g. from :

Most of the flag names match names, with the notable exception of   which is called   in  (please also do not confuse it with distinct  ).

Using cpuid2cpuflags
helps users determine the correct CPU_FLAGS_ USE_EXPAND variables for their CPU architecture.

Invocation
Example to apply globally:

Migration from deprecated USE flags
In order not to lose CPU-specific optimizations, users will be required to update the (and potentially ) file. For example, if the following USE flags were present:

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 /, / and / 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.

External resources

 * News item: new CPU_FLAGS_PPC USE_EXPAND