[mlir][cmake] Don't add dependencies on mlir-(generic-)headers
authorJeff Niu <jeff@modular.com>
Thu, 1 Sep 2022 18:06:46 +0000 (11:06 -0700)
committerJeff Niu <jeff@modular.com>
Fri, 2 Sep 2022 19:13:49 +0000 (12:13 -0700)
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)

Reviewed By: rriddle, jpienaar

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

mlir/cmake/modules/AddMLIR.cmake
mlir/lib/Analysis/CMakeLists.txt
mlir/lib/Dialect/Transform/IR/CMakeLists.txt
mlir/lib/Pass/CMakeLists.txt
mlir/lib/Rewrite/CMakeLists.txt

index 15079ee..dbcc13a 100644 (file)
@@ -577,19 +577,19 @@ endfunction()
 # Declare the library associated with a dialect.
 function(add_mlir_dialect_library name)
   set_property(GLOBAL APPEND PROPERTY MLIR_DIALECT_LIBS ${name})
-  add_mlir_library(${ARGV} DEPENDS mlir-headers)
+  add_mlir_library(${ARGV})
 endfunction(add_mlir_dialect_library)
 
 # Declare the library associated with a conversion.
 function(add_mlir_conversion_library name)
   set_property(GLOBAL APPEND PROPERTY MLIR_CONVERSION_LIBS ${name})
-  add_mlir_library(${ARGV} DEPENDS mlir-headers)
+  add_mlir_library(${ARGV})
 endfunction(add_mlir_conversion_library)
 
 # Declare the library associated with a translation.
 function(add_mlir_translation_library name)
   set_property(GLOBAL APPEND PROPERTY MLIR_TRANSLATION_LIBS ${name})
-  add_mlir_library(${ARGV} DEPENDS mlir-headers)
+  add_mlir_library(${ARGV})
 endfunction(add_mlir_translation_library)
 
 # Verification tools to aid debugging.
index 23bcb97..6b75bac 100644 (file)
@@ -34,9 +34,6 @@ add_mlir_library(MLIRAnalysis
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Analysis
 
-  DEPENDS
-  mlir-headers
-
   LINK_LIBS PUBLIC
   MLIRCallInterfaces
   MLIRControlFlowInterfaces
index 3041d20..e770dc1 100644 (file)
@@ -6,6 +6,7 @@ add_mlir_dialect_library(MLIRTransformDialect
   DEPENDS
   MLIRTransformDialectIncGen
   MLIRTransformInterfacesIncGen
+  MLIRTransformOpsIncGen
 
   LINK_LIBS PUBLIC
   MLIRIR
index 5ca9b41..76ed4a4 100644 (file)
@@ -10,9 +10,6 @@ add_mlir_library(MLIRPass
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Pass
 
-  DEPENDS
-  mlir-generic-headers
-
   LINK_LIBS PUBLIC
   MLIRAnalysis
   MLIRIR
index e0395be..03afe40 100644 (file)
@@ -6,9 +6,6 @@ add_mlir_library(MLIRRewrite
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Rewrite
 
-  DEPENDS
-  mlir-generic-headers
-
   LINK_LIBS PUBLIC
   MLIRIR
   MLIRPDLDialect