How to Use Firebuild: Your Guide to Automatic Build Acceleration

Jul 18, 2021 | Programming

Welcome to the world of Firebuild, an innovative tool designed to make your build processes faster and more efficient! In this tutorial, we’ll guide you through the key features, usage, and installation of Firebuild, providing you with all the necessary insights to get started.

What is Firebuild?

Firebuild is an automatic build accelerator that caches the outputs of executed commands. When the same commands are executed with identical parameters within the same environment, Firebuild replays the results, drastically reducing build times. Whether it’s compilation, test stages, or any command yielding predictable output, Firebuild has you covered. The caching behavior is determined by a configuration file, enhancing the efficiency of your build workflow.

Firebuild logo

Getting Started: Using Firebuild

To use Firebuild, you simply prefix your build command with firebuild like so:

firebuild build command

The first build might be a bit slower (5-10%) due to the initial analysis and cache population. However, subsequent builds can accelerate by a remarkable 5-20 times, depending on the project’s complexity.

Improving Cache Hit Rate

If you notice your hit rate not meeting expectations, you can run Firebuild with:

  • -d proc to analyze which commands can’t be cached.
  • -d shortcut to identify commands that are not shortcutting.

You can also generate a comprehensive report of the build process by using:

firebuild -r build command

This report helps highlight the slowest parts of your build process and identify non-shortcutting commands.

Considerations for Clang

When using Clang, be mindful that it embeds timestamps in precompiled headers (PCHs) by default, which can interfere with caching. To resolve this, you can disable timestamps with:

-Xclang -fno-pch-timestamp

Comparison with Other Build Accelerators

Firebuild stands out from other build accelerators such as Ccache and Sccache. While these tools are limited to specific programming languages, Firebuild accelerates commands across a variety of languages, including Fortran, Java, and Scala, making it more versatile and efficient. It consistently surpasses Ccache in real-world testing.

Unlike Bazel, which requires maintenance of its own build system, Firebuild integrates seamlessly with any build system that doesn’t have built-in caching. Simply prefix your command as described earlier!

Firebuild’s Shortcomings

While Firebuild is powerful, it currently does not support:

  • Compressing cache entries
  • Remote caches

Additionally, it cannot intercept or shortcut statically linked binaries due to its method of preloading the library libfirebuild.so.

Installation Instructions

Installing Firebuild is straightforward. You can find it in several distributions:

To install on Ubuntu, use the following commands:

sudo add-apt-repository ppa:firebuild/stable
sudo apt install firebuild

If you’re looking to integrate Firebuild into your GitHub pipeline, there’s also a GitHub Action available.

Building Firebuild from Source

For Linux

If you’re using an older version of Ubuntu (before 21.04), start by adding the build dependencies:

sudo apt-add-repository ppa:firebuild/build-deps
sudo apt update
sudo apt install clang cmake bats bc graphviz libconfig++-dev node-d3 libxxhash-dev libjemalloc-dev libtsl-hopscotch-map-dev moreutils python3-jinja2 fakeroot

Then, build and install it using:

cmake .
make check
sudo make install

For Mac

First, install the build dependencies:

brew bundle

Next, build and install:

cmake .
HOMEBREW_PREFIX=$(ls -d /opt/homebrew /usr/local 2>/dev/null | head -n1)
export XML_CATALOG_FILES=$HOMEBREW_PREFIX/etc/xml/catalog
export PYTHONPATH=$(ls -d $HOMEBREW_PREFIX/Cellar/jinja2-cli*libexec/lib/python*site-packages 2>/dev/null | tail -n1)
make check
sudo make install

Finally, set up your system to allow intercepting builds by visiting this link.

Troubleshooting Firebuild

If you encounter issues while using Firebuild, consider the following troubleshooting steps:

  • Check if the cache hit rate is low by running firebuild -s.
  • Use -d proc or -d shortcut to debug cache-saving issues.
  • Review the generated report with firebuild -r build command to pinpoint bottlenecks.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox