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-CC
like 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-CXX
like 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-F77
like 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
true
if<flag>
is in{C,CXX,F,FC}FLAGS
, else returns shellfalse
. Accepts shell globs. - is-flag <flag>
-
Echo's
true
if flag is set in{C,CXX,F,FC}FLAGS
. Accepts shell globs. - is-ldflagq <flag>
-
Returns shell
true
if<flag>
is inLDFLAGS
, else returns shellfalse
. Accepts shell globs. - is-ldflag <flag>
-
Echo's
true
if flag is set inLDFLAGS
. Accepts shell globs. - filter-mfpmath <math types>
-
Remove specified math types from the
fpmath
flag. For example, if the user has-mfpmath=sse,386
, runningfilter-mfpmath sse
will leave the user with-mfpmath=386
. - strip-flags
-
Strip
*FLAGS
of everything except known good/safe flags. This runs over all flags returned byall_flag_vars()
. - test-flag-CC <flag>
-
Returns shell
true
if<flag>
is supported by the C compiler, else returns shellfalse
. - test-flag-CXX <flag>
-
Returns shell
true
if<flag>
is supported by the C++ compiler, else returns shellfalse
. - test-flag-F77 <flag>
-
Returns shell
true
if<flag>
is supported by the Fortran 77 compiler, else returns shellfalse
. - test-flag-FC <flag>
-
Returns shell
true
if<flag>
is supported by the Fortran 90 compiler, else returns shellfalse
. - test-flag-CCLD <flag>
-
Returns shell
true
if<flag>
is supported by the C compiler and linker, else returns shellfalse
. - test-flags-CC <flags>
-
Returns shell
true
if<flags>
are supported by the C compiler, else returns shellfalse
. - test-flags-CXX <flags>
-
Returns shell
true
if<flags>
are supported by the C++ compiler, else returns shellfalse
. - test-flags-F77 <flags>
-
Returns shell
true
if<flags>
are supported by the Fortran 77 compiler, else returns shellfalse
. - test-flags-FC <flags>
-
Returns shell
true
if<flags>
are supported by the Fortran 90 compiler, else returns shellfalse
. - test-flags-CCLD <flags>
-
Returns shell
true
if<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
true
if the current C compiler version matches<version>
, else returns shellfalse
. Accepts shell globs. - strip-unsupported-flags
-
Strip
{C,CXX,F,FC}FLAGS
of 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
mcpu
tov8
and uses the original value asmtune
if none specified. - append-libs <libs>
-
Add extra
<libs>
to the currentLIBS
. All arguments should be prefixed with either-l
or-L
. For compatibility, if arguments are not prefixed as options, they are given a-l
prefix automatically. - raw-ldflags [flags]
-
Turn C style ldflags (
-Wl,-foo
) into straight ldflags - the results are suitable for passing directly told
; noteLDFLAGS
is usually passed togcc
where it needs the-Wl,
.If no flags are specified, then default to
${LDFLAGS}
. - no-as-needed
-
Return value: Flag to disable
asneeded
behavior 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/