[PATCH] D125010: [MLIR] Fix build with make

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 07:04:21 PDT 2022


nikic created this revision.
nikic added a reviewer: rriddle.
Herald added subscribers: sdasgup3, wenzhicui, wrengr, Chia-hungDuan, dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, mehdi_amini, mgorny.
Herald added a project: All.
nikic requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: MLIR, LLVM.

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 `obj` 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 `obj` target.


https://reviews.llvm.org/D125010

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


Index: mlir/tools/mlir-pdll/CMakeLists.txt
===================================================================
--- mlir/tools/mlir-pdll/CMakeLists.txt
+++ mlir/tools/mlir-pdll/CMakeLists.txt
@@ -4,18 +4,22 @@
   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)
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -877,6 +877,9 @@
       )
     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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125010.427302.patch
Type: text/x-patch
Size: 1182 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220505/94a69498/attachment.bin>


More information about the llvm-commits mailing list