Bug 231749 - Realize Mac CMake build of WebCore and WebKit
Summary: Realize Mac CMake build of WebCore and WebKit
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CMake (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ross Kirsling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-14 10:57 PDT by Ross Kirsling
Modified: 2021-10-15 17:44 PDT (History)
20 users (show)

See Also:


Attachments
Patch (56.73 KB, patch)
2021-10-14 10:58 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (65.42 KB, patch)
2021-10-14 13:35 PDT, Ross Kirsling
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (28.69 KB, patch)
2021-10-14 14:03 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (30.49 KB, patch)
2021-10-14 15:30 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (33.51 KB, patch)
2021-10-15 15:14 PDT, Ross Kirsling
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (31.13 KB, patch)
2021-10-15 15:26 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch for landing (27.67 KB, patch)
2021-10-15 17:05 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Kirsling 2021-10-14 10:57:48 PDT
Realize full Mac CMake build
Comment 1 Ross Kirsling 2021-10-14 10:58:44 PDT
Created attachment 441239 [details]
Patch
Comment 2 Ross Kirsling 2021-10-14 10:59:33 PDT
It lives! (Patch is based off of the one in bug 225070.)
Comment 3 EWS Watchlist 2021-10-14 10:59:57 PDT
Note that there are important steps to take when updating ANGLE. See https://trac.webkit.org/wiki/UpdatingANGLE
Comment 4 Ross Kirsling 2021-10-14 13:35:50 PDT
Created attachment 441272 [details]
Patch
Comment 5 Ross Kirsling 2021-10-14 13:39:16 PDT
This certainly can't land with the #if 1 in Tools/MiniBrowser/mac/WK1BrowserWindowController.h, but the error there is weird, as its #imports of WKL things are conflicting with WebKit.framework headers:

> In file included from .../Tools/MiniBrowser/mac/WK1BrowserWindowController.m:34:
> In file included from .../WebKitBuild/Release/WebKitLegacy/Headers/WebKitLegacy/WebPreferencesPrivate.h:1:
> In file included from .../Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h:29:
> In file included from .../WebKitBuild/Release/WebKitLegacy/Headers/WebKitLegacy/WebPreferences.h:1:
> .../Source/WebKitLegacy/mac/WebView/WebPreferences.h:167:38: error: property has a previous declaration
> @property (nonatomic, strong) NSURL *userStyleSheetLocation;
>                                      ^
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebPreferences.h:167:38: note: property declared here
> @property (nonatomic, strong) NSURL *userStyleSheetLocation;
>                                     ^
Comment 6 Alex Christensen 2021-10-14 13:45:33 PDT
Comment on attachment 441272 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=441272&action=review

> Source/JavaScriptCore/PlatformMac.cmake:-40
> -set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-compatibility_version 1 -current_version ${WEBKIT_MAC_VERSION} -force_load ${CMAKE_BINARY_DIR}/lib/libWTF.a -force_load ${CMAKE_BINARY_DIR}/lib/libbmalloc.a")

As strange as it is, this needs to stay.

> Source/WebCore/PlatformMac.cmake:-941
> -set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-compatibility_version 1 -current_version ${WEBKIT_MAC_VERSION} -force_load ${CMAKE_BINARY_DIR}/lib/libPAL.a")

ditto

> Tools/WebKitTestRunner/mac/TestControllerMac.mm:73
> +static NSMenu *gCurrentPopUpMenu = nil;

This could be a WeakObjCPtr
Comment 7 Ross Kirsling 2021-10-14 14:03:47 PDT
Created attachment 441276 [details]
Patch
Comment 8 Ross Kirsling 2021-10-14 14:05:59 PDT
Okay, so judging from EWS, the Tools changes I was working with might have been based on false assumptions, so I'm stashing those for now and we can focus on just having WebCore and WebKit fully buildable for this patch.
Comment 9 Don Olmstead 2021-10-14 14:46:50 PDT
(In reply to Alex Christensen from comment #6)
> Comment on attachment 441272 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=441272&action=review
> 
> > Source/JavaScriptCore/PlatformMac.cmake:-40
> > -set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-compatibility_version 1 -current_version ${WEBKIT_MAC_VERSION} -force_load ${CMAKE_BINARY_DIR}/lib/libWTF.a -force_load ${CMAKE_BINARY_DIR}/lib/libbmalloc.a")
> 
> As strange as it is, this needs to stay.
> 
> > Source/WebCore/PlatformMac.cmake:-941
> > -set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-compatibility_version 1 -current_version ${WEBKIT_MAC_VERSION} -force_load ${CMAKE_BINARY_DIR}/lib/libPAL.a")
> 
> ditto

The OBJECT libraries are a cross platform way of doing GCC's `--whole-archive` flag, which `-force_load` is roughly equivalent to. When there's an OBJECT library it just builds out all the .o files. Then in this case the .o files for bmalloc and WTF get linked into JavaScriptCore and the .o files for PAL get linked into WebCore. If this behavior wasn't working then there would be linker errors.
Comment 10 Don Olmstead 2021-10-14 15:00:29 PDT
Comment on attachment 441276 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=441276&action=review

> Source/cmake/WebKitMacros.cmake:245
> +        if (APPLE)

Ross can you add a FIXME here for https://bugs.webkit.org/show_bug.cgi?id=231774

This was done to prevent WebCore from ending up in the `_LIBRARIES` when using the `-umbrella` flag which was causing a linker error but I have some ideas on how to better handle this which I want to try out in that linked bug.
Comment 11 Ross Kirsling 2021-10-14 15:30:02 PDT
Created attachment 441294 [details]
Patch
Comment 12 Alexey Proskuryakov 2021-10-14 16:43:50 PDT
Comment on attachment 441294 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=441294&action=review

> Source/WebCore/Modules/applepay/ApplePaySetupWebCore.h:30
> +#include "ActiveDOMObject.h"

ApplePaySetupWebCore.h is a private header, so this is still not OK.
Comment 13 Don Olmstead 2021-10-14 16:46:41 PDT
Comment on attachment 441294 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=441294&action=review

>> Source/WebCore/Modules/applepay/ApplePaySetupWebCore.h:30
>> +#include "ActiveDOMObject.h"
> 
> ApplePaySetupWebCore.h is a private header, so this is still not OK.

Its my understanding that WebCore doesn't have any public headers only private so this would be a valid change.

Did something change here?
Comment 14 Alexey Proskuryakov 2021-10-14 17:07:16 PDT
"Private" means that it's not part of public Xcode SDK, but unlike "Project" headers, these are part of internal SDK.

I do see that there is another non-framework-style include next to this one, and I don't know why exactly this works, but it's still a problem with CMake build as proposed if it requires to use the wrong include form.
Comment 15 Ross Kirsling 2021-10-14 17:25:45 PDT
This is in fact the *only* file under WebCore/Modules with a `<WebCore/...>` include, so it certainly looks like a mistake...
Comment 16 Ross Kirsling 2021-10-15 11:51:47 PDT
(In reply to Ross Kirsling from comment #15)
> This is in fact the *only* file under WebCore/Modules with a `<WebCore/...>`
> include, so it certainly looks like a mistake...

In fact, it and testing/cocoa/WebViewVisualIdentificationOverlay.h are the only files in the whole of WebCore which are doing this in the Mac build.

My understanding is that a <WebCore/...> include is only used to consume a framework from the outside, so fixing this syntax should be desirable even without talking about CMake.
Comment 17 Ross Kirsling 2021-10-15 15:14:53 PDT
Created attachment 441436 [details]
Patch
Comment 18 Ross Kirsling 2021-10-15 15:15:51 PDT
I have split out source changes from this patch; we can continue that discussion in a separate non-CMake-related ticket.
Comment 19 Ross Kirsling 2021-10-15 15:26:14 PDT
Created attachment 441439 [details]
Patch
Comment 20 Alexey Proskuryakov 2021-10-15 16:50:00 PDT
Comment on attachment 441439 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=441439&action=review

> Source/WebKit/ChangeLog:11
> +        * SourcesCocoa.txt:
> +        * WebKit.xcodeproj/project.pbxproj:

Could you please add an explanation for this change? As it's the only non-CMake change here, I'm just curious.
Comment 21 Ross Kirsling 2021-10-15 17:01:16 PDT
(In reply to Alexey Proskuryakov from comment #20)
> Comment on attachment 441439 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=441439&action=review
> 
> > Source/WebKit/ChangeLog:11
> > +        * SourcesCocoa.txt:
> > +        * WebKit.xcodeproj/project.pbxproj:
> 
> Could you please add an explanation for this change? As it's the only
> non-CMake change here, I'm just curious.

Platform/IPC/cocoa/ sources are listed in SourcesCocoa.txt except for this one which was added as "Sources" in Xcode instead. A hackier temporary solution would be to list this one file in PlatformMac.cmake instead, to avoid editing the xcodeproj -- I suppose I could do that for this patch, because there are other files which ought to be moved similarly in a subsequent patch.
Comment 22 Ross Kirsling 2021-10-15 17:05:09 PDT
Created attachment 441456 [details]
Patch for landing
Comment 23 EWS 2021-10-15 17:44:17 PDT
Committed r284298 (243096@main): <https://commits.webkit.org/243096@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 441456 [details].