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

The steps are:

1. [Prerequisites](https://fuchsia.dev/fuchsia-src/get-started/build_fuchsia#prerequisites).
2. [Set your build configuration](https://fuchsia.dev/fuchsia-src/get-started/build_fuchsia#set-your-build-configuration).
3. [Speed up the build (Optional)](https://fuchsia.dev/fuchsia-src/get-started/build_fuchsia#speed-up-the-build).
4. [Build Fuchsia](https://fuchsia.dev/fuchsia-src/get-started/build_fuchsia#build-fuchsia).

## Prerequisites

This guide requires the following prerequisite items:

- [Source code setup](https://fuchsia.dev/fuchsia-src/get-started/build_fuchsia#source-code-setup)
- [Hardware requirements](https://fuchsia.dev/fuchsia-src/get-started/build_fuchsia#hardware-requirements)

### Source code setup

**Complete the [Download the Fuchsia source code](https://fuchsia.dev/docs/get-started/get_fuchsia_source) guide.**
This guide helps you download the Fuchsia source code and set up the Fuchsia
development environment on your host machine.

### Hardware requirements

You can build Fuchsia on a host machine with the x86-64 Linux architecture
(Debian-based distributions only).

**Windows and macOS are not supported.**

## Set your build configuration

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

To set your Fuchsia build configuration, run the following
[`fx set`](https://fuchsia.dev/reference/tools/fx/cmd/set) command:

    fx set PRODUCT.BOARD

Replace the following:

- `PRODUCT`: The Fuchsia product that you want to build; for example, `core` and `workbench_eng`.
- `BOARD`: The board configuration; for example, `x64` or `qemu-arm64`.

> [!IMPORTANT]
> **Important:** The generic `arm64` board configuration does not support running in the emulator because it is configured for physical target hardware. To build a Fuchsia image for the emulator on an ARM64 host, or to emulate an ARM64 target, you must use the `qemu-arm64` board configuration (for example, `terminal.qemu-arm64`).

The example command below sets the build configuration to `core.x64`:

    fx set core.x64

- `core` is a product with the minimum feature set of Fuchsia, which includes network capabilities.
- `x64` is a board that can run on a wide range of x64 devices, including the Fuchsia emulator ([FEMU](https://fuchsia.dev/docs/get-started/set_up_femu)).

On the other hand, the example below sets the build configuration to
[`workbench_eng.x64`](https://fuchsia.dev/docs/development/build/build_workbench):

    fx set workbench_eng.x64

The lists of possible [boards](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/boards/) and [products](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/products/) are aggregated
from the root of the Fuchsia source repository. For more information, see
[Configure a build](https://fuchsia.dev/docs/development/build/fx#configure-a-build).

## Speed up the build (Optional)

> [!NOTE]
> **Note:** This step is **not required** for building Fuchsia.

To accelerate the Fuchsia build locally, use [`ccache`](https://ccache.dev/)
to cache C and C++ artifacts from previous builds.

Install the `ccache` package:

    sudo apt install ccache

`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:

      fx set PRODUCT.BOARD --ccache

- Disable the use of `ccache`:

      fx set PRODUCT.BOARD --no-ccache

## Build Fuchsia

The [`fx build`](https://fuchsia.dev/reference/tools/fx/cmd/build) command executes the build to transform
source code into packages and other build artifacts.

To build Fuchsia, run the following command:

    fx build

> [!NOTE]
> **Note:** Building Fuchsia can take up to 90 minutes.

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](https://fuchsia.dev/docs/development/build/fx#execute-a-build).

## Next steps

To launch the Fuchsia emulator (FEMU) on your machine, see
[Start the Fuchsia emulator](https://fuchsia.dev/docs/get-started/set_up_femu).

However, if you want to run Fuchsia on a hardware device, see
[Install Fuchsia on a device](https://fuchsia.dev/docs/development/hardware/README) instead.
[](https://issues.fuchsia.dev/issues/new?component=1439230&template=1881640&description=Issue+on:+https://fuchsia.dev/docs/get-started/build_fuchsia.md "Report a bug or suggest improvements on this page") [](https://cs.opensource.google/fuchsia/fuchsia/+/main:docs/get-started/build_fuchsia.md "View the source code of this page") [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/get-started/build_fuchsia.md&cloneRepo=fuchsia/fuchsia:refs/heads/main&fullPath=fuchsia/docs/get-started/build_fuchsia.md "Edit the source code of this page")