This is an archive of the discontinued LLVM Phabricator instance.

[clang-cl] Expose -Wall to clang-cl by unaliasing -Wall, keeping /Wall as alias to -Weverything
AbandonedPublic

Authored by saudi on Nov 26 2021, 10:22 AM.

Details

Reviewers
rnk
hans
Summary

Currently, for clang-cl, -Wall is treated identically as /Wall and is aliased to -Weverything.

This patch allows to expose -Wall to clang-cl while keeping the order of warning arguments, which the -Xclang alternative doesn't allow.

Diff Detail

Event Timeline

saudi created this revision.Nov 26 2021, 10:22 AM
saudi requested review of this revision.Nov 26 2021, 10:22 AM

Is the deviation from MSVC behaviour here intentional? MSVC flags allow both using a / as well as - as prefix. That means Both -Wall and /Wall are accepted by MSVC as well as clang-cl and in both compilers currently lead to ALL warnings being emitted. So this patch would deviate from that behaviour as well as add confusion as every other option behaves the same in MSVC and clang-cl, regardless of whether - or / is used as prefix.

Is the deviation from MSVC behaviour here intentional? MSVC flags allow both using a / as well as - as prefix. That means Both -Wall and /Wall are accepted by MSVC as well as clang-cl and in both compilers currently lead to ALL warnings being emitted. So this patch would deviate from that behaviour as well as add confusion as every other option behaves the same in MSVC and clang-cl, regardless of whether - or / is used as prefix.

+1, while it's annoying with -Wall not doing the expected thing when using (clang-)cl, that's to be expected - cl and gcc style drivers have entirely different options overall, so one generally have to take care and use the right kind of options for them (and it's just a bit inconvenient that some options overlap but differ). So specialcasing an exception for this particular option doesn't seem worth it. Even in the context of cl-only options, I tend to always use the slash form, because there's less risk of mixups.

saudi abandoned this revision.Nov 29 2021, 6:01 AM

I understand, making clang-cl -Wall behave differently than `/Wall' is indeed confusing.
We'll take different steps for setting up the warnings in our Build System.

rnk added a comment.Nov 29 2021, 10:01 AM

I will add that multiple users have run into this problem, and I think it might be more practical to consider unaliasing Wall altogether. Clang doesn't emit the same set of warnings as MSVC. Anyone seriously using clang-cl /Wall is going to receive a pile of -WcxxNN-compat warnings that are self-contradictory, and they are going to need to curate a set of clang-specific warning flags anyway.

I will add that multiple users have run into this problem, and I think it might be more practical to consider unaliasing Wall altogether. Clang doesn't emit the same set of warnings as MSVC. Anyone seriously using clang-cl /Wall is going to receive a pile of -WcxxNN-compat warnings that are self-contradictory, and they are going to need to curate a set of clang-specific warning flags anyway.

One possible downside with that, is that you'd easily end up making cl-compatible build files that works nicely with clang-cl but spew warnings with cl.exe. (Although maybe cl.exe's -Wall produce a much safer/saner set of warnings?) But I don't feel strongly about it..

rnk added a comment.Nov 30 2021, 9:15 AM

It looks like this Wall -> Weverything alias is from my 2017 change:
https://reviews.llvm.org/rGf9b08a382cc1e0669805991849ad69efbd4703e8

The commit message doesn't link to any bugs or any other motivating material. All I said is that this is being done for MSVC compatibility. I remember having some motivating reason, but it looks like I won't be able to find it. I see Hans thanked me for the behavior change, maybe he recalls.

Anyway, I would approve a patch to remove the alias, but I'd want to confirm with Hans that he is also on board with it, since I suspect he was the one who talked me into adding the alias. I don't have more time to follow up on this at the moment.