eclass: remove unused bzr.eclass
[gentoo.git] / eclass / flag-o-matic.eclass
index d8111fb9e38f4c07b009ca1a60c23656a84b7c43..0c67ec9f7a76861b5ff773f17f09b1694dc2562a 100644 (file)
@@ -56,7 +56,9 @@ setup-allowed-flags() {
                -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi
                -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel
                -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' -mfloat-abi
-               -mfix-r10000 -mno-fix-r10000 -mthumb -marm
+               -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
+               -mfix-rm7000 -mno-fix-rm7000 -mfix-r10000 -mno-fix-r10000
+               -mr10k-cache-barrier -mthumb -marm
 
                # gcc 4.5
                -mno-fma4 -mno-movbe -mno-xop -mno-lwp
@@ -487,15 +489,22 @@ test-flag-PROG() {
 
        printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'"
 
-       # Don't set -Werror as there are cases when benign
-       # always-on warnings filter out all flags like bug #712488.
-       # We'll have to live with potential '-Wunused-command-line-argument'.
-       # flags.
+       # Currently we rely on warning-free output of a compiler
+       # before the flag to see if a flag prduces any warnings.
+       # This has a few drawbacks:
+       # - if compiler already generates warnings we filter out
+       #   every single flag: bug #712488
+       # - if user actually wants to see warnings we just strip
+       #   them regardless of warnings type.
        #
        # We can add more selective detection of no-op flags via
-       # '-Werror=ignored-optimization-argument' and similar error options.
+       # '-Werror=ignored-optimization-argument' and similar error options
+       # similar to what we are doing with '-Qunused-arguments'.
        local cmdline=(
                "${comp[@]}"
+               # Clang will warn about unknown gcc flags but exit 0.
+               # Need -Werror to force it to exit non-zero.
+               -Werror
                "$@"
                # -x<lang> options need to go before first source file
                "${cmdline_extra[@]}"
@@ -503,7 +512,14 @@ test-flag-PROG() {
                "${test_in}" -o "${test_out}"
        )
 
-       "${cmdline[@]}" &>/dev/null
+       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
+               cmdline+=( -Qunused-arguments )
+               "${cmdline[@]}" &>/dev/null
+       fi
 }
 
 # @FUNCTION: test-flag-CC