From: Alexander Miller <>

A number of configure checks used by CMake and autoconf (and probably
other build systems) relies on warning-free compiler runs. A combination
of compiler and flags that always generates warnings can cause
misconfiguration and/or build failures.

Since commit ae9870d9f6b1394ede86176443770b36d7e60ac1, flags that
generate warnings that could be suppressed with -Qunused-arguments
are accepted anyway to avoid stripping all linker flags (#627474).
But commit 28d6437fc7009002f98f28e8900e994109927726 added linker
invocation for linker flags tests, so the workaround shouldn't be
necessary any more.

Drop the extra -Qunused-arguments check and reject all flags that
generate warnings to avoid configuration issues.

If it turns out that stripping these unused flags is still problematic,
we could accept them and actually add -Qunused-arguments to the
relevant *FLAGS to silence the warnings, but that would require
bigger changes, so let's try the simpler and cleaner solution first.

Signed-off-by: Alexander Miller <>
Signed-off-by: Sam James <>
 eclass/flag-o-matic.eclass | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 7319326c7ad8..365741a6dddf 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -601,11 +601,20 @@ _test-flag-PROG() {
        # We can add more selective detection of no-op flags via
        # '-Werror=ignored-optimization-argument' and similar error options
-       # similar to what we are doing with '-Qunused-arguments'.
+       # or accept unused flags with '-Qunused-arguments' like we
+       # used to for bug #627474. Since we now invoke the linker
+       # for testing linker flags, unused argument warnings aren't
+       # ignored; linker flags may no longer be accepted in CFLAGS.
+       #
+       # However, warnings emitted by a compiler for a clean source
+       # can break feature detection by CMake or autoconf since
+       # many checks use -Werror internally. See e.g. bug #714742.
        local cmdline=(
                # Clang will warn about unknown gcc flags but exit 0.
                # Need -Werror to force it to exit non-zero.
+               #
+               # See also bug #712488 and bug #714742.
                # -x<lang> options need to go before first source file
@@ -614,16 +623,7 @@ _test-flag-PROG() {
                "${test_in}" -o "${test_out}"
-       if ! "${cmdline[@]}" &>/dev/null; then
-               # -Werror makes clang bail out on unused arguments as well;
-               # try to add -Qunused-arguments to work-around that
-               # other compilers don't support it but then, it's failure like
-               # any other.
-               #
-               # See also bug #712488 and bug #714742.
-               cmdline+=( -Qunused-arguments )
-               "${cmdline[@]}" &>/dev/null
-       fi
+       "${cmdline[@]}" &>/dev/null
 # @FUNCTION: test-flag-CC

Reply via email to