wiki:BuildingCairoOnWindows

Version 93 (modified by Fujii Hironori, 12 months ago) (diff)

--

WebKit Windows port was formally called WinCairo port before Apple Windows port was deprecated. It is using Cairo for the graphics backend, libcurl for the network backend. It supports only 64 bit Windows.

Installing Development Tools

You need CMake, Perl, Python, Ruby, gperf, the latest Windows SDK and Visual Studio 2022 to build Windows port. The easiest way to install some tools is using Chocolatey.

Unfortunately, ActivePerl chocolatey package has a problem and no package maintainer now. XAMPP includes Perl, and running layout tests needs XAMPP. So, let's use XAMPP's Perl.

choco install -y xampp-81 python ruby git cmake gperf

It supports both CMake Ninja generator and CMake Visual Studio generator. Ninja is optional.

choco install -y ninja

WebKit command prompt

To compile, run programs and run tests, you need to set some environment variables. For ease of development, it's recommended to create a batch file to set environment variables and open powershell. Create a batch file with the following content with modifying for your PC, and put it in the top source directory, and double-click it to open powershell.

@echo off
cd %~dp0

path C:\xampp\apache\bin;%path%
path C:\xampp\perl\bin;%path%
path C:\Program Files\CMake\bin;%path%
path %ProgramFiles(x86)%\Microsoft Visual Studio\Installer;%path%
for /F "usebackq delims=" %%I in (`vswhere.exe -latest -property installationPath`) do set VSPATH=%%I

set RC_PROJECTSOURCEVERSION=0.0.0.0.0
set WEBKIT_LIBRARIES=%~dp0WebKitLibraries\win
set WEBKIT_OUTPUTDIR=%~dp0WebKitBuild
set WEBKIT_TESTFONTS=%~dp0Tools\WebKitTestRunner\fonts

set DUMPRENDERTREE_TEMP=%TEMP%

rem set http_proxy=http://your-proxy:8080
rem set https_proxy=%http_proxy%

rem set JSC_dumpOptions=1
rem set JSC_useJIT=0
rem set JSC_useDFGJIT=0
rem set JSC_useRegExpJIT=0
rem set JSC_useDOMJIT=0

rem set WEBKIT_SHOW_FPS=1

call "%VSPATH%\VC\Auxiliary\Build\vcvars64.bat"
cd %~dp0
start powershell

You can replace powershell with cmd or wt (Windows Terminal) if you like.

Building

In the WinKit command prompt, invoke build-webkit to start building.

perl Tools/Scripts/build-webkit --release

Ensure you don't have GCC in your PATH, otherwise CMake is going to use GCC and builds will fail.

build-webkit automatically downloads the latest WebKitRequirements from GitHub. It checks the latest WebKitRequirements every time you invoke. I'd like to recommend to use --skip-library-update for incremental build to speed up for the next time.

python Tools\Scripts\update-webkit-wincairo-libs.py
perl Tools\Scripts\build-webkit --release --skip-library-update

The build succeeded if you got WebKit is now built message. Run your MiniBrowser.

WebKitBuild/Release/bin64/MiniBrowser.exe

Building from within Visual Studio

In the WinKit command prompt,

perl Tools/Scripts/build-webkit --release --no-ninja --generate-project-only

Open the generated solution file by invoking devenv command from a WebKit command prompt.

devenv WebKitBuild\Release\WebKit.sln

Build "MiniBrowser" project.

Debugging

WebKit has two logging features, LOG and dataLog.

LOG is documented at Logging in WebKit. WebCore is using LOG. It outputs logs through stderr and OutputDebugString on Windows.

Console applications such like jsc.exe and UI process of WebKitTestRunner, can use stderr. GUI applications (MiniBrowser.exe) and child processes can't use stderr. You have to attach a debugger to see the message of OutputDebugString. You should use Child Process Debugging Power Tool to get messages of child processes.

dataLog has no documents. It output logs through stderr or a file. It outputs to a file if you set a env var WTF_DATA_LOG_FILENAME. You have to enable JSC logging by set env vars, for example:

set JSC_logGC=2

Required Libraries

You will get required libraries downloaded automatically when you perform a build-webkit. The source code is hosted in: https://github.com/WebKitForWindows/WebKitRequirements

Running the tests

Install XAMPP as described above.

Install required Python and Ruby modules.

pip install pywin32
gem install webrick

If Apache service is running, stop it.

net stop apache2.4

Some extensions need to be registered as CGI. Modify the following commands for your Perl an Python paths, and run them as administrator.

reg add HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI\Command /ve /d "c:\xampp\perl\bin\perl.exe -T"
reg add HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command /ve /d "c:\xampp\perl\bin\perl.exe -T"
reg add HKEY_CLASSES_ROOT\.py\Shell\ExecCGI\Command /ve /d "c:\Python311\python.exe -X utf8"

You need openssl.exe in your PATH to run wpt server. XAMPP contains openssl.exe in C:\xampp\apache\bin directory. Append the directory to your PATH.

Open the WinKit command prompt as administrator because http tests need to run Apache service.

Invoke run-webkit-tests.

python Tools/Scripts/run-webkit-tests --release --wincairo

You can use Docker to run LayoutTests by mounting the host directory.

docker run -it --rm --cpu-count=8 --memory=16g -v %cd%:c:\repo -w c:\repo webkitdev/msbuild

If you are using Japanese Windows, some layout tests fails due to form control size differences. GetStockObject(DEFAULT_GUI_FONT) returns MS UI Gothic on it. Remove GUIFont.Facename of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\GRE_Initialize. And, replace MS UI Gothic with Microsoft Sans Serif in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes\MS Shell Dlg.

If http tests fail as flaky failures due to the socket count limit, increase the user port range. See Bug 224523

netsh int ipv4 set dynamicport tcp start=1025 num=64511

Download build artifacts from Buildbot

  • Unpack them, copy all DLL of WebKitRequirements to the directory of MiniBrowser.exe
  • Install the latest vc_redist.x64.exe of Microsoft Visual C++ Redistributable for Visual Studio

The specified module could not be found

If you simply double-click MiniBrowser.exe to execute, you'd get the following error message.

---------------------------
MiniBrowser can't open.
---------------------------
::LoadLibraryW failed: 
path=C:\path\to\bin64\MiniBrowserLib.dll
The specified module could not be found.

---------------------------
OK   
---------------------------

Due to the useless error message, this is a Windows port FAQ. The error message actually means MiniBrowserLib.dll can't load required DLL of WebKitRequirements. You have to set the env var WEBKIT_LIBRARIES. Or, copy all DLL of WebKitRequirements to the directory of MiniBrowser.exe as explained in the above section.

Compile with Clang

clang-cl builds isn't supported anymore, see Bug 171618.

clang-cl has a problem for /MP support. https://reviews.llvm.org/D52193 It's recommended to use Ninja with clang-cl. Install clang-cl and Ninja.

choco install llvm ninja -y

Open Visual Studio Command Prompt, and invoke the following commands.

set CC=clang-cl
set CXX=clang-cl
perl Tools\Scripts\build-webkit --release --ninja

clang-cl builds are experimental, see Bug 171618 for the current status.