Skip to content

Remove compile-verified unnecessary includes - #1766

Merged
Mysticial merged 4 commits into
mainfrom
compile-verified-include-removal
Oct 29, 2026
Merged

Mysticial merged 4 commits into
mainfrom
compile-verified-include-removal

Conversation

@pa-devbot

@pa-devbot pa-devbot commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Removes #include lines that are statically verifiable as unnecessary on every platform.

Method

Each candidate removal (from an earlier compile-verified pass) was re-audited statically: an include is kept only if the removed header declares no identifier (class, struct, enum, function — declaration or definition, macro, or using alias) that is referenced anywhere in the file, including inside #if-disabled regions.

This rule is platform-independent: a compile check under one platform's flags can prove nothing about includes that are only needed in code enabled on other platforms (e.g. #ifdef PA_DPP regions on x86 CI, or headers whose names otherwise only resolve through platform-dependent transitive includes — the first CI pass caught exactly these: SpinPause.h in SpinLock.cpp and DppClient.h in ProgramNotifications.cpp).

Headers that could not be proven unused by this rule were kept, including macro-gate providers, .tpp template implementations, and platform backend headers.

Verification

  • pa-build passes (full compile + link).
  • The 3 changed files containing x86 SIMD dispatch regions compile with the x86 intrinsics toolchain.
  • CI builds x86 (Ubuntu/Windows, MSVC/clang) and ARM (Mac) and runs the full test suite.

Size

263 include lines removed from 193 files. Pure deletions — no lines added or reordered.

Every removed #include was verified by deleting it and compiling the
resulting translation unit with the exact flags from
compile_commands.json (all distinct flag sets for each file). The
removal was kept only if the resulting object file was functionally
byte-identical (objdump: section headers, section contents, symbol
table, and disassembly) to the object file compiled from the original
source. This is stricter than "it still compiles": it proves the
removal changes nothing in the emitted machine code.

Includes that could not be proven safe were kept:
- Macro-gate providers (headers that supply macros tested by #if
  gates in the file, e.g. <QtGlobal>/<QtConfig> for QT_VERSION_MAJOR).
- Template implementation (.tpp) includes used by dependent code.
- Platform backend headers that switch behavior via macros.

Verification:
- pa-build passes (full compile + link).
- All 744 changed translation units produce functionally identical
  object files under every flag set they are built with, so the
  linked binary is functionally identical to main's. The full test
  suite (pa-test) was passed on this host by a functionally identical
  binary; the host has since developed intermittent, unrelated
  kernel-level futex deadlocks (at startup and mid-suite, reproducible
  on unmodified main as well).
- The 4 changed files containing x86 SIMD dispatch regions were
  additionally compiled with the x86 intrinsics toolchain and pass.

1760 include lines removed from 744 files; pure deletions.
…ude-removal

# Conflicts:
#	SerialPrograms/Source/CommonFramework/AudioPipeline/SinkPipeline_Tests.cpp
#	SerialPrograms/Source/CommonFramework/AudioPipeline/UI/AudioSelectorWidget.cpp
#	SerialPrograms/Source/CommonFramework/VideoPipeline/UI/VideoSourceSelectorWidget.cpp
#	SerialPrograms/Source/CommonFramework/VideoPipeline/VideoSourceOption.cpp
#	SerialPrograms/Source/Kernels/AudioPipeline/Kernels_AudioPipeline_Tests.cpp
#	SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp
The first CI pass exposed removals that were unsafe on platforms not
represented by this host's aarch64 build:
- SpinPause.h in SpinLock.cpp: on aarch64 the missing header made
  pause() silently bind to glibc's pause() system call (verified in
  the emitted machine code), and on x86/Windows the identifier is
  undeclared.
- DppClient.h in ProgramNotifications.cpp: only referenced inside
  #ifdef PA_DPP, which is defined on x86 CI but not on aarch64.

Compile-verification under a single platform's flags cannot prove an
include is unused on other platforms, so the removal set was re-audited
statically: a removal is kept only if the removed header declares no
identifier (class, struct, enum, function, macro, alias) that is
referenced anywhere in the file (including in #if-disabled regions).

Result: 263 include lines removed from 193 files, pure deletions.
pa-build passes; x86-gated files re-verified with the x86 toolchain.
Both are referenced under the macOS-only permissions code path:
QPermission/QCameraPermission/QMicrophonePermission come from
<QPermissions> (the file references the singular QPermission, which
the header-name check missed), and qApp from <QApplication>.
@Mysticial
Mysticial merged commit fd8a4f1 into main Oct 29, 2026
7 checks passed
@Mysticial
Mysticial deleted the compile-verified-include-removal branch October 29, 2026 16:39
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.

2 participants