Disabling PDB/debug gen in Development configuration (Engine Source)

So far I’ve tried:

  1. Editing VCToolChain.cs, forcefully disabling any debug/PDB options and rebuilding UBT (confirmed makefiles were remade because UBT was newer)

  2. Editing Build.bat and adding -NoDebugInfo -NoPDB -IncrementalLinking as defaults

  3. Editing all copies of BuildConfiguratin.xml scattered around (because you clearly need 2-3 of them)

None of these work, PDB files still generated.

For anyone who is curious, editing VCToolChain.cs to force flags for compiler and linker is not the best idea, because the build properties used also through UBTfor other tasks.

On Windows, the generation of debug is forced via hardcoded property assignment in UEBuildWindows.cs in SetUpConfigurationEnvironment method. You can fix it there and it will respect BuildConfiguration.xml

3 Likes

What do you mean by ‘fix it there’?

public override void SetUpConfigurationEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment GlobalCompileEnvironment, LinkEnvironment GlobalLinkEnvironment)
{
base.SetUpConfigurationEnvironment(Target, GlobalCompileEnvironment, GlobalLinkEnvironment);

		// NOTE: Even when debug info is turned off, we currently force the linker to generate debug info
		//       anyway on Visual C++ platforms.  This will cause a PDB file to be generated with symbols
		//       for most of the classes and function/method names, so that crashes still yield somewhat
		//       useful call stacks, even though compiler-generate debug info may be disabled.  This gives
		//       us much of the build-time savings of fully-disabled debug info, without giving up call
		//       data completely.
		GlobalLinkEnvironment.bCreateDebugInfo = true;
	}

This thread helped me find the actual solution, right under the source code above it checks for a variable called bOmitPCDebugInfoInDevelopment on whether it should generate PDB files.

In my Game.Target.cs file I added:

		if(Configuration == UnrealTargetConfiguration.Shipping) {
			// Disable PDB debug file generation in shipping builds
			bOmitPCDebugInfoInDevelopment = true;
		}

Warning: Will trigger a couple hundred build steps.