Building Servo

If this is your first time building Servo, be sure to set up your environment before continuing with the steps below.

To build servoshell for your machine:

$ ./mach build -d

To build servoshell for Android (armv7):

$ ./mach build --android

To check your code for compile errors, without a full build:

$ ./mach check

Sometimes the tools or dependencies needed to build Servo will change. If you start encountering build problems after updating Servo, try running ./mach bootstrap again, or set up your environment from the beginning.

You are not alone! If you have problems building Servo that you can’t solve, you can always ask for help in the build issues chat on Zulip.

Build profiles

There are three main build profiles, which you can build and use independently of one another:

  • debug builds, which allow you to use a debugger (lldb)
  • release builds, which are slower to build but more performant
  • production builds, which are used for official releases only
debug release production
mach option -d -r --profile production
optimised? noyesyes
debug info? yesnono
debug assertions? yesyes(!)no
maximum RUST_LOG level traceinfoinfo
finds resources in
current working dir?
yesyesno

You can change these settings in a servobuild file (see servobuild.example) or in the root Cargo.toml.

Optional build settings

Some build settings can only be enabled manually:

  • AddressSanitizer builds are enabled with ./mach build --with-asan
  • crown linting is recommended when hacking on DOM code, and is enabled with ./mach build --use-crown
  • SpiderMonkey debug builds are enabled with ./mach build --debug-mozjs, or [build] debug-mozjs = true in your servobuild file