FASTBuild with Unreal Engine 4 setup

So you want to build Unreal Engine 4 with FASTBuild… Or maybe you don’t want to pay for Incredibuild but rebuilding Unreal in 45 minutes doesn’t seem promising. You are in the right spot. Here were our steps to building UE4 with FASTBuild on Windows.

  1. Download FASTBuild from here, the latest x64 Windows version most likely. Move the extracted folder to the Engine/Extras folder in Unreal.
  2. Download FASTBuild.cs from here and place under Engine/Source/Programs/UnrealBuildTool/System/. Either add it to the UnrealBuildTool project yourself or regenerate the projects.
  3. Modify the ActionGraph.cs file, specifically the ExecuteActions method, to call FASTBuild.ExecuteActions like so:

    For Unreal Engine before 4.15, it looked more like this:
    In both cases, you can of course also add a bAllowFastBuild bool to BuildConfiguration.cs to control who attempts to use FASTBuild.
  4. Rebuild UnrealBuildTool from Visual Studio.
  5. Build a smaller project, like say ShaderCompileWorker to test it out! It should use FASTBuild, but it won’t build across the network or use the cache without a little bit more setup.

Next you’ll want to set up caching and distribution, as that’s where you’ll actually see the benefits of using FASTBuild!

Using FASTBuild with Unreal Engine 4

Near the end of 2015 we were placed in the unpleasant situation of needing to compile two versions of Unreal Engine without the benefit of the ubiquitously speedy Incredibuild.

To make things worse we on platforms using the lightly poky Microsoft C++ compiler, meaning that changing a core header in Unreal was resulting in compile times of over half an hour.

It did not take many of these changes before we decided something had to be done. Being in Montreal we knew that some studios in the city were using the aptly named distributed build and caching solution FASTBuild. As the universe tends to do, as we were cleaning up our solution it appears someone else was also on the trail of making FASTBuild work with unreal! If we had a time machine… FASTBuild with Unreal would have saved us a bit of trouble.

The end goal for what we did as well as what Carl did was the same: produce a .bff file from the UnrealBuildTool actions.

The Unreal FASTBuild duo has some quirks worth mentioning.

Unreal enjoys its precompiled headers (PCHs), this works as expected in FASTBuild except that Unreal also sometimes links with the PCH object file, and the object file FASTBuild generates does not have the appropriate name. So we have a small modification to FASTBuild which allows us to override the PCH object file name.

Another quirk was that some of the obj files (occasionally in the hundreds of MB) generated are so big that the clients were timing out. Yassine did some profiling and somewhat surprisingly it looks like it’s happening at the Windows socket level with the send call telling us the buffer had no room for very small sends of 8 bytes, just after attempting some sends in the tens of megabytes. Bumping up the timeout from 5 seconds to over a minute got rid of all of these issues, but it was a bit of an annoyance.