Generating compile_commands.json when building WebKit on MacOS

# shrivatsa at firemail.cc (8 days ago)

dev,

I'm trying to study the structure of web browsers in general and WebKit specifically for academic purposes. I found that using language servers that index compile_commands.json (clangd, ccls etc.) is a very good solution to navigate source code of extremely large projects, such as WebKit.

Unfortunately, I was only able to get compile_commands.json generated when I compiled with --jsc-only where the build is executed using cmake and not the perl script. Trying to pass --cmake as a build argument to build-webkit causes the build to fail pretty early for missing files (that I believe aren't open source).

To wrap it up, I wonder if there's a way to compile WebKit as a browser (and not just JavaScriptCore) and have compile_commands.json generated?

platform: osx arch: x86_64 commit: 521d40b

Thanks,

Contact us to advertise here
# Konstantin Tokarev (8 days ago)

20.07.2020, 13:13, "shrivatsa at firemail.cc" <shrivatsa at firemail.cc>:

Hi webkit-dev,

I'm trying to study the structure of web browsers in general and WebKit specifically for academic purposes. I found that using language servers that index compile_commands.json (clangd, ccls etc.) is a very good solution to navigate source code of extremely large projects, such as WebKit.

Unfortunately, I was only able to get compile_commands.json generated when I compiled with --jsc-only where the build is executed using cmake and not the perl script. Trying to pass --cmake as a build argument to build-webkit causes the build to fail pretty early for missing files (that I believe aren't open source).

No, these files were just removed from tree or renamed recently, and Mac/cmake doesn't have EWS bot so such breakages happen regularly. However, it should be possible to fix such error just by looking at git log for missing file paths and figuring out what happened to respective files, i.e. should the be removed from cmake or replaced with a different file path. Feel free to contribute patches if you happen to fix anything.

# shrivatsa at firemail.cc (6 days ago)

I was able to get the compilation process starting with some changed (patch attached), but now I am facing some errors that I don't know how to tackle, e.g.:

[1218/5220] Building CXX object Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir///DerivedSources/JavaScriptCore/unified-sources/UnifiedSource-d93d10ff-2-mm.mm.o FAILED: Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir///DerivedSources/JavaScriptCore/unified-sources/UnifiedSource-d93d10ff-2-mm.mm.o /usr/local/bin/ccache /usr/local/opt/ccache/libexec/c++
-DBUILDING_JavaScriptCore -DBUILDING_WITH_CMAKE=1 -DHAVE_CONFIG_H=1 -DJavaScriptCore_EXPORTS -DSTATICALLY_LINKED_WITH_WTF -DSTDC_WANT_LIB_EXT1 -IDerivedSources/ForwardingHeaders -I. -I../../Source/JavaScriptCore -I../../Source/JavaScriptCore/API -I../../Source/JavaScriptCore/assembler -I../../Source/JavaScriptCore/b3 -I../../Source/JavaScriptCore/b3/air -I../../Source/JavaScriptCore/bindings -I../../Source/JavaScriptCore/builtins -I../../Source/JavaScriptCore/bytecode -I../../So urce/JavaScriptCore/bytecompiler -I../../Source/JavaScriptCore/dfg -I../../Source/JavaScriptCore/disassembler -I../../Source/JavaScriptCore/disassembler/ARM64 -I../../Source/JavaScriptCore/disassembler/udis86 -I../../Source/JavaScriptCore/domjit -I../../Source/JavaScriptC ore/ftl -I../../Source/JavaScriptCore/heap -I../../Source/JavaScriptCore/debugger -I../../Source/JavaScriptCore/inspector -I../../Source/JavaScriptCore/inspector/agents -I../../Source/JavaScriptCore/inspector/augmentable -I../../Source/JavaScriptCore/inspector/remote -I.. /../Source/JavaScriptCore/interpreter -I../../Source/JavaScriptCore/jit -I../../Source/JavaScriptCore/llint -I../../Source/JavaScriptCore/parser -I../../Source/JavaScriptCore/profiler -I../../Source/JavaScriptCore/runtime -I../../Source/JavaScriptCore/tools -I../../Source /JavaScriptCore/wasm -I../../Source/JavaScriptCore/wasm/js -I../../Source/JavaScriptCore/yarr -IDerivedSources/JavaScriptCore -IDerivedSources/JavaScriptCore/inspector -IDerivedSources/JavaScriptCore/runtime -IDerivedSources/JavaScriptCore/yarr -IDerivedSources -I../../So urce/JavaScriptCore/inspector/cocoa -I../../Source/JavaScriptCore/inspector/remote/cocoa -isystem ICU/Headers -fdiagnostics-color=always -fcolor-diagnostics -Wextra -Wall -Wno-noexcept-type -Wno-parentheses-equality -Qunused-arguments -Wwrite-strings -Wundef -Wpointer-ari th -Wmissing-format-attribute -Wformat-security -Wcast-align
-fno-strict-aliasing -fno-exceptions -fno-rtti -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -fPIC -ffp-contract=off -fno-slp-vectorize -std=c++17 -MD -MT Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir///DerivedSources/JavaScriptCore/unified-sources/UnifiedSource-d93d10ff-2-mm.mm.o -MF Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir///DerivedSources/JavaScriptCore/unified-sources/UnifiedSource-d93d 10ff-2-mm.mm.o.d -o Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir///DerivedSources/JavaScriptCore/unified-sources/UnifiedSource-d93d10ff-2-mm.mm.o -c DerivedSources/JavaScriptCore/unified-sources/UnifiedSource-d93d10ff-2-mm.mm In file included from DerivedSources/JavaScriptCore/unified-sources/UnifiedSource-d93d10ff-2-mm.mm:1: In file included from ../../Source/JavaScriptCore/API/JSWrapperMap.mm:35: In file included from ../../Source/JavaScriptCore/API/JSContextInternal.h:30: In file included from DerivedSources/ForwardingHeaders/JavaScriptCore/JSContextPrivate.h:31: DerivedSources/ForwardingHeaders/JavaScriptCore/JSContext.h:40:1: error: duplicate interface definition for class 'JSContext' @interface JSContext : NSObject ^ ../../Source/JavaScriptCore/API/JSContext.h:40:12: note: previous definition is here @interface JSContext : NSObject ^

Your assistance would be much appreciated.

# Carlos Alberto Lopez Perez (6 days ago)

On 22/07/2020 10:15, shrivatsa at firemail.cc wrote:

Your assistance would be much appreciated.

Perhaps you can try to use the WebKitGTK port for Linux ? CMake support for it is actively maintained and should work without any issue. Check: trac.webkit.org/wiki/BuildingGtk

# Michael Catanzaro (6 days ago)

On Wed, Jul 22, 2020 at 11:15 am, shrivatsa at firemail.cc wrote:

DerivedSources/ForwardingHeaders/JavaScriptCore/JSContext.h:40:1: error: duplicate interface definition for class 'JSContext' @interface JSContext : NSObject ^ ../../Source/JavaScriptCore/API/JSContext.h:40:12: note: previous definition is here @interface JSContext : NSObject ^

Your assistance would be much appreciated.

It might be time to simply remove support for building WebKitGTK on macOS. I imagine it's been many years since anyone has successfully built it.

# Philippe Normand (6 days ago)

On Wed, 2020-07-22 at 08:24 -0500, Michael Catanzaro wrote:

On Wed, Jul 22, 2020 at 11:15 am, shrivatsa at firemail.cc wrote:

DerivedSources/ForwardingHeaders/JavaScriptCore/JSContext.h:40:1: error: duplicate interface definition for class 'JSContext' @interface JSContext : NSObject ^ ../../Source/JavaScriptCore/API/JSContext.h:40:12: note: previous definition is here @interface JSContext : NSObject ^

Your assistance would be much appreciated.

It might be time to simply remove support for building WebKitGTK on macOS. I imagine it's been many years since anyone has successfully built it.

jmercouris on IRC reported yesterday that he got it to build on macOS. IIUC he's working on the macports project.

Philippe

# Adrian Perez de Castro (6 days ago)

Hello,

On Wed, 22 Jul 2020 14:42:07 +0100, Philippe Normand <philn at igalia.com> wrote:

On Wed, 2020-07-22 at 08:24 -0500, Michael Catanzaro wrote:

On Wed, Jul 22, 2020 at 11:15 am, shrivatsa at firemail.cc wrote:

DerivedSources/ForwardingHeaders/JavaScriptCore/JSContext.h:40:1: error: duplicate interface definition for class 'JSContext' @interface JSContext : NSObject ^ ../../Source/JavaScriptCore/API/JSContext.h:40:12: note: previous definition is here @interface JSContext : NSObject ^

Your assistance would be much appreciated.

It might be time to simply remove support for building WebKitGTK on macOS. I imagine it's been many years since anyone has successfully built it.

jmercouris on IRC reported yesterday that he got it to build on macOS. IIUC he's working on the macports project.

That's right; I have been helping them out and encouraging to send patches upstream. The Nyxt [1] browser is using WebKitGTK on MacOS and actively maintained, too.

Cheers, —Adrián


[1] atlas-engineer/nyxt

# shrivatsa at firemail.cc (3 days ago)

Perhaps you can try to use the WebKitGTK port for Linux ?

You mean that I should try to build WebKitGTK port for Linux on macOS or simply move to Linux?

# Carlos Alberto Lopez Perez (21 hours ago)

On 25/07/2020 20:16, shrivatsa at firemail.cc wrote:

Perhaps you can try to use the WebKitGTK port for Linux ? You mean that I should try to build WebKitGTK port for Linux on macOS or simply move to Linux?

In theory it is possible to build the WebKitGTK port on MacOS, but in practice i don't think it will work out the box since its a build configuration that is not tested at build.webkit.org

So, my suggestion is to build the WebKitGTK port on Linux.

Want more features?

Request early access to our private beta of readable email premium.