Skip to content

Add missing includes for non-unity / no-PCH builds - #136

Open
itismyfield wants to merge 1 commit into
tumourlove:masterfrom
itismyfield:iwyu-nonunity
Open

Add missing includes for non-unity / no-PCH builds#136
itismyfield wants to merge 1 commit into
tumourlove:masterfrom
itismyfield:iwyu-nonunity

Conversation

@itismyfield

@itismyfield itismyfield commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What this changes

153 #include lines across 106 files. No deletions, no code changes, no behavioural change.

Why

Unity builds hide missing includes: several .cpp files are concatenated into one translation unit, so a file silently gets the declarations it needs from whichever neighbour happened to include them. A shared PCH covers most of the rest.

Building with unity disabled and PCHs off surfaces them — 106 files fail to compile because they name types they never include. -DisableUnity on its own does not catch these, since the PCH still supplies the headers; that is how a unity-off build gate can stay green while the files are still not self-contained.

This is the include-what-you-use convention the engine's own modules follow, so each fix is mechanical: add the header that declares a type the file already uses.

Reproducing

In a module's Build.cs:

PCHUsage = ModuleRules.PCHUsageMode.NoPCHs;
bUseUnity = false;

Most frequent additions:

count header
21 AssetRegistry/AssetData.h
19 Policies/CondensedJsonPrintPolicy.h
7 Dom/JsonObject.h
6 Modules/ModuleManager.h
5 UObject/TextProperty.h, UObject/Package.h, Serialization/JsonWriter.h, Serialization/JsonSerializer.h, Math/RandomStream.h

By module: MonolithMesh 24, MonolithIndex 21, MonolithCore 12, MonolithAI 9, MonolithLogicDriver 7, MonolithUI 6, MonolithGAS 5, MonolithAudio 5, remainder 1–3 each.

Two placements worth a look

Both files already had the header, but in a preprocessor branch that does not cover the use site — so these went inside a branch rather than at the top of the file:

  • MonolithMeshHandlePool.cppListHandles() in the !WITH_GEOMETRYSCRIPT stub branch returns MakeShared<FJsonObject>(), while the file's only Dom/JsonObject.h sits in the #else. Added inside the stub branch, to avoid a redundant include on the GeometryScript path.
  • MonolithLogicDriverInternal.cppAssetRegistry/AssetData.h added inside #if WITH_LOGICDRIVER, alongside the existing include group, since every use site is in that block.

Verification

The bulk of the set was established against v0.21.2 by compiling each module with unity off and PCHs off on UE 5.7, iterating until clean, then rebased onto master. The rebase touched one file — MonolithBlueprintActions.cpp, where a later commit added an include at the same position.

Two of the 106 are new files on master rather than carried forward, and they are direct evidence for the PCH point above: MonolithIndexRecoveryTests.cpp and MonolithProjectSearchTests.cpp both call FPlatformFileManager::Get().GetPlatformFile().DeleteFile(...) while HAL/PlatformFileManager.h only forward-declares IPlatformFile, so a no-PCH build fails them with

error C2027: use of undefined type 'IPlatformFile'

Both now include GenericPlatform/GenericPlatformFile.h, matching what MonolithIndexDatabase.cpp and MonolithSourceDatabase.cpp need for the same call. These two were found by compiling master's sources; the remaining 104 were not recompiled on master, so read those as "verified on 0.21.2 / UE 5.7, carried forward mechanically". No 5.8 build was run.

If you would rather have a full no-PCH pass on master before merging, say so and I will redo it.

Unity builds and the shared PCH hide these dependencies: each translation
unit picks the declarations up from a neighbour in the same unity blob, or
from the PCH, so nothing complains. Building with unity disabled and PCHs
off fails in 106 files.

Includes only. No deletions, no behavioural change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant