flag-o-matic.eclass
Description
This eclass contains a suite of functions to help developers sanely and safely manage toolchain flags in their builds.
Functions
- all-flag-vars
-
Return all the flag variables that our high level functions operate on.
- filter-flags <flags>
-
Remove particular <flags> from
{C,CPP,CXX,CCAS,F,FC,LD}FLAGS. Accepts shell globs. - filter-lfs-flags
-
Remove flags that enable Large File Support.
- filter-lto
-
Remove flags that enable LTO and those that depend on it
- filter-ldflags <flags>
-
Remove particular
<flags>fromLDFLAGS. Accepts shell globs. - append-cppflags <flags>
-
Add extra
<flags>to the currentCPPFLAGS. - append-cflags <flags>
-
Add extra
<flags>to the currentCFLAGS. If a flag might not be supported with different compilers (or versions), then usetest-flags-CClike so:append-cflags $(test-flags-CC -funky-flag) - append-cxxflags <flags>
-
Add extra
<flags>to the currentCXXFLAGS. If a flag might not be supported with different compilers (or versions), then usetest-flags-CXXlike so:append-cxxflags $(test-flags-CXX -funky-flag) - append-fflags <flags>
-
Add extra
<flags>to the current{F,FC}FLAGS. If a flag might not be supported with different compilers (or versions), then usetest-flags-F77like so:append-fflags $(test-flags-F77 -funky-flag) - append-lfs-flags
-
Add flags that enable Large File Support.
- append-ldflags <flags>
-
Add extra
<flags>to the currentLDFLAGS. - append-flags <flags>
-
Add extra
<flags>to your current{C,CXX,F,FC}FLAGS. - replace-flags <old> <new>
-
Replace the
<old>flag with<new>. Accepts shell globs for<old>. - replace-cpu-flags <old> <new>
-
Replace cpu flags (like
-march/-mcpu/-mtune) that select the<old>cpu with flags that select the<new>cpu. Accepts shell globs for<old>. - is-flagq <flag>
-
Returns shell
trueif<flag>is in{C,CXX,F,FC}FLAGS, else returns shellfalse. Accepts shell globs. - is-flag <flag>
-
Echo's
trueif flag is set in{C,CXX,F,FC}FLAGS. Accepts shell globs. - is-ldflagq <flag>
-
Returns shell
trueif<flag>is inLDFLAGS, else returns shellfalse. Accepts shell globs. - is-ldflag <flag>
-
Echo's
trueif flag is set inLDFLAGS. Accepts shell globs. - filter-mfpmath <math types>
-
Remove specified math types from the
fpmathflag. For example, if the user has-mfpmath=sse,386, runningfilter-mfpmath ssewill leave the user with-mfpmath=386. - strip-flags
-
Strip
*FLAGSof everything except known good/safe flags. This runs over all flags returned byall_flag_vars(). - test-flag-CC <flag>
-
Returns shell
trueif<flag>is supported by the C compiler, else returns shellfalse. - test-flag-CXX <flag>
-
Returns shell
trueif<flag>is supported by the C++ compiler, else returns shellfalse. - test-flag-F77 <flag>
-
Returns shell
trueif<flag>is supported by the Fortran 77 compiler, else returns shellfalse. - test-flag-FC <flag>
-
Returns shell
trueif<flag>is supported by the Fortran 90 compiler, else returns shellfalse. - test-flag-CCLD <flag>
-
Returns shell
trueif<flag>is supported by the C compiler and linker, else returns shellfalse. - test-flags-CC <flags>
-
Returns shell
trueif<flags>are supported by the C compiler, else returns shellfalse. - test-flags-CXX <flags>
-
Returns shell
trueif<flags>are supported by the C++ compiler, else returns shellfalse. - test-flags-F77 <flags>
-
Returns shell
trueif<flags>are supported by the Fortran 77 compiler, else returns shellfalse. - test-flags-FC <flags>
-
Returns shell
trueif<flags>are supported by the Fortran 90 compiler, else returns shellfalse. - test-flags-CCLD <flags>
-
Returns shell
trueif<flags>are supported by the C compiler and default linker, else returns shellfalse. - test-flags <flags>
-
Short-hand that should hopefully work for both C and C++ compiler, but its really only present due to the
append-flags()abomination. - test_version_info <version>
-
Returns shell
trueif the current C compiler version matches<version>, else returns shellfalse. Accepts shell globs. - strip-unsupported-flags
-
Strip
{C,CXX,F,FC}FLAGSof any flags not supported by the active toolchain. - get-flag <flag>
-
Find and echo the value for a particular flag. Accepts shell globs.
- replace-sparc64-flags
-
Sets
mcputov8and uses the original value asmtuneif none specified. - append-libs <libs>
-
Add extra
<libs>to the currentLIBS. All arguments should be prefixed with either-lor-L. For compatibility, if arguments are not prefixed as options, they are given a-lprefix automatically. - raw-ldflags [flags]
-
Turn C style ldflags (
-Wl,-foo) into straight ldflags - the results are suitable for passing directly told; noteLDFLAGSis usually passed togccwhere it needs the-Wl,.If no flags are specified, then default to
${LDFLAGS}. - no-as-needed
-
Return value: Flag to disable
asneededbehavior for use withappend-ldflags. - append-atomic-flags [bytes]
-
Attempts to detect if appending -latomic is required to use a specific-sized atomic intrinsic, and if so, appends it. If the bytesize is not specified, then check the four most common byte sizes (1, 2, 4, 8). >=16-byte atomics are not included in this default set and must be explicitly passed if required. This may require you to add a macro definition like -Duint128_t=__uint128_t to your CFLAGS.
Reporting Bugs
Please report bugs via https://bugs.gentoo.org/