[Win][Clang] Do not give -Wall to clang-cl because it is treated as -Weverything
According to clang-cl manual, it has following command switch mapping:
> /W4 Enable -Wall and -Wextra
> /Wall Enable -Weverything
As the result, clang-cl treat -Wall as -Weverything, and reports ton of warning messages.
Created attachment 352155 [details]
There is another issue some switches aren't effective.
For exampel -Wno-unknown-pragmas.
-Wno-unknown-pragmas should be specified after /W4, not before.
GCC and Clang treat -Wall differently.
Clang processes all -W* options in left-to-right order.
GCC processes -Wall and -Wextra options first.
Created attachment 352305 [details]
Created attachment 352306 [details]
Created attachment 352307 [details]
I think it would be more reasonable to avoid feeding COMPILER_IS_GCC_OR_CLANG options for clang-cl, because it expects cl.exe options instead
Thanks for your feedback. I was also thinking the same idea. But, I'm not confident which is better. I will try to create a patch in another bug ticket.
clang-cl compiles almost same code paths with MSVC. But there is only one exception.
clang-cl uses warning macros for Clang (IGNORE_WARNINGS_* and IGNORE_CLANG_WARNINGS_*), even though those macros are disabled for MSVC.
With regard to compilation warnings, clang-cl is closer to clang than MSVC.
It turned out it is not simple as I expected.
Here are all usage of COMPILER_IS_GCC_OR_CLANG.
Almost all usage of COMPILER_IS_GCC_OR_CLANG is to suppress
compilation warnings, such like the following:
> if (COMPILER_IS_GCC_OR_CLANG)
> WEBKIT_ADD_TARGET_CXX_FLAGS(TestWTF -Wno-dangling-else
> endif ()
I'd like to share these warning switched with clang-cl.
It seems COMPILER_IS_GCC_OR_CLANG should be enabled for clang-cl.
Comment on attachment 352307 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=352307&action=review
> + # -Wall and -Wextra should be speficied before -Wno-* for Clang.
Created attachment 352687 [details]
Comment on attachment 352687 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=352687&action=review
> +if (NOT MSVC)
if (COMPILER_IS_GCC_OR_CLANG AND NOT MSVC)
It's just unfriendly to pass GCC flags to random compilers that might not be GCC compatible (even if it's unlikely that somebody would be attempting to use such a compiler nowadays.)
Created attachment 352757 [details]
Patch for landing
Thank you for the review. It makes sense. Applied the review feedback.
Comment on attachment 352757 [details]
Patch for landing
Clearing flags on attachment: 352757
Committed r237282: <https://trac.webkit.org/changeset/237282>
All reviewed patches have been landed. Closing bug.