🔗 Building JSC

This exercise is an opportunity for you to gain experience building standalone JSC yourself.

Noteinfo

As mentioned previously, this exercise is entirely optional. It will help to familiarize yourself with the build system, but all other exercises will use custom prebuilt JSC binaries.

Warningwarning

If you haven't already, read through the VM overview to understand the VM / exercise setup.

Use the command exercise run builds in the VM to drop into a base Ubuntu container. Note that like other exercise containers, the home directory is shared with the host.

🔗 1. Get the Code

You can try your luck building the current main git branch, but it may be in a somewhat "broken" state that will end up failing to build. This can be especially relevant on Linux, since macOS / iOS / etc. are the primary use cases.

To increase the likelihood compilation succeeds, you can clone the most recent WebKit-n.n.n tag (list of tags here). If you were building the full GTK MiniBrowser port, you might want to look for a webkitgtk-n.n.n tag.

Noteinfo

On the off chance there are changes in the build system etc., a tag known to have worked with these instructions is WebKit-7618.1.15.14.7

Once you've identified the tag / commit you'd like to use, you can fetch the code:

bash
# Download code git clone https://github.com/WebKit/WebKit.git # Checkout specific version cd WebKit git checkout <branch or hash>
Noteinfo

The git history for full WebKit is relatively large compared to V8. To save disk space and time spent downloading, you can perform a "shallow" clone:

bash
# for new clones git clone --depth=1 --branch <tag> https://github.com/WebKit/WebKit.git # for existing repos git fetch --depth=1 origin <branch or hash> git checkout <branch or hash>

🔗 2. Build

Kick off a release build:

bash
Tools/Scripts/build-webkit --jsc-only --release

Compilation will take a while.

Warningwarning

The VM is not specced as a build box:

  • do NOT attempt a debug build, which requires lots of RAM and will likely DOS the machine
  • similarly, do not attempt building both V8 and JSC at the same time
  • a build can take e.g. 8+ hours, throw it in a tmux/screen session so you can disconnect as needed

🔗 3. Run!

Hopefully your build completes, and you can proudly run your freshly compiled interpreter:

bash
./WebKitBuild/JSCOnly/Release/bin/jsc