[Mlir-commits] [mlir] 686bd6d - [MLIR] Fix build with make

Nikita Popov llvmlistbot at llvm.org
Fri May 6 05:52:43 PDT 2022


Author: Nikita Popov
Date: 2022-05-06T14:52:35+02:00
New Revision: 686bd6dd2bf53763b720a1ee60ee01d9054f9434

URL: https://github.com/llvm/llvm-project/commit/686bd6dd2bf53763b720a1ee60ee01d9054f9434
DIFF: https://github.com/llvm/llvm-project/commit/686bd6dd2bf53763b720a1ee60ee01d9054f9434.diff

LOG: [MLIR] Fix build with make

https://reviews.llvm.org/D124075 causes MLIR to no longer build
when using make rather than ninja, due to a tablegen-generated
header being used before it is created.

It seems that this is related to the use of LLVM_ENABLE_OBJLIB when
using add_tablgen with a non-Ninja/Xcode generator. In that case an
intermediate objlib target is generated.

This patch fixes the issue by a) declaring dependencies in
add_tablegen for mlir-pdll and b) making sure those dependencies
are added to the objlib target.

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

Added: 
    

Modified: 
    llvm/cmake/modules/AddLLVM.cmake
    mlir/tools/mlir-pdll/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index c25ac7a100216..f798243a80b22 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -877,6 +877,9 @@ macro(add_llvm_executable name)
       )
     llvm_update_compile_flags(${obj_name})
     set(ALL_FILES "$<TARGET_OBJECTS:${obj_name}>")
+    if(ARG_DEPENDS)
+      add_dependencies(${obj_name} ${ARG_DEPENDS})
+    endif()
 
     set_target_properties(${obj_name} PROPERTIES FOLDER "Object Libraries")
   endif()

diff  --git a/mlir/tools/mlir-pdll/CMakeLists.txt b/mlir/tools/mlir-pdll/CMakeLists.txt
index f6313484b6181..b195d62dfd076 100644
--- a/mlir/tools/mlir-pdll/CMakeLists.txt
+++ b/mlir/tools/mlir-pdll/CMakeLists.txt
@@ -4,18 +4,22 @@ set(LLVM_LINK_COMPONENTS
   TableGen
 )
 
+set(LIBS
+  MLIRIR
+  MLIRPDLLAST
+  MLIRPDLLCodeGen
+  MLIRPDLLODS
+  MLIRPDLLParser
+  )
+
 add_tablegen(mlir-pdll MLIR_PDLL
   mlir-pdll.cpp
+
+  DEPENDS
+  ${LIBS}
   )
 
 set_target_properties(mlir-pdll PROPERTIES FOLDER "Tablegenning")
-target_link_libraries(mlir-pdll
-  PRIVATE
-    MLIRIR
-    MLIRPDLLAST
-    MLIRPDLLCodeGen
-    MLIRPDLLODS
-    MLIRPDLLParser
-  )
+target_link_libraries(mlir-pdll PRIVATE ${LIBS})
 
 mlir_check_all_link_libraries(mlir-pdll)


        


More information about the Mlir-commits mailing list