Specific compiler switches per package in Gentoo

To configure specific compiler switches per package in Gentoo use these instructions.

Modifying environmental variables per package

The package.env file can be used to modify environmental variables per package. See /etc/portage/env in the Gentoo Wiki for details.

Conflicting compiler switches

In make.conf one typically specifies compiler switches that are selected to optimize for one's specific machine. But some packages (e.g. www-client/chromium) have their own build system, which can result in conflicting compiler switches.

Disabling compiler switches per package

This can be done via package.env and helper files in the env subdirectory. For example, if /etc/portage/make.conf specifies the following section:

1CFLAGS="-O2 -march=native -pipe" CXXFLAGS="${CFLAGS}"

then in /etc/portage/package.env the following section will select specific flags for the www-client/chromium package:

1www-client/chromium cflags-no-optimization

and in the /etc/portage/env/cflags-no-optimization file holds the specific environmental variable:

1# No optimization # CFLAGS="-march=native -pipe"

This prevents that the -O2 compiler switch that is specified in make.conf is used for the www-client/chromium package.

Posts in this Series