Navigating Unreal Engine’s source code

Navigating the Unreal code base can be… fraught. Last I checked there were over two hundred thousand files to sort through, and you probably only care about one hundred thousand of those at any given time. Haha! After realizing that even Visual Studio’s 2022 Find in Files isn’t quite up to the task, Entrian and Entrian alternatives are the first places to look.

If you’re willing to part with the very reasonable cost, Entrian Source Search is a very solid option. Once you have it installed and pointed at your source directories, pressing Alt-= on any symbol instantly brings up everywhere it’s used.

If you’re on a tighter budget, a reasonable Entrian alternative is vsChromium, which has nearly the same effect, but for the low low price of free and with slightly more configuration required on your part. It was originally made to navigate the ponderous Chromium source, but luckily it plays nicely with Unreal as well. vsChromium uses Ctrl-Shift-: to pop up your search, a slight muscle memory adjustment from Entrian. The easiest way to get started is by taking an existing vs-chromium-project.txt file which is set up for Unreal and putting it next to your solution. Here’s mine:

It’s configured to include most relevant code files, and ignore a few directories which balloon the index (Experimental and ICU) which you could consider removing if those folders pique your interest.

Both of these greatly improve your time spent lost in the desert… but for traversing across large files, these solutions can still feel a bit cumbersome (800 KB MaterialExpressions.cpp?). For this I like to use the handy LiteSearch, which collapses the rest of the file except for lines containing the symbol you have selected with a quick toggle of Ctrl-M, Ctrl-K! Sometimes you just need to see all 52 instances of GetInputType at the same time:

Oh that’s what GetInputType does…

When you’re suitably disgusted, toggling it again puts things back to normal. Sweet relief.

Hopefully this can help you as you hack your way through the wilderness! Good luck out there!

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.