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
47 lines
1.4 KiB
CMake
47 lines
1.4 KiB
CMake
# This library is unusual, since mlir-tblgen depends on it, which is
|
|
# built with DISABLE_LLVM_LINK_LLVM_DYLIB, this must also be built
|
|
# with that option. Otherwise builds with LLVM_BUILD_LLVM_DYLIB and
|
|
# LLVM_LINK_LLVM_DYLIB fail. (Note that even if this has no llvm
|
|
# component dependencies, LLVM_LINK_LLVM_DYLIB tends to introduce a
|
|
# dependence on libLLVM.so) However, it must also be linkable against
|
|
# libMLIR.so in some contexts (see unittests/Tablegen, for instance, which
|
|
# has a dependence on MLIRIR, which must depend on libLLVM.so). This works
|
|
# in this special case because this library is static.
|
|
#
|
|
# In order for this arrangement to be sound, it must not depend on libraries
|
|
# that may be transitively included in libMLIR.so or libLLVM.so. Specifically,
|
|
# this means that MLIRSupport (outside of header-only access) cannot be used.
|
|
llvm_add_library(MLIRTableGen STATIC
|
|
Argument.cpp
|
|
Attribute.cpp
|
|
AttrOrTypeDef.cpp
|
|
Builder.cpp
|
|
Class.cpp
|
|
CodeGenHelpers.cpp
|
|
Constraint.cpp
|
|
Dialect.cpp
|
|
Format.cpp
|
|
GenInfo.cpp
|
|
Interfaces.cpp
|
|
Operator.cpp
|
|
Pass.cpp
|
|
Pattern.cpp
|
|
Predicate.cpp
|
|
Property.cpp
|
|
Region.cpp
|
|
SideEffects.cpp
|
|
Successor.cpp
|
|
Trait.cpp
|
|
Type.cpp
|
|
|
|
DISABLE_LLVM_LINK_LLVM_DYLIB
|
|
|
|
ADDITIONAL_HEADER_DIRS
|
|
${MLIR_MAIN_INCLUDE_DIR}/mlir/TableGen
|
|
${MLIR_MAIN_INCLUDE_DIR}/mlir/Support
|
|
)
|
|
|
|
mlir_check_all_link_libraries(MLIRTableGen)
|
|
|
|
add_mlir_library_install(MLIRTableGen)
|