This is an archive of the discontinued LLVM Phabricator instance.

Convert MLIR IndentedOstream to header only.
ClosedPublic

Authored by stellaraccident on Jun 20 2023, 6:51 PM.

Details

Summary

This class has been causing me no end of grief for a long time, and the way it is used by mlir-tblgen is technically an ODR violation in certain situations.

Due to the way that the build is layered, it is important that the MLIR tablegen libraries only depend on the LLVM tablegen libraries, not on anything else (like MLIRSupport). It has to be this way because these libraries/binaries are special and must pre-exist the full shared libraries. Therefore, the dependency chain must be clean (and static).

At some point, someone pulled out a separate build target for just IndendedOstream in an attempt to satisfy the constraint. But because it is weird in different ways, this target was never installed properly as part of distributions, etc -- this causes problems for downstreams seeking to build a tblggen binary that doesn't itself have ODR/shared library problems.

I was attempting to fix the distribution stuff but just opted to collapse this into a header-only library and not try to solve this with build layering. I think this is the safest and the least bad thing for such a dep. This also makes for a clean comment that actually explains the constraint (which I was having trouble verbalizing with the weird subset dependency).

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald Transcript
stellaraccident requested review of this revision.Jun 20 2023, 6:51 PM
jpienaar accepted this revision.Jun 20 2023, 6:56 PM

SGTM (i was thinking about moving to LLVM Support but didn't get that far yet, this is improvement).

This revision is now accepted and ready to land.Jun 20 2023, 6:56 PM
This revision was automatically updated to reflect the committed changes.
mlir/lib/Support/CMakeLists.txt