Building

Table of contents

  1. Building Frida
  2. Building the toolchain and SDK

Building Frida

Design Constraints

Frida has a fairly complex build system due to some design constraints:

  • Short build time for new contributors. Frida downloads a prebuilt toolchain and SDK to save time. This requires a bit more fiddling to get the build environment just right, but it has the added benefit of providing a coherent build environment.

  • No moving parts. The final binary must be self-contained/portable. Some of Frida’s run-time components, like frida-helper, frida-agent, etc. may at some point need to be present on the filesystem. These binaries are serialized and linked into the Frida library (for example _frida.so in the case of frida-python), which means it’s portable without relying on external moving parts. At runtime these are written out to a temporary directory and later cleaned up.

  • No runtime conflicts. frida-agent, the shared library injected into target processes, must have all of its dependencies (GLib, Gee, etc.) linked in to avoid runtime conflicts with target applications that happen to use the same libraries. Because of this, these libraries are compiled as static libraries.

  • No resource leaks. frida-agent, the shared library injected into target processes, should not allocate any OS resources without releasing them when it is unloaded to avoid accumulating leaks in long-lived processes. Because Frida is mostly written in C and makes use of the excellent GLib library, which unfortunately doesn’t provide any way to fully clean up statically allocated resources, we had to patch that library to add support for this. Upstream doesn’t consider this a valid use-case, so unfortunately we need to maintain our fork of this library. This means we can’t make use of a system-wide GLib on GNU/Linux systems, which consequently makes the prebuilt SDK a bit larger.

Frida’s build system tries to keep you sane by making use of a prebuilt toolchain and SDK for each platform. This is what’s used in the steps outlined below.

GNU/Linux

  • Make sure you have a:
    • Modern x86 system with GCC 7.5 or newer
    • Development toolchain, and Node.js on your PATH. E.g. on Ubuntu 20.04:
$ sudo apt-get install build-essential curl git lib32stdc++-9-dev \
    libc6-dev-i386 nodejs npm python3-dev python3-pip
  • Clone frida and build it:
$ git clone --recurse-submodules https://github.com/frida/frida.git
$ cd frida
$ make

Running make will provide you a list of modules to build. See the hacking page for more information.

macOS

  • Make sure you have:
  • Clone frida and build it:
$ git clone --recurse-submodules https://github.com/frida/frida.git
$ cd frida
$ make

Running make will provide you a list of modules to build. See the hacking page for more information.

Windows

  • Make sure you have:
    • Visual Studio 2022
    • Git on your PATH
    • Python 3.10 on your PATH
      • Select Add Python 3.10 to PATH
      • Set the installation directory to C:\Program Files\Python310\, or edit releng\frida.props to change the PythonLocation values there.
    • Node.js on your PATH
  • Clone the frida repository:
$ git clone --recurse-submodules https://github.com/frida/frida
  • Open frida.sln and build it.

Building the toolchain and SDK

This should not be necessary unless you’re porting Frida to a new platform. The following steps assume you have the OS-specific prerequisites mentioned above.

UNIX Toolchain and SDK

  • Make sure your system has the following goodies:
$ sudo apt-get install bison flex gperf
  • Clone the frida repository and build away:
$ git clone --recurse-submodules https://github.com/frida/frida
$ cd frida
$ make -f Makefile.toolchain.mk
$ make -f Makefile.sdk.mk FRIDA_HOST=linux-x86_64
  • Transfer the resulting toolchain and SDK to a web server somewhere:
$ scp build/toolchain-*.tar.bz2 [email protected]:
$ scp build/sdk-*.tar.bz2 [email protected]:
  • Now you can clone frida like above and adjust the URLs in releng/setup-env.sh (look for download_command) before running make. You can also copy the files into build/ and they’ll be picked up instead of attempting to download them.

Windows Toolchain and SDK

  • Clone the frida repository and build away:
$ git clone --recurse-submodules https://github.com/frida/frida
$ cd frida
$ python releng\build-deps-windows.py
  • Transfer the resulting toolchain and SDK to a web server somewhere:
$ scp toolchain-windows-*.exe [email protected]:
$ scp sdk-windows-*.exe [email protected]:
  • Now you can clone frida like above and adjust BUNDLE_URL in releng\deps.py before opening frida.sln. You can also copy the files into build\ and they’ll be picked up instead of attempting to download them.