Bug 190514

Summary: [Win][Clang] Do not give -Wall to clang-cl because it is treated as -Weverything
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: CMakeAssignee: Fujii Hironori <Hironori.Fujii>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, annulen, bfulgham, mcatanzaro, pvollan, webkit-bug-importer
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 171618    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Fujii Hironori
Reported 2018-10-12 03:37:02 PDT
[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: https://clang.llvm.org/docs/UsersManual.html#id8 > /W4 Enable -Wall and -Wextra > /Wall Enable -Weverything As the result, clang-cl treat -Wall as -Weverything, and reports ton of warning messages. reported
Attachments
Patch (1.70 KB, patch)
2018-10-12 04:10 PDT, Fujii Hironori
no flags
Patch (4.01 KB, patch)
2018-10-15 02:06 PDT, Fujii Hironori
no flags
Patch (4.08 KB, patch)
2018-10-15 03:27 PDT, Fujii Hironori
no flags
Patch (4.15 KB, patch)
2018-10-15 03:34 PDT, Fujii Hironori
no flags
Patch (3.87 KB, patch)
2018-10-18 00:43 PDT, Fujii Hironori
no flags
Patch for landing (4.03 KB, patch)
2018-10-18 19:37 PDT, Fujii Hironori
no flags
Fujii Hironori
Comment 1 2018-10-12 04:10:34 PDT
Fujii Hironori
Comment 2 2018-10-14 20:10:59 PDT
There is another issue some switches aren't effective. For exampel -Wno-unknown-pragmas. -Wno-unknown-pragmas should be specified after /W4, not before.
Fujii Hironori
Comment 3 2018-10-14 21:59:27 PDT
GCC and Clang treat -Wall differently. Clang processes all -W* options in left-to-right order. GCC processes -Wall and -Wextra options first. https://bugs.llvm.org/show_bug.cgi?id=24376 https://gist.github.com/fujii/afb137300be40c71ea61b28391035ce7
Fujii Hironori
Comment 4 2018-10-15 02:06:10 PDT
Fujii Hironori
Comment 5 2018-10-15 03:27:16 PDT
Fujii Hironori
Comment 6 2018-10-15 03:34:09 PDT
Konstantin Tokarev
Comment 7 2018-10-15 06:54:10 PDT
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
Fujii Hironori
Comment 8 2018-10-15 07:36:28 PDT
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. https://github.com/WebKit/webkit/blob/947003f6e3e05f3387e625d862e18cf61c15f03d/Source/WTF/wtf/Compiler.h#L442 With regard to compilation warnings, clang-cl is closer to clang than MSVC.
Fujii Hironori
Comment 9 2018-10-15 21:00:29 PDT
It turned out it is not simple as I expected. Here are all usage of COMPILER_IS_GCC_OR_CLANG. https://github.com/WebKit/webkit/search?q=COMPILER_IS_GCC_OR_CLANG&unscoped_q=COMPILER_IS_GCC_OR_CLANG Almost all usage of COMPILER_IS_GCC_OR_CLANG is to suppress compilation warnings, such like the following: https://github.com/WebKit/webkit/blob/8138e195f0da39b5a476cbab5d3f1b8aafb6be4e/Tools/TestWebKitAPI/CMakeLists.txt#L265 > if (COMPILER_IS_GCC_OR_CLANG) > WEBKIT_ADD_TARGET_CXX_FLAGS(TestWTF -Wno-dangling-else > -Wno-sign-compare > -Wno-undef > -Wno-unused-parameter) > 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.
Fujii Hironori
Comment 10 2018-10-16 18:36:48 PDT
Comment on attachment 352307 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=352307&action=review > Source/cmake/WebKitCompilerFlags.cmake:147 > + # -Wall and -Wextra should be speficied before -Wno-* for Clang. s/speficied/specified/
Fujii Hironori
Comment 11 2018-10-18 00:43:58 PDT
Fujii Hironori
Comment 12 2018-10-18 18:09:51 PDT
Review, please.
Michael Catanzaro
Comment 13 2018-10-18 18:21:55 PDT
Comment on attachment 352687 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=352687&action=review > Source/cmake/WebKitCompilerFlags.cmake:148 > +if (NOT MSVC) What about: 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.)
Fujii Hironori
Comment 14 2018-10-18 19:37:21 PDT
Created attachment 352757 [details] Patch for landing Thank you for the review. It makes sense. Applied the review feedback.
Fujii Hironori
Comment 15 2018-10-18 23:44:44 PDT
Comment on attachment 352757 [details] Patch for landing Clearing flags on attachment: 352757 Committed r237282: <https://trac.webkit.org/changeset/237282>
Fujii Hironori
Comment 16 2018-10-18 23:44:47 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.