WebKit on Windows

This guide provides instructions for building WebKit on Windows 8.1 without Cygwin (the AppleWin port of WebKit). You can optionally install Cygwin in order to run tests.

Installing Development Tools

Begin by installing the following programs and setting up your environment:

  1. Visual Studio. (Make sure you include C++ support.) https://www.visualstudio.com/en-us/products/visual-studio-community-vs
  2. ActiveState Perl. 64-bit is fine. http://www.activestate.com/activeperl/downloads
  3. ActiveState Python. Make sure it’s version 2.x instead of 3.x. 64-bit is fine. http://www.activestate.com/activepython/downloads Make sure you don’t download it from python.org because we hardcode the executable name as “python2.7” and the python.org python doesn’t include an executable with that name.
  4. Ruby. 64-bit is fine. http://rubyinstaller.org/
  5. Bison. http://gnuwin32.sourceforge.net/packages/bison.htm Make sure that the installation path does not have spaces in it, because Bison does not correctly quote paths when passing them to m4.
  6. Gperf. http://gnuwin32.sourceforge.net/packages/gperf.htm
  7. Flex. http://gnuwin32.sourceforge.net/packages/flex.htm
  8. CMake. https://cmake.org/download/
  9. Git. http://www.git-scm.com/download/win Note: Make sure you select the option “Use Git from the Windows Command Prompt.” This is because it installs a sh.exe in your path, and if the location of that sh.exe has spaces in it, Make gets confused. When I installed this, I unchecked all the options.
  10. iTunes. This is only needed for the AppleWin port, not for the WinCairo port. http://www.apple.com/itunes/download/ This is needed because it includes the .dlls which implement Apple frameworks like CoreGraphics, CoreAnimation, etc.
  11. The “Ahem” font, used for testing. http://www.w3.org/Style/CSS/Test/Fonts/Ahem/
  12. (Optional: If you intend to interact with Subversion patches) Subversion. http://sourceforge.net/projects/win32svn/
  13. (Optional: To speed up the build process) Ninja Build. https://github.com/ninja-build/ninja/releases

Make sure all the programs you just installed (except Visual Studio and iTunes) are accessible through your $PATH http://www.itechtics.com/customize-windows-environment-variables/ You may be required to reboot after modifying $PATH before new shells will see the updated variable.

If you are behind a proxy, be sure to set the HTTP_PROXY and HTTPS_PROXY environment variables.

Setup the Git Repository

Tell git your name.

> git config --global user.name "John Smith"

Tell git your email address.

> git config --global user.email "johnsmith@example.com"

Download a clone of the repository.

> git clone <git://git.webkit.org/WebKit.git>
> cd WebKit

(Optional: If you intend to interact with Subversion patches)
Automatically configure the local clone to follow Subversion:

> python Tools\Scripts\webkit-patch setup-git-clone

Setup Support Tools

Download the WebKit Support Libraries to the root of your source tree https://developer.apple.com/opensource/internet/webkit_sptlib_agree.html If the file is incorrectly named, rename it to WebKitSupportLibrary.zip. Do not extract its contents. This archive includes an SDK (headers only) for the Windows builds of the Apple stack of software (like CoreGraphics, for example).

In addition, you will need to download https://developer.apple.com/opensource/internet/WebKitAuxiliaryLibrary.zip

> cd Tools\Scripts
> perl update-webkit

If the above command asks you to reboot your machine, do so.

Note that this command will automatically download WebKitAuxiliaryLibrary.zip from Apple and extract it into your tree (inside the WebKitLibraries folder). This archive includes Windows builds of all the public libraries that WebKit depends on (like libxml2). Note also that this command might set environment variables.

Build WebKit

> perl build-webkit 

Note that this command will automatically extract WebKitSupportLibrary.zip (which you downloaded in step 6) into your tree (inside the WebKitLibraries folder).

Install Cygwin (optional)

You can build with either Visual Studio 2015 or Visual Studio 2015 Community Edition.

Use the default options for the installation.

Cygwin is a collection of utilities for Windows that includes not only a Subversion client, but also additional tools that are required to build the

WebKit source. We have made a downloader available that automatically collects all of the required packages.

Download cygwin-downloader.zip. Extract the content of the archive to some folder and start cygwin-downloader.exe from that folder. This will download all the Cygwin packages you need. When all the packages have finished downloading, the Cygwin installer will launch. Choose Install from Local Directory, then click Next until the install is complete. If you are running Vista, the installer won’t be able to launch automatically, so you will have to manually launch Cygwin’s Setup.exe.

Note: If you are behind a proxy you need to set the HTTP_PROXY environment variable to the URL of the proxy. This would likely match this pattern: http[s]://[username[:password]@]somehost.com[:port]. The square brackets ([…]) are not part of the URL, but are used to indicate optional elements of the URL.
Note: Vista may warn you that Cygwin did not install correctly. Ignore this warning and tell Vista that the install was successful.
Warning: If you are running Vista or Windows 7, Cygwin may have trouble with implementing fork (the POSIX function frequently used to start child processes, needed by many of the WebKit build tools). In order to enable cygwin1.dll to implement fork successfully it is better if no DLL loaded in the parent process is relocated at runtime. One way to achive this is to rebase all cygwin dlls except cyglsa64.dll and cygwin1.dll to base addresses that cause them to not overlap in memory.

In order to rebase all cygwin dlls a rebaseall script is provided in the cygwin installation’s bin directory (usually C:\cygwin\bin). This script must be run from ash.exe (found in the same directory) while no other cygwin application is running.

ash.exe has very limited command line editing features so cutting and pasting to the commandline is recommended.
The PATH environment variable may not contain the /bin directory by default thus the script should be launched as /bin/rebaseall.
If rebaseall is complaining about failure to write to a Windows Temp directory (i.e. /cygdrive/c/Users/you/AppData/Local/Temp), fix the permissions on that folder (i.e. /bin/chown you /cygdrive/c/Users/you/AppData/Local/Temp) or change the TMP environment variable to point to a directory with the appropriate permission flags

(i.e.: export TMP=/tmp). Note: The rebase process may need to be repeated to include any new libraries added later to cygwin by listing these libraries by full cygwin path in a file and passing the file to rebaseall via the -T fileName commandline argument. The dlls under LayoutTests/http/conf are a relevant use case.

Remove the following lines from /home/[username]/.bashrc (if present):

unset TMP
unset TEMP

Those lines would prevent picking up the Windows TMP and TEMP environment variables.

If you are behind a proxy you need to do the following to allow cygwin svn to get through the proxy (similar steps are available for your Windows svn):

  • In bash (Cygwin) run: svn help. This will create in your cygwin home directory the file .subversion/servers.
  • Edit the file mentioned above and follow the instructions in the file to set up your proxy settings.

Install Perl
Download Perl 5.18 (or newer) from activestate.com and install it.

Install Python
Download Python 2.7.8 from activestate.com and install it.

Install Ruby
Download Ruby 2.0.0 from rubyinstaller.org and install it.

Install php, we use the following steps (you need this to run http layout tests):
1. cd /usr/local/bin
2. wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
3. chmod a+x apt-cya
4. Change line 341 of the apt-cya script to wget -nc $mirror/../$install
5. apt-cyg -m ftp://sourceware.org/pub/cygwinports/x86 install php

Optional: Hotfix for 64-bit Windows (Windows 7 or earlier) to disable the user-mode callback filter for exceptions

Without the 976038 hotfix, exceptions may be thrown in callback routines that do not cause a crash but leave the application in an inconsistent state that might cause a crash later. You will need to click on “View and request hotfix downloads” and fill out the form. A link to download the hotfix and a password will be emailed to you.

Getting the Code for Cygwin

  1. Open a Cygwin Shell Double-click the Cygwin icon on your Desktop to launch a new shell.
  2. You can download a snapshot of the WebKit source tree. It is updated daily.

Type these commands to check out the WebKit source tree:

tar jxvf WebKit-SVN-source.tar.bz2
cd webkit

Note the archived checkout uses an HTTP connection. We recommend running the following command to use HTTPS instead:

svn switch --relocate http://svn.webkit.org/repository/webkit/trunk https://svn.webkit.org/repository/webkit/trunk

Alternatively, type this command to check out the WebKit source tree:

svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit
  1. Install the WebKit Support Libraries

    Download the WebKit Support Libraries to the root of your source tree (C:\cygwin\home\<username>\WebKit).

    If the file is incorrectly named, rename it to WebKitSupportLibrary.zip. Do not extract its contents.

  2. Run the ./Tools/Scripts/update-webkit script to update your source tree.

    If you downloaded the tarball, this will bring it up to date. Windows users must always execute this command after first obtaining the code, since it will download additional libraries that are needed to build.

Once you have a current tree, the next step is building WebKit.

Getting a Crash Log

Windows Error Reporting (WER) has been integrated into the operating system. By default, Windows uploads the crash logs to Microsoft, but does not save a local copy. This is configurable via the registry.

  1. Save the following text to a file named wer.reg: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting] "ForceQueue"=dword:00000001
  2. Double-click the file from Windows Explorer and respond affirmatively to any prompts.
  3. Reboot

The next time Safari (or any other application) crashes, the crash information will be written into a folder located inside %LOCALAPPDATA%\Microsoft\Windows\WER\ReportQueue. Check the modification date to make sure you are using the correct file. Be sure to include the following files in your bug report:

WER_xxxx_.tmp.mdmp
This is the most important file. It contains the crash dump that can be opened inside Visual Studio or other Windows debuggers.
WER_xxxx_.tmp.version.txt
Contains the operating system version and other hardware information.
WER_xxxx_.tmp.appcompat.txt
Lists all of the DLLs loaded at the time of the crash with their version information.