clang-cl is a new compiler from the LLVM project that attempts to be a drop-in replacement for MSVC's cl.exe. It also brings the full power of the LLVM toolchain to Windows.
lld-link is a linker from LLVM that can be used a drop-in replacement for MSVC's link.exe. It runs much faster than the Microsoft linker.
Firefox's build system now supports both clang-cl and lld-link.
First, make sure you have an updated Mozilla source tree, as a number of build system fixes have landed very recently (March 2018).
You will need to obtain a recent build of clang-cl, using one of these options:
mach bootstrapwill download the clang package currently used by automation to your
~/.mozbuild/clangdirectory. Mozilla's build system is able to detect clang-cl binaries in this location. There is no need to change your
- Download a 64-bit release build or trunk snapshot from LLVM. You should allow the installer to put LLVM on your
- Build your own LLVM from source. You must add the build directory to your
PATHor provide a full path in your mozconfig.
Also, for the SDK requirement "Windows 10 SDK (N) for Desktop C++ x86 and x64", N must be 10.0.15063.0. 10.0.16299.0 is not yet supported with clang-cl.
Configuring your build
To build with clang-cl as your compiler, add the following to your mozconfig:
export CC="clang-cl.exe" export CXX="clang-cl.exe"
To build with lld-link as your linker, add the following to your mozconfig:
And then, proceed to build as normal.
Pushing to try
If you would like to use the clang toolchain on your try push, add one or both of the following lines to
. "$topsrcdir/build/mozconfig.clang-cl" . "$topsrcdir/build/mozconfig.lld-link"
These files set the necessary
exports and additionally have logic to find the clang binaries on the automation filesystems.
You can select a different LLVM SVN revision by editing
build/build-clang/clang-win64.json (this file handles 32-bit builds too). When you push the change to try, it will first build that revision of clang (~1hr) and use the resulting compiler to build your code.