This is an archive of the discontinued LLVM Phabricator instance.

[mlir][cmake] Don't add dependencies on mlir-(generic-)headers
ClosedPublic

Authored by Mogball on Sep 1 2022, 11:11 AM.

Details

Summary

Every dialect was dependent on mlir-headers, which was causing the
build of any single MLIR dialect to pull in a bunch of extra
dependencies that aren't needed. Now, MLIR dialects will need to
explicitly depend on MLIR*IncGen targets to pull in any needed
headers.

This does not impact the actual mlir-header target.

Consider the "simple" Arithmetic dialect. Before:

% ninja MLIRArithmeticDialect
[151/812] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/JSONBackend.cpp.o

After:

% ninja MLIRArithmeticDialect
[207/374] Building CXX object tools/mlir/lib/TableGen/CMakeFiles/MLIRTableGen.dir/GenInfo.cpp.o

(Both clean builds)

Diff Detail

Event Timeline

Mogball created this revision.Sep 1 2022, 11:11 AM
Mogball requested review of this revision.Sep 1 2022, 11:11 AM
Mogball edited the summary of this revision. (Show Details)Sep 1 2022, 11:21 AM
Mogball added a reviewer: jpienaar.
jpienaar accepted this revision.Sep 1 2022, 11:30 AM

Nice, and seems like everyone was already doing that in core? (>2x reduction good, always good to occasionally check here)

This revision is now accepted and ready to land.Sep 1 2022, 11:30 AM
rriddle accepted this revision.Sep 1 2022, 11:31 AM

Assuming this doesn't blow anything up, LG.

It seems to be the CI is already failing due to missing dependencies on headers. I also tested the patch and while it did luckily I build I ran ninja -t missingdeps on it afterwards and it flagged a few more missing dependencies on headers https://gist.github.com/zero9178/a1b69d320e9f56f11ec2eb3b30ebf47d. You can run that ninja commandline if you have a new enough version to help you find missing header dependencies. Just make sure its run after the related cpp files have been built so that it picks up the header dependencies. It sadly sometimes has false positives however.

Mogball updated this revision to Diff 457647.Sep 2 2022, 11:16 AM

possibly due to ccache, I'm not able to reproduce these failures locally, so I guess I'm iterating with the bot :(

This is extremely tricky to get right, I'm quite concern about the blast effect of this.

Please revert for now.

The bot was green when I landed. Only flang is broken now which I'm fixing. Should I still revert it?