Configure and build Fuchsia

This guide provide instructions on how to configure and build Fuchsia on a host machine.

The steps are:

  1. Prerequisites.
  2. Set your build configuration.
  3. Speed up the build (Optional).
  4. Build Fuchsia.

1. Prerequisites

Before you start, check out the following requirements:

Source code setup

Complete the Download the Fuchsia source code guide to download the Fuchsia source code and set up the Fuchsia development environment on your machine.

Hardware requirements

You can build Fuchsia only on a machine with one of the following host architectures:

  • x86-64 Linux (Debian-based distributions only)
  • x86-64 macOS

Note: Windows and ARM64 are not supported.

2. Set your build configuration

Fuchsia's build configuration informs the build system which product to build and which architecture to build for.

To set your Fuchsia build configuration, run the following fx set command:

fx set {{ '<var>' }}PRODUCT{{ '</var>' }}.{{ '<var>' }}BOARD{{ '</var>' }}

Replace the following:

  • PRODUCT: The Fuchsia product that you want to build; for example, core and workstation_eng.
  • BOARD: The architecture of the product; for example, x64 and qemu-x64

The example command below sets a build configuration to core.qemu-x64:

fx set core.qemu-x64

In this example:

  • core is a product with the minimum feature set of Fuchsia, including common network capabilities.
  • qemu-x64 is a board that refers to the x64 architecture of the Fuchsia emulator (FEMU), which is based on the open source emulator QEMU{:.external}.

On the other hand, the example below sets the build configuration to workstation_eng.x64, which is commonly used to install Fuchsia's Workstation product on a device:

fx set workstation_eng.x64

For more information on the build configuration, see Configure a build.

3. Speed up the build (Optional)

Note: This step is not required to build Fuchsia, but it's recommended since it can save you a lot of time when you build Fuchsia.

To speed up the Fuchsia build, you can use one of the following services:

Enable Goma

Goma{:.external} is a distributed compiler service for open source projects such as Chrome, Android and Fuchsia.

If you have access to Goma, enable a Goma client on your machine:

fx goma

Install ccache

If you do not have access to Goma, but want to accelerate the Fuchsia build locally, use ccache{:.external} to cache artifacts from previous builds.

  • {Linux}

    To use ccache on Linux, install the following package:

    sudo apt install ccache
  • {macOS}

    For macOS, see Using CCache on Mac{:.external} for installation instructions.

ccache is enabled automatically if your CCACHE_DIR environment variable refers to an existing directory.

To override this default behavior, specify the following flags to fx set:

  • Force the use of ccache even when other accelerators are available:

  • Disable the use of ccache:

4. Build Fuchsia

The fx build command executes the build to transform source code into packages and other build artifacts.

To build Fuchsia, run the following command:

Note: Building Fuchsia can take up to 90 minutes.

fx build

When you modify source code, run the fx build command again to perform an incremental build, or run the fx -i build command to start a watcher, which automatically builds whenever you update the source code.

For more information on building Fuchsia, see Execute a build.

Next steps

To launch the Fuchsia emulator (FEMU) on your machine, see Start the Fuchsia emulator.

However, if you want to run Fuchsia on a hardware device, see Install Fuchsia on a device instead.