Post

Jumbo Builds Is The Prime Suspect!

Jumbo Builds Is The Prime Suspect!

I added six new UI screens to my Unreal Engine project. Empty shells — just controllers and widget classes, barely any logic. I hit compile, and the build exploded with errors in a file I hadn’t touched:

1
2
3
4
5
InputKeyVisualDataAsset.h(20): error C2143: syntax error: missing ';' before '*'
    UTexture2D* Icon = nullptr;
InputKeyVisualDataAsset.h(20): error C4430: missing type specifier - int assumed
InputKeyVisualDataAsset.gen.cpp(81): error C2039: 'Icon': is not a member of 'FInputKeyVisual'
InputKeyVisualDataAsset.gen.cpp(81): error C2618: illegal member designator in offsetof

My first reaction was the universal developer instinct: “But I didn’t even touch that file. Did my new code break something a thousand lines away?”

It turns out, kind of. And the real explanation is a great lesson in how large C++ projects actually compile.

The actual bug

Here’s the offending line:

1
2
3
4
5
6
7
8
9
10
11
12
#include "CoreMinimal.h"
#include "InputCoreTypes.h"
#include "Engine/DataAsset.h"

USTRUCT(BlueprintType)
struct FInputKeyVisual
{
    GENERATED_BODY()

    UPROPERTY(EditAnywhere, BlueprintReadOnly)
    UTexture2D* Icon = nullptr;   // UTexture2D is never included or forward-declared!
};

The file uses UTexture2D, but nothing in its includes actually declares that type. Not CoreMinimal.h, not DataAsset.h. This code was always broken. It just never got caught.

So why did it compile for months?

Because of unity builds (also called “jumbo builds”).

To speed up compilation, Unreal — and many large C++ projects — doesn’t compile each .cpp file separately. Instead it concatenates dozens of them into a handful of giant blobs:

1
2
Module.MyGame.1.cpp   // = fileA.cpp + fileB.cpp + fileC.cpp + ...
Module.MyGame.2.cpp   // = fileD.cpp + fileE.cpp + fileF.cpp + ...

Compiling 5 big files is much faster than 200 small ones — you pay header-parsing costs far fewer times. It’s a huge win.

But it has a sharp edge: include order becomes a matter of luck.

For months, InputKeyVisualDataAsset happened to land in a blob after some other file that included Engine/Texture2D.h. By the time the compiler reached the broken line, UTexture2D was already defined — thanks to a neighbor it knew nothing about.

The bug was real, but invisible.

What my new files did

Adding six new files changed the math. The build tool re-partitioned its unity blobs, and InputKeyVisualDataAsset shuffled to the front of a blob — with no friendly neighbor including Texture2D ahead of it.

The latent bug was finally standing alone in the cold, and the compiler called it out.

The fix

One line. A forward declaration is all a UPROPERTY pointer needs — Unreal’s generated .gen.cpp resolves the full type itself:

1
2
3
4
5
6
7
8
#include "Engine/DataAsset.h"
#include "InputKeyVisualDataAsset.generated.h"

class UTexture2D;   // that's it

USTRUCT(BlueprintType)
struct FInputKeyVisual
{ ... };

All six errors vanished — they were all cascading from that single unknown type.

The takeaway

If you’ve ever seen a build break in a file you never touched after adding unrelated code, unity builds are a prime suspect. The error isn’t random and your new code probably isn’t wrong — you just reshuffled the deck and exposed a header that was never including what it used.

Two practical habits:

  1. Every header should include (or forward-declare) every type it names. Don’t lean on transitive includes you didn’t ask for. They’re a loan that gets called in at the worst time.
  2. Want to catch these before they ambush you? Temporarily disable unity builds for a module with bUseUnity = false; in your .Build.cs. Compiles get slower, but every file is forced to stand on its own — and every freeloading include gets flushed out.
This post is licensed under CC BY 4.0 by the author.