[PATCH] D79067: [MLIR][In progress] Fix libMLIR.so and LLVM_LINK_LLVM_DYLIB

Stephen Neuendorffer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 23:25:39 PDT 2020


stephenneuendorffer created this revision.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, bader, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle, mehdi_amini, mgorny, jholewinski.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: mravishankar.
Herald added a reviewer: antiagainst.
Herald added a reviewer: nicolasvasilache.
Herald added a reviewer: herhut.
Herald added a reviewer: rriddle.
Herald added a reviewer: antiagainst.
Herald added a reviewer: aartbik.
Herald added a reviewer: ftynse.
Herald added a project: LLVM.

Primarily, this patch moves all mlir references to LLVM libraries into
either LLVM_LINK_COMPONENTS or LINK_COMPONENTS.  This enables magic in
the llvm cmake files to automatically replace reference to LLVM components
with references to libLLVM.so when necessary.  Among other things, this
completes fixing libMLIR.so, which has been broken for some configurations
since D77515 <https://reviews.llvm.org/D77515>.

Unlike previously, the pattern is now that mlir libraries should almost
always use add_mlir_library.  Previously, some libraries still used
add_llvm_library.  However, this confuses the export of targets for use
out of tree because libraries specified with add_llvm_library are exported
by LLVM.  Instead users which don't need/can't be linked into libMLIR.so
can specify EXCLUDE_FROM_LIBMLIR

A common error mode is linking with LLVM libraries outside of LINK_COMPONENTS.
This almost always results in symbol confusion or multiply defined options
in LLVM when the same object file is included as a static library and
as part of libLLVM.so.  To catch these errors more directly, there's now
mlir_check_all_link_libraries.

To simplify usage of add_mlir_library, we assume that all mlir
libraries depend on LLVMSupport, so it's not necessary to separately specify
it.

tested with:
BUILD_SHARED_LIBS=on,
BUILD_SHARED_LIBS=off + LLVM_BUILD_LLVM_DYLIB,
BUILD_SHARED_LIBS=off + LLVM_BUILD_LLVM_DYLIB + LLVM_LINK_LLVM_DYLIB.

TODO: I've been unable to figure out how to use the LLVMMLIRTableGen
library to link mlir-tblgen.  Under some configurations, cmake insists
on linking in libLLVM.so in addition to static linkage, resulting in a
broken mlir-tblgen binary.  Avoiding use of the LLVMMLIRTableGen
library fixes the problem.  It's unclear to me whether this is a
problem in the way we're using add_tablegen() or something more
fundamental.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79067

Files:
  mlir/cmake/modules/AddMLIR.cmake
  mlir/examples/toy/Ch6/CMakeLists.txt
  mlir/examples/toy/Ch7/CMakeLists.txt
  mlir/lib/Conversion/AVX512ToLLVM/CMakeLists.txt
  mlir/lib/Conversion/AffineToStandard/CMakeLists.txt
  mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
  mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt
  mlir/lib/Conversion/GPUToROCDL/CMakeLists.txt
  mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt
  mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt
  mlir/lib/Conversion/LoopToStandard/CMakeLists.txt
  mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt
  mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt
  mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
  mlir/lib/Conversion/VectorToLoops/CMakeLists.txt
  mlir/lib/Dialect/AVX512/CMakeLists.txt
  mlir/lib/Dialect/GPU/CMakeLists.txt
  mlir/lib/Dialect/LLVMIR/CMakeLists.txt
  mlir/lib/Dialect/Linalg/Analysis/CMakeLists.txt
  mlir/lib/Dialect/Linalg/EDSC/CMakeLists.txt
  mlir/lib/Dialect/LoopOps/CMakeLists.txt
  mlir/lib/Dialect/LoopOps/Transforms/CMakeLists.txt
  mlir/lib/Dialect/Shape/CMakeLists.txt
  mlir/lib/Dialect/StandardOps/CMakeLists.txt
  mlir/lib/ExecutionEngine/CMakeLists.txt
  mlir/lib/Pass/CMakeLists.txt
  mlir/lib/Support/CMakeLists.txt
  mlir/lib/TableGen/CMakeLists.txt
  mlir/lib/Target/CMakeLists.txt
  mlir/lib/Translation/CMakeLists.txt
  mlir/test/EDSC/CMakeLists.txt
  mlir/test/SDBM/CMakeLists.txt
  mlir/test/lib/Dialect/Affine/CMakeLists.txt
  mlir/test/lib/Dialect/SPIRV/CMakeLists.txt
  mlir/test/lib/Dialect/Test/CMakeLists.txt
  mlir/test/lib/IR/CMakeLists.txt
  mlir/test/lib/Pass/CMakeLists.txt
  mlir/test/lib/Transforms/CMakeLists.txt
  mlir/tools/mlir-cpu-runner/CMakeLists.txt
  mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
  mlir/tools/mlir-opt/CMakeLists.txt
  mlir/tools/mlir-shlib/CMakeLists.txt
  mlir/tools/mlir-tblgen/CMakeLists.txt
  mlir/tools/mlir-translate/CMakeLists.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79067.260845.patch
Type: text/x-patch
Size: 27827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200429/f17b9f53/attachment.bin>


More information about the llvm-commits mailing list