Constellation Scorpius

Technical notes

How to Build JavaScriptCore on Your Machine

TL;TR

1
Tools/Scripts/build-webkit --jsc-only

JSCOnly port

WebKit JavaScriptCore (JSC) is a high quality JavaScript engine that is used in many production-quality software. The performance of JSC is comparable to the other JavaScript engines like V8, and SpiderMonkey 1. And its spec conformance reaches 99% in ES6 compat-table 2.

While JSC is responsible to the JavaScript engine part in WebKit, the standalone JavaScript engine cannot be built easily. As a same to V8 and SpiderMonkey, JSC also provides the standalone shell to test itself. In OS X environment, the JSC shell can be built with the command Tools/Scripts/build-jsc without doing nothing before. However, in the other ports (EFL and GTK), we need to build WebKit’s dependencies despite these dependent libraries are not necessary to JSC. Building the dependent libraries takes much time since it includes many fundamental libraries, glib, gtk+, cairo, mesa and so on. In addition, once the dependent libraries are updated, which is noted in jhbuild.modules, we need to rebuild these libraries.

The dependent libraries become obstacles in many cases. For example, if you need to build the old revision of JSC to confirm the performance regression, we need to rebuild the old dependencies for that. Another case is testing on the other platform. If you need to build 32bit JSC on Linux, you may set up the LXC container for that. At that time, you need to build all the dependencies to build JSC on the test box even if those dependencies are not related to JSC.

To overcome this situation, we recently introduce a new port JSCOnly 34. The major goal of this port is the followings; (1) providing the platform-independent way to build JSC with significantly fewer dependencies and (2) providing the playground for new aggressive features. JSCOnly port only builds and maintains JSC and its dependent parts, such as WTF, and bmalloc. Since WTF, bmalloc, and JSC are well-written for the Nix environments, we have very few specific part to maintain this port. This port allow us to build JSC on any platforms with significantly less effort.

How to build

The standalone JSC shell in JSCOnly has only one dependent library (ICU), while building process requires some dependencies (like perl, ruby, python, bison, flex etc.). Before building JSC, we need to install these dependencies via your favorite package manager.

1
sudo apt install libicu-dev python ruby bison flex cmake build-essential ninja-build git gperf

Then, build your JSC shell. Of course, you need to check out the WebKit tree.

1
git clone git://git.webkit.org/WebKit.git

And then, build JSC.

1
Tools/Scripts/build-webkit --jsc-only

That’s it.

In addition to that, you can build the JSC shell with the static JSC library.

1
Tools/Scripts/build-webkit --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON"

Comments