Compiling Frida on Fedora

Compiling Frida can seem to be a bit daunting, with over two thousand lines of Makefile, and that is without even beginning to look at the shell scripts in there. This complexity is there for a reason, Frida needs to be run on over a dozen of build targets, many of which are not proper building environments. The make files you are looking at are mostly for this reason1. But luckily, Frida itself use Meson, a modern, sane build system, for the actual building. Not only that, but Frida vendor all of its dependencies with a Meson version to simplify building it even further!

I wrote a small Sourcehut Builds configuration file to build it on the rawhide Fedora version. It should be possible to build it with the stable version of Fedora but a newer version of Meson is required. The listed dependencies at the top of the configuration file is for everything but I will explain about them below. I tried to keep the configuration simple so there are only 5 build steps: Frida gum, Vala, Glib, Frida core and the Python bindings.

Frida Gum

Frida gum is the part being injected into the process we want to debug. It contain APIs to interact with the running process and a JavaScript runtime so we could write our code in something other than C. Building Frida Gum is straightforward, requiring only a few dependencies, the rest it will build on its own.

The build steps are standard to Meson: setup, compile and install.

Frida Core

Here is where things get a bit confusing, because we have to use some downstream patches that are not being handled automatically by our build system. Frida Core depends on a patched version of Vala and GLib so we need to build them first.

Vala

Vala compiler is self-hosted so we need Vala before we can compile Vala. There is a more complicated bootstrap process but for our purpose we can use the upstream Vala compiler. Other dependencies are flex and bison, which I won’t go into detail here.

GLib

Compiling GLib is quite simple and we already have all of the dependencies. It use Meson and gcc just like Frida Gum so we don’t need to modify the dependencies list.

Core

Now that we have the required compiler and glib versions, we can compile Frida Core itself. Sadly, unlike the rest of the projects we’ve compiled so far, Frida Core won’t handle all of the dependencies itself, there is because an open issue with the build system. But don’t worry, it just means we need to install a few additional dependencies: gee-0.8, libbrotlidec and libbrotlienc, gcc, gcc-g++ and npm.

Frida Python

The python bindings depends on Frida core but once it’s installed, all we need is the Python header files and gcc.


  1. It does actually do a couple of additional actions like downloading a pre-built SDK. ↩︎