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.
- gcc/gcc-g++ - Frida Gum is written in C but there are C++ bindings which we want as well so we will install both gcc and gcc-g++.
- meson - As was mentioned earlier, all Frida projects use Meson as their build system. From this point, assume that everything we compile depends on Meson, even if I won’t say it.
- npm - Frida Compile, which is a modules bundler for Frida, uses NPM.
The build steps are standard to Meson: setup, compile and install.
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 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.
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.
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.
The python bindings depends on Frida core but once it’s installed, all we need is the Python header files and gcc.
It does actually do a couple of additional actions like downloading a pre-built SDK. ↩︎