Skip to content

[TableGen] Emit the primary input file in -d depfile output - #23012

Merged
hahnjo merged 1 commit into
root-project:masterfrom
hahnjo:tablegen-depfile
Aug 5, 2026
Merged

hahnjo merged 1 commit into
root-project:masterfrom
hahnjo:tablegen-depfile

Conversation

@hahnjo

@hahnjo hahnjo commented Aug 4, 2026

Copy link
Copy Markdown
Member

This fixes a bug where old, but still supported, versions of CMake and ninja perpetually consider zero-include tablegen files to be out of date. It also matches what Clang and GCC do for regular C compilations.

When a .td input has no include directives, the depfile produced by -d contains only <output>: followed by zero dependencies. My version (3.27) of CMake's cmake_transform_depfile step then writes a 0-byte file, which old versions of ninja treat as a missing depfile and re-run the rule on every incremental build (e.g. Attributes.td, ValueTypes.td).

Here's the effect on Attributes.inc.d:

$ cat ./build/include/llvm/IR/Attributes.inc.d
Attributes.inc:
# switch branches and rebuild...
$ cat ./build/include/llvm/IR/Attributes.inc.d
Attributes.inc: /work/llvm-project/llvm/include/llvm/IR/Attributes.td

An LLM was used to help create this change.


Backport of llvm/llvm-project@05c0db7

This fixes a bug where old, but still supported, versions of CMake and
ninja perpetually consider zero-include tablegen files to be out of
date. It also matches what Clang and GCC do for regular C compilations.

When a .td input has no `include` directives, the depfile produced by
`-d` contains only `<output>:` followed by zero dependencies. My version
(3.27) of CMake's `cmake_transform_depfile` step then writes a 0-byte
file, which old versions of ninja treat as a missing depfile and re-run
the rule on every incremental build (e.g. Attributes.td, ValueTypes.td).

Here's the effect on Attributes.inc.d:

```
$ cat ./build/include/llvm/IR/Attributes.inc.d
Attributes.inc:
$ cat ./build/include/llvm/IR/Attributes.inc.d
Attributes.inc: /work/llvm-project/llvm/include/llvm/IR/Attributes.td
```

An LLM was used to help create this change.

---

Backport of llvm/llvm-project@05c0db7
@hahnjo hahnjo self-assigned this Aug 4, 2026
@hahnjo
hahnjo requested a review from vgvassilev as a code owner August 4, 2026 14:12

@vgvassilev vgvassilev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 16h 54m 31s ⏱️
 3 856 tests  3 856 ✅ 0 💤 0 ❌
78 514 runs  78 514 ✅ 0 💤 0 ❌

Results for commit 6416d8f.

@hahnjo
hahnjo merged commit d0a56e2 into root-project:master Aug 5, 2026
35 checks passed
@hahnjo
hahnjo deleted the tablegen-depfile branch August 5, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants