Bug 234696 - [Clang][Win] NotificationData.h(47,5): error: reference to 'UUID' is ambiguous
Summary: [Clang][Win] NotificationData.h(47,5): error: reference to 'UUID' is ambiguous
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on: 255567
Blocks: 171618
  Show dependency treegraph
 
Reported: 2021-12-26 13:17 PST by Fujii Hironori
Modified: 2023-07-06 18:11 PDT (History)
5 users (show)

See Also:


Attachments
repro (142 bytes, text/plain)
2021-12-26 17:03 PST, Fujii Hironori
no flags Details
workaround patch (1.24 KB, patch)
2022-03-17 15:40 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch to replace UUID with WTF::UUID (105.30 KB, patch)
2023-04-17 19:46 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2021-12-26 13:17:10 PST
After r287412 (Bug 234571), Clang-cl can't compile WinCairo port.

FAILED: Source/WebCore/CMakeFiles/WebCore.dir/__/__/WebCore/DerivedSources/unified-sources/UnifiedSource-cbdfe323-28.cpp.obj 
C:\PROGRA~1\LLVM\bin\clang-cl.exe (..)UnifiedSource-cbdfe323-28.cpp
In file included from WebCore\DerivedSources\unified-sources\UnifiedSource-cbdfe323-28.cpp:6:
In file included from ..\..\Source\WebCore\Modules/notifications/NotificationData.cpp:27:
..\..\Source\WebCore\Modules\notifications/NotificationData.h(47,5): error: reference to 'UUID' is ambiguous
    UUID notificationID;
    ^
WTF\Headers\wtf/UUID.h(143,12): note: candidate found by name lookup is 'UUID'
using WTF::UUID;
           ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared\rpcdce.h(83,14): note: candidate found by name lookup is 'UUID'
typedef GUID UUID;
             ^
1 error generated.
Comment 1 Fujii Hironori 2021-12-26 17:03:23 PST
Created attachment 447994 [details]
repro
Comment 2 Fujii Hironori 2021-12-26 17:07:39 PST
GCC and MSVC can compile, but Clang can't
https://godbolt.org/z/hfsd5Gxj1

https://stackoverflow.com/q/36204506
https://stackoverflow.com/q/55896837
Comment 3 Radar WebKit Bug Importer 2022-01-02 13:18:19 PST
<rdar://problem/87052994>
Comment 4 Brady Eidson 2022-01-20 12:39:10 PST
We shouldn't have to make WebKit source code worse to handle one misbehaving compiler.

I'd wager we've had to deal with this type of thing in the past - Anybody have any ideas?
Comment 5 Fujii Hironori 2022-03-17 15:40:49 PDT
Created attachment 455038 [details]
workaround patch
Comment 6 Darin Adler 2023-04-04 15:05:21 PDT
Comment on attachment 455038 [details]
workaround patch

I don’t think this is the best workaround.
Comment 7 Fujii Hironori 2023-04-04 15:20:53 PDT
I don't intend to land this patch. Sometimes I have to compile Windows port with clang-cl. I need this small workaround patch in such a case.
The best solution is changing WebKit policy to avoid defining names in the global scope.
Comment 8 Darin Adler 2023-04-05 12:53:53 PDT
OK, but we don’t have consensus on that.


Outside WTF, WebKit coding style absolutely does *not* support adding any identifiers to the global scope.

WTF has an approach where it uses a namespace to avoid link-time conflicts, but it *does* pull identifiers into global scope. Changing that WTF approach would be a *big* deal, and is not going to be decided based on a single identifier or bug. So if you’d like us to move in that direction, it would be good to start the discussion.

As I said we should not try to settle that here, but my first thought is that I think that since we used a short namespace name, WTF, we *could* consider making that change, but it would have far-reaching implications in code style. Writing WTF::String every time instead of just String. But maybe we could get some of the same benefit from importing these names into each of the WebKit namespaces like you did here?
Comment 9 Fujii Hironori 2023-04-05 13:22:28 PDT
I'm proposing removing MSVC support by switch to clang-cl for WinCairo developers. But, some developers disagree.
So, this problem isn't so important now.
I think the simplest solution might be adding "using namespace WTF;" in all other namespaces.
Comment 10 Fujii Hironori 2023-04-16 18:05:26 PDT
(In reply to Fujii Hironori from comment #9)
> So, this problem isn't so important now.

I'm going to revive clang-cl builds for Windows port.
This problem is important now.

> I think the simplest solution might be adding "using namespace WTF;" in all
> other namespaces.

This approach doesn't work. WTF::HashTable and JSC::HashTable conflict.
Source/JavaScriptCore/runtime/Lookup.h
Comment 11 Fujii Hironori 2023-04-16 21:53:57 PDT
I misunderstood. "using namespace WTF;" in each namespace can't solve this problem.
Comment 12 Fujii Hironori 2023-04-16 22:03:48 PDT
Pull request: https://github.com/WebKit/WebKit/pull/12784
Comment 13 EWS 2023-04-17 15:32:36 PDT
Committed 263042@main (16e36e6bc5e6): <https://commits.webkit.org/263042@main>

Reviewed commits have been landed. Closing PR #12784 and removing active labels.
Comment 14 WebKit Commit Bot 2023-04-17 17:52:36 PDT
Re-opened since this is blocked by bug 255567
Comment 15 Yusuke Suzuki 2023-04-17 17:58:05 PDT
Given that this broke internal build, probably we should stop using `using WTF::UUID`, and always use `WTF::UUID` for this class. Or rename it to some other name.
Comment 16 Fujii Hironori 2023-04-17 19:46:27 PDT
Created attachment 465955 [details]
Patch to replace UUID with WTF::UUID

I created a patch to replace UUID with WTF::UUID, but check-webkit-style complains for this patch.
> ERROR: Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.messages.in:26:  Line contains WTF:: prefix.  [build/messagesin/wtf] [5]

I'm going to create another patch with the first approach and "#if OS(WINDOWS)".
Comment 17 Fujii Hironori 2023-04-17 20:27:29 PDT
Pull request: https://github.com/WebKit/WebKit/pull/12843
Comment 18 Fujii Hironori 2023-07-04 18:39:08 PDT
Pull request: https://github.com/WebKit/WebKit/pull/15553
Comment 19 EWS 2023-07-06 15:18:30 PDT
Committed 265828@main (d8d3aef8dff8): <https://commits.webkit.org/265828@main>

Reviewed commits have been landed. Closing PR #15553 and removing active labels.