Bug 182479

Summary: [Win] Fix MSVC's treating __attribute__((warn_unused_result))
Product: WebKit Reporter: Yousuke Kimoto <Yousuke.Kimoto>
Component: WebKit2Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ap, cdumez, commit-queue, darin, don.olmstead, koivisto, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 174003    
Attachments:
Description Flags
Patch
none
Patch
darin: review-
Patch
none
Patch
darin: review+, commit-queue: commit-queue-
Patch (a rebased version)
none
Patch (a rebased version) none

Yousuke Kimoto
Reported 2018-02-05 04:20:46 PST
MSVC doesn't understand __attribute((warn_unsed_resutl)), but it has a similar option, _Check_return_. MSVC Annotating Function Behavior: https://msdn.microsoft.com/en-us/library/jj159529.aspx
Attachments
Patch (1.56 KB, patch)
2018-02-05 04:34 PST, Yousuke Kimoto
no flags
Patch (1.41 KB, patch)
2018-02-05 19:45 PST, Yousuke Kimoto
darin: review-
Patch (1.44 KB, patch)
2018-02-15 05:28 PST, Yousuke Kimoto
no flags
Patch (1.44 KB, patch)
2018-02-15 09:56 PST, Yousuke Kimoto
darin: review+
commit-queue: commit-queue-
Patch (a rebased version) (1.45 KB, patch)
2018-02-19 18:35 PST, Yousuke Kimoto
no flags
Patch (a rebased version) (1.44 KB, patch)
2018-02-19 18:44 PST, Yousuke Kimoto
no flags
Yousuke Kimoto
Comment 1 2018-02-05 04:34:36 PST
Yousuke Kimoto
Comment 2 2018-02-05 06:58:57 PST
>ERROR: '/Volumes/Data/EWS/WebKit/WebKitBuild/Release/WebKitFailed to run "['Tools/Scripts/build-webkit', '--release']" exit_code: 65 >Last 500 characters of output: >A55DEAA61670402E003DB841.sh >ERROR: >'/Volumes/Data/EWS/WebKit/WebKitBuild/Release/WebKit.framework/Versions/A/PrivateHeaders/WKRetainPtr.h:245' included forbidden macro 'COMPILER' => '#if !COMPILER(MSVC)' >Command /bin/sh failed with exit code 1 > >** BUILD FAILED ** > >The following build commands failed: > PhaseScriptExecution Check\ For\ Inappropriate\ Macros\ in\ External\ Headers /Volumes/Data/EWS/WebKit/WebKitBuild/WebKit.build/Release/WebKit.build/Script-A55DEAA61670402E003DB841.sh >(1 failure) Mac and iOS failed by the same reason like the above.
Alex Christensen
Comment 3 2018-02-05 17:29:33 PST
Comment on attachment 333074 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=333074&action=review > Source/WebKit/UIProcess/API/cpp/WKRetainPtr.h:245 > +#if !COMPILER(MSVC) We usually try to put the positive first, so this would be #if COMPILER(MSVC) But you can't use COMPILER here because this header is part of the API. Elsewhere in the API we've done #if defined(WIN32) || defined(_WIN32), but maybe we should check _MSC_VER instead for people using clang on windows.
Yousuke Kimoto
Comment 4 2018-02-05 19:07:38 PST
(In reply to Alex Christensen from comment #3) > We usually try to put the positive first, so this would be #if COMPILER(MSVC) > But you can't use COMPILER here because this header is part of the API. > Elsewhere in the API we've done #if defined(WIN32) || defined(_WIN32), but > maybe we should check _MSC_VER instead for people using clang on windows. Thank you for your advice. I'll fix it with the condition you suggested.
Yousuke Kimoto
Comment 5 2018-02-05 19:45:46 PST
Yousuke Kimoto
Comment 6 2018-02-06 05:04:49 PST
(In reply to Alex Christensen from comment #3) > maybe we should check _MSC_VER instead for people using clang on windows. Table about _MSC_VER and Visual Studio version: https://blogs.msdn.microsoft.com/vcblog/2015/12/04/clang-with-microsoft-codegen-in-vs-2015-update-1/ https://cpprefjp.github.io/implementation.html#visual_cpp I have two questions about _MSC_VER. 1. Is VisualStudio 2017 a recommended IDE on windows ? 2. When clang is used on windows, which template should be chosen, a) or b)? a) template<typename T> inline WKRetainPtr<T> adoptWK(T) _Check_return_; b) template<typename T> inline WKRetainPtr<T> adoptWK(T) __attribute__((warn_unused_result));
Yousuke Kimoto
Comment 7 2018-02-07 19:37:33 PST
Comment on attachment 333152 [details] Patch I confirmed this patch works on the wincairo build but the Bot status was failure on wincairo. If we take care of clang users on windows, for example, the part will be as follows. (In this case, supposing VisualStudio 2017 and Clang/C2 are used.) Please give me your comment. #if defined(WIN32) || defined(_WIN32) #if (_MSC_VER > 1900) && (__c2__) template<typename T> inline WKRetainPtr<T> adoptWK(T) __attribute__((warn_unused_result)); #else template<typename T> inline WKRetainPtr<T> adoptWK(T) _Check_return_; #endif #else template<typename T> inline WKRetainPtr<T> adoptWK(T) __attribute__((warn_unused_result)); #endif
Darin Adler
Comment 8 2018-02-14 16:36:10 PST
Comment on attachment 333152 [details] Patch This is the wrong fix. The correct fix would be to use WARN_UNUSED_RETURN from Compiler.h instead of using warn_unused_result directly.
Darin Adler
Comment 9 2018-02-14 16:38:08 PST
Comment on attachment 333152 [details] Patch Oh wait, I see, this is in an "API" header. Maybe this is OK, then. Lets try it at least.
Darin Adler
Comment 10 2018-02-14 16:38:52 PST
Comment on attachment 333152 [details] Patch Actually, the compiler version issue you mentioned has to be resolved first, so back to review-.
Yousuke Kimoto
Comment 11 2018-02-15 05:28:53 PST
Yousuke Kimoto
Comment 12 2018-02-15 09:56:02 PST
Yousuke Kimoto
Comment 13 2018-02-15 14:26:00 PST
(In reply to Darin Adler from comment #10) > Actually, the compiler version issue you mentioned has to be resolved first, > so back to review-. > Created attachment 333909 [details] This patch fixed the compiler version issue. Could you review it again?
WebKit Commit Bot
Comment 14 2018-02-18 08:04:20 PST
Comment on attachment 333909 [details] Patch Rejecting attachment 333909 [details] from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-02', 'land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 333909, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit Last 500 characters of output: rdparty/autoinstalled/mechanize/_urllib2_fork.py", line 332, in _call_chain result = func(*args) File "/Volumes/Data/EWS/WebKit/Tools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_urllib2_fork.py", line 1170, in https_open return self.do_open(conn_factory, req) File "/Volumes/Data/EWS/WebKit/Tools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_urllib2_fork.py", line 1118, in do_open raise URLError(err) urllib2.URLError: <urlopen error [Errno 60] Operation timed out> Full output: http://webkit-queues.webkit.org/results/6563066
Yousuke Kimoto
Comment 15 2018-02-19 18:35:04 PST
Created attachment 334223 [details] Patch (a rebased version) This patch is a rebased version of attachment 333909 [details].
Yousuke Kimoto
Comment 16 2018-02-19 18:44:10 PST
Created attachment 334224 [details] Patch (a rebased version)
WebKit Commit Bot
Comment 17 2018-02-20 00:42:17 PST
Comment on attachment 334224 [details] Patch (a rebased version) Clearing flags on attachment: 334224 Committed r228751: <https://trac.webkit.org/changeset/228751>
Don Olmstead
Comment 18 2018-02-20 11:29:15 PST
Not sure why this didn't get closed automagically.
Radar WebKit Bug Importer
Comment 19 2018-02-20 11:30:46 PST
Note You need to log in before you can comment on or make changes to this bug.