[all-commits] [llvm/llvm-project] b9a907: Convert MLIR IndentedOstream to header only.

Stella Laurenzo via All-commits all-commits at lists.llvm.org
Tue Jun 20 19:19:19 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b9a907d1336f09b6ff79a69ebd86a3a946ad4073
      https://github.com/llvm/llvm-project/commit/b9a907d1336f09b6ff79a69ebd86a3a946ad4073
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2023-06-20 (Tue, 20 Jun 2023)

  Changed paths:
    M mlir/include/mlir/Support/IndentedOstream.h
    M mlir/lib/Support/CMakeLists.txt
    R mlir/lib/Support/IndentedOstream.cpp
    M mlir/lib/TableGen/CMakeLists.txt
    M mlir/lib/Tools/mlir-tblgen/CMakeLists.txt
    M mlir/tools/mlir-tblgen/CMakeLists.txt

  Log Message:
  -----------
  Convert MLIR IndentedOstream to header only.

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).

Differential Revision: https://reviews.llvm.org/D153393




More information about the All-commits mailing list