[Mesa-dev] [PATCH v2] configure: avoid testing for negative compiler options

Dylan Baker dylan at pnwbakers.com
Sat Dec 2 01:15:00 UTC 2017


Thanks for looking into this, I've gone ahead and pushed this to master.

Dylan

Quoting Marc Dietrich (2017-11-29 13:25:05)
> gcc seems to always accept unsupported negative compiler warning options:
> 
> echo "int i;" | gcc -c -xc -Wno-bob - # no error
> echo "int i;" | gcc -c -xc -Walice -  # unsupported compiler option
> 
> Inverting the options fixes the tests.
> 
> V2: fix options in meson build
> 
> Reviewed-by: Matt Turner <mattst88 at gmail.com>
> Signed-off-by: Marc Dietrich <marvin24 at gmx.de>
> ---
>  configure.ac |  6 ++++--
>  meson.build  | 23 +++++++++++++++--------
>  2 files changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 1344c12884..3f9a5c85b1 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -394,8 +394,10 @@ esac
>  AC_SUBST([VISIBILITY_CFLAGS])
>  AC_SUBST([VISIBILITY_CXXFLAGS])
>  
> -AX_CHECK_COMPILE_FLAG([-Wno-override-init],                    [WNO_OVERRIDE_INIT="$WNO_OVERRIDE_INIT -Wno-override-init"])         # gcc
> -AX_CHECK_COMPILE_FLAG([-Wno-initializer-overrides],            [WNO_OVERRIDE_INIT="$WNO_OVERRIDE_INIT -Wno-initializer-overrides"]) # clang
> +dnl For some reason, the test for -Wno-foo always succeeds with gcc, even if the
> +dnl option is not supported. Hence, check for -Wfoo instead.
> +AX_CHECK_COMPILE_FLAG([-Woverride-init],                    [WNO_OVERRIDE_INIT="$WNO_OVERRIDE_INIT -Wno-override-init"])         # gcc
> +AX_CHECK_COMPILE_FLAG([-Winitializer-overrides],            [WNO_OVERRIDE_INIT="$WNO_OVERRIDE_INIT -Wno-initializer-overrides"]) # clang
>  AC_SUBST([WNO_OVERRIDE_INIT])
>  
>  dnl
> diff --git a/meson.build b/meson.build
> index 919f1c2d41..a55d5ed391 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -683,11 +683,25 @@ endif
>  cpp = meson.get_compiler('cpp')
>  cpp_args = []
>  foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
> -             '-Qunused-arguments', '-Wno-non-virtual-dtor']
> +             '-Qunused-arguments']
>    if cpp.has_argument(a)
>      cpp_args += a
>    endif
>  endforeach
> +
> +# For some reason, the test for -Wno-foo always succeeds with gcc, even if the
> +# option is not supported. Hence, check for -Wfoo instead.
> +if cpp.has_argument('-Wnon-virtual-dtor')
> +  cpp_args += '-Wno-non-virtual-dtor'
> +endif
> +
> +no_override_init_args = []
> +foreach a : ['override-init', 'initializer-overrides']
> +  if cc.has_argument('-W' + a)
> +    no_override_init_args += '-Wno-' + a
> +  endif
> +endforeach
> +
>  cpp_vis_args = []
>  if cpp.has_argument('-fvisibility=hidden')
>    cpp_vis_args += '-fvisibility=hidden'
> @@ -707,13 +721,6 @@ foreach a : ['-Werror=pointer-arith', '-Werror=vla']
>    endif
>  endforeach
>  
> -no_override_init_args = []
> -foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
> -  if cc.has_argument(a)
> -    no_override_init_args += a
> -  endif
> -endforeach
> -
>  if host_machine.cpu_family().startswith('x86')
>    pre_args += '-DHAVE_SSE41'
>    with_sse41 = true
> -- 
> 2.15.0
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171201/35ecf2fc/attachment-0001.sig>


More information about the mesa-dev mailing list