Replies: 1 comment
-
|
As described multiple times, this task shouldn't be performed without basic understanding of the codebase, and should never be done mechanically.
This is largely incorrect. Many headers are used directly, and the compilation successes because they are happened to brought from transitive dependencies. For example,
This repo contains code that's currently never enabled in any configuration, but still has usage during development. CI is not enough for validating them. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I have a PR (#127295) intended to remove unused
#includedirectives from 102 source files in CoreCLR.Goals & Benefits
Approach
The initial pass was generated by an automated tool without cross-platform context, then iterated to fix issues across all target platforms. The final result was validated through binary-level comparison of compiled output across all CI platforms and configurations.
Validation Methodology
Two CI builds were run, publishing
.obj/.ofiles for all 102 modified source files:Artifacts were downloaded (~15.7 GB across 40 platform/config combinations) and compared using platform-appropriate tools:
llvm-objdumpfor disassemblable objects,pyelftoolsfor LoongArch64 ELF sections, and binary/string analysis for LTCG objects.Results
Disassemblable objects (x64, ARM64, ARM, RISC-V, WASM): 11,301 files compared. 5,868 were byte-identical. The remaining 3,919 diffs were exclusively
__LINE__constant shifts (e.g., line 825 → 824) caused by removed#includelines shifting source line numbers. Zero opcode, register, branch target, or structural changes.LTCG/WPO objects (Windows Release): All 1,255 objects had diffs fully explained by removed header path strings, changed anonymous namespace hashes (
?A0x...values — deterministic but path-sensitive), and removed type metadata from unused headers. Cross-validated against non-LTCG (Checked) builds of the same sources, which produce identical machine code.LoongArch64 native objects: 87 identical code sections, 132 with immediate-field-only diffs (
__LINE__). Zero structural changes. Verified by extracting executable ELF sections and comparing instruction words.x86_64 cross-compiled objects (LoongArch build): 4 identical, 30 with constant-only
__LINE__diffs. Zero structural changes, even withTARGET_LOONGARCH64defines active.Conclusion
This PR produces zero code-generation changes across all platforms and configurations.
Every observed diff falls into one of two categories:
__LINE__macro shifts — removing an#includeline shifts subsequent line numbers by 1–2, changing only debug-info constantsNo removed include provided macros, constants, type definitions, or declarations that affected any compiled code path on any architecture (x64, ARM64, ARM, RISC-V, WASM, LoongArch64) in any configuration (Debug, Checked, Release). All CI pipelines pass.
Feedback Welcome
I understand this is a large mechanical change, so I want to make sure it lands cleanly. If you spot an include that should be kept e.g. for documentation, forward-compatibility, or a platform I may have missed, please flag it and I'm happy to restore it.
Beta Was this translation helpful? Give feedback.
All reactions