From 0404ad5601418884f967f8917cbf763cfb7be282 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 1 May 2022 18:59:21 -0400 Subject: [PATCH] compilers: remove opinionated c++ warning flag -Wnon-virtual-dtor is not what people think of as a standard warning flag. It was previously removed from -Wall in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16190 on the grounds that people didn't like it and were refusing to use -Wall at all because it forced this warning. Instead, it is enabled by -Weffc++ which is typically not enabled and even comes with GCC documentation warnings stating that the standard library doesn't obey it, and you might need to `grep -v` and filter out warnings. (!!!) It doesn't fit into the typical semantics of Meson's warning_level option, which usually aligns with compiler standard warning levels rather than a niche ideological warning level. It was originally added in commit 22af56e05aa9cba4740d2ff303d876bb0c3cfb2b, but without any specific rationale included, and has gone unquestioned since then -- except by the Meson users who see it, assume there is a finely crafted design behind it, and quietly opt out by rolling their own warning options with `add_project_arguments('-Wall', ...)`. Furthermore a GCC component maintainer for the C++ standard library opened a Meson bug report specially to tell us that this warning flag is a "dumb option" and "broken by design" and "doesn't warn about the right thing anyway", thus it should not be used. This is a reasonably authoritative source that maybe, just maybe, this flag... is too opinionated to force upon Meson users without recourse. It's gone beyond opinionated and into the realm of compiler vendors seem to think that the state of the language would be better if the flag did not exist at all, whether default or not. Fixes #11096 --- docs/markdown/snippets/cxx_warn_args_dtor.md | 3 +++ mesonbuild/compilers/cpp.py | 8 ++++---- mesonbuild/compilers/objcpp.py | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 docs/markdown/snippets/cxx_warn_args_dtor.md diff --git a/docs/markdown/snippets/cxx_warn_args_dtor.md b/docs/markdown/snippets/cxx_warn_args_dtor.md new file mode 100644 index 000000000..fb35c36a6 --- /dev/null +++ b/docs/markdown/snippets/cxx_warn_args_dtor.md @@ -0,0 +1,3 @@ +## Flags removed from cpp/objcpp warning level 1 + +`-Wnon-virtual-dtor` is no longer implied by `meson setup -Dwarning_level=1`. diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 06338291e..1ea9bcae5 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -190,7 +190,7 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler): CPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross, info, exe_wrapper, linker=linker, full_version=full_version) ClangCompiler.__init__(self, defines) - default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] + default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], @@ -310,7 +310,7 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler): CPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross, info, exe_wrapper, linker=linker, full_version=full_version) ArmclangCompiler.__init__(self) - default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] + default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], @@ -356,7 +356,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): CPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross, info, exe_wrapper, linker=linker, full_version=full_version) GnuCompiler.__init__(self, defines) - default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] + default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], @@ -536,7 +536,7 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler): IntelGnuLikeCompiler.__init__(self) self.lang_header = 'c++-header' default_warn_args = ['-Wall', '-w3', '-diag-disable:remark', - '-Wpch-messages', '-Wnon-virtual-dtor'] + '-Wpch-messages'] self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index 5012ea3e3..f44931fdc 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -63,7 +63,7 @@ class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler): ObjCPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross, info, exe_wrapper, linker=linker, full_version=full_version) GnuCompiler.__init__(self, defines) - default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] + default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], @@ -81,7 +81,7 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler): ObjCPPCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross, info, exe_wrapper, linker=linker, full_version=full_version) ClangCompiler.__init__(self, defines) - default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] + default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'],