Skip to content

remove min warning level #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2022
Merged

remove min warning level #27

merged 1 commit into from
Apr 30, 2022

Conversation

neheb
Copy link
Contributor

@neheb neheb commented Apr 22, 2022

This can be done using warning_level=1. Fixes meson warning.

WARNING: Consider using the built-in warning_level option instead of using "-Wall".

This can be done using warning_level=1. Fixes meson warning.
@kjellahl
Copy link
Collaborator

Sorry, but I'd rather not implement your patch. For a number of reasons.

  • We use -Dwarnings with possible values ['no', 'min', 'max', 'fatal'] in a number
    of projects, most of them in gitlab.gnome.org.

  • It's inherited from what has been used in Autotools builds for decades.
    (Not a very good reason, I admit.)

  • Your patch removes a meson warning only if warnings=min is selected. I usually
    build with warnings=fatal. Even with your patch I get the usual warnings

meson.build:253: WARNING: Consider using the built-in warning_level option instead of using "-Wall".
meson.build:253: WARNING: Consider using the built-in warning_level option instead of using "-Wextra".
meson.build:253: WARNING: Consider using the built-in werror option instead of using "-Werror".
  • With meson's warning_level we don't get a very good control of which compiler
    warnings are enabled. I haven't seen it documented. I looked into meson's source code
    to see that warning_level=1 enables ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'].

When I looked at your patch and once again studied part of the meson documentation,
I realized that probably warning_level=0 should be set in project() at the beginning
of the meson.build file. The default is warning_level=1, which means that some
warnings are enabled even if you choose warnings=no.

It would be nice to get rid of meson's warnings and still set any compiler options
in the call to add_project_arguments(). I haven't found a way to achieve that.

@eli-schwartz
Copy link

Wouldn't it make sense to do all that properly, by actually making proper use of Meson?

As for the flags, why do you care if -Winvalid-pch is set? On the other hand, sure, Meson could probably avoid setting this flag at all if a given target doesn't have *_pch: 'foo_pch.h' set.

-Wnon-virtual-dtor is apparently part of -Wall, and is only passed by Meson in cases where -Wall is anyways passed, so I can't imagine it causes any harm whatsoever.

@kjellahl
Copy link
Collaborator

I'm not a fan of warning_level. In https://github.com/libsigcplusplus/libsigcplusplus
it's impossible to combine warning_level>0 with -Werror, because of -Wnon-virtual-dtor.
Without -Werror, -Wnon-virtual-dtor would generate unnecessary compilation warnings.
Is it documented what the different warning levels mean? Which compiler options they generate?

Meson's werror option is another matter. It should probably be used instead of
libxml++'s warnings=fatal.

That said, this PR does no harm here. I can merge it. But it corrects only a small
part of all my improper uses of Meson. I'll give the PR writer a chance to comment first.

@eli-schwartz
Copy link

eli-schwartz commented Apr 26, 2022

Isn't that what -Wno-non-virtual-dtor is for?

According to my manpage, this warning is implied by -Wall anyway.

@kjellahl
Copy link
Collaborator

-Wall implies -Wdelete-non-virtual-dtor. It does not imply -Wnon-virtual-dtor.

-Wnon-virtual-dtor generated a warning in libsigcplusplus. I thought that the
warning came from code that can't be fixed, because it would break ABI. (Adding or
deleting virtual functions in existing classes in a library breaks its ABI.) I was wrong.
When I checked again, I saw that the warning came from a small example program that can
be changed without breaking any user code. I've fixed that now. -Wnon-virtual-dtor
is no longer a problem in libsigcplusplus.

Still, I don't like the warnings from Meson when you add certain compiler options with
add_project_arguments(), options that can be added with warning_level > 0.
It's possible to avoid the warnings by adding the compiler options in library()
and executable() instead, but that would be an unnecessary complication, if you
want them added in all compilations.

For instance, say you want to add -Wextra. Which level of warning_level should you select?
Would it also add other warning options? Which ones? I don't mind that the warning_level
option exists, but it can be problematic if you're nitpicking about which compiler
options to set. It should be possible to set warning_level=0 and set any compiler
options (except possibly -Werror) in add_project_arguments() without getting warnings
from Meson.

@kjellahl
Copy link
Collaborator

@fanc999 If I merge this PR, -Dwarnings=min (the default value) will add /W2
instead of /W3 when compiling with MSVC. Does it matter?

@fanc999
Copy link
Collaborator

fanc999 commented Apr 29, 2022

Hi,

That's perfectly fine with me. It's actually better, since Visual Studio would be less annoyed by D9028 warnings by attempting to replace /W2 with /W3.

Thanks for the heads up! :)

@kjellahl kjellahl merged commit 8cbfa14 into libxmlplusplus:master Apr 30, 2022
@eli-schwartz
Copy link

-Wall implies -Wdelete-non-virtual-dtor. It does not imply -Wnon-virtual-dtor.

Right, sorry, I misread that.

Now, it's not really clear to me what the purpose of this warning being in the Meson defaults is, though. So maybe that's a problem we should fix, so that people stop being unhappy about using meson's warning_level option. ;)

@eli-schwartz
Copy link

mesonbuild/meson#10339

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants