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 --prod
optimised? no yes yes, more than in release
maximum RUST_LOG level trace info info
debug assertions? yesyes(!)no
debug info? yesnono
symbols? yesnoyes
finds resources in
current working dir?
yesyesno(!)

There are also two special variants of production builds for performance-related use cases:

  • production-stripped builds are ideal for benchmarking Servo over time, with debug symbols stripped for faster initial startup
  • profiling builds are ideal for profiling and troubleshooting performance issues; they behave like a debug or release build, but have the same performance as a production build
production production-stripped profiling
mach --profile production production-stripped profiling
debug info? nonoyes
symbols? yesnoyes
finds resources in
current working dir?
nonoyes(!)

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