<div dir="ltr">I am checking LLVM_OPTIMIZD_TABLEGEN with ninja.<div><br></div><div>NATIVE/bin/*-tblgen(s) are generated but *.gen.tmp(s) are not regenerated, when NATIVE/bin/*-tblgen(s) should be rebuilt.</div><div><br></div><div>$ touch llvm/utils/TableGen/TableGen.cpp</div><div>$ ninja LLVMCore</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 2, 2016 at 3:27 AM Chris Bieneman <<a href="mailto:beanz@apple.com">beanz@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">Hi Takumi,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">What is the issue you’re seeing? Do you have a reproduction case?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">This change is trying to solve the case where there is no target to generate the tablegen executable. This happens when you are cross-compiling or when you are using LLVM_OPTIMIZED_TABLEGEN=On.</div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">-Chris</div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Nov 1, 2016, at 11:20 AM, NAKAMURA Takumi <<a href="mailto:geek4civic@gmail.com" class="gmail_msg" target="_blank">geek4civic@gmail.com</a>> wrote:</div><br class="m_-1906414593202572529Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg">Chris, excuse me to respond an older commit.<br class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Sat, Apr 25, 2015 at 2:17 AM Chris Bieneman <<a href="mailto:beanz@apple.com" class="gmail_msg" target="_blank">beanz@apple.com</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: cbieneman<br class="gmail_msg">Date: Fri Apr 24 12:09:20 2015<br class="gmail_msg">New Revision: 235732<br class="gmail_msg"><br class="gmail_msg">URL:<span class="m_-1906414593202572529Apple-converted-space gmail_msg"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=235732&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=235732&view=rev</a><br class="gmail_msg">Log:<br class="gmail_msg">[CMake] Fix for PR 23328: LLVM_OPTIMIZED_TABLEGEN broken<br class="gmail_msg"><br class="gmail_msg">In CMake dependencies can be filenames or targets, and targets can't be filenames. The Ninja generator handles filename dependencies because it generates targets for every output file from a command. For example:<br class="gmail_msg"><br class="gmail_msg">add_custom_command(OUTPUT foo.txt COMMAND touch foo.txt)<br class="gmail_msg"><br class="gmail_msg">With the Ninja generator this generates a target foo.txt, but with the Makefile generator it doesn't. This is probably because Ninja explicitly requires these hard dependency ties, and Make just behaves oddly in general.<br class="gmail_msg"><br class="gmail_msg">To fix this we need to make the tablegen actions depend on a target rather than a filename.<br class="gmail_msg"><br class="gmail_msg">Modified:<br class="gmail_msg">   <span class="m_-1906414593202572529Apple-converted-space gmail_msg"> </span>llvm/trunk/cmake/modules/TableGen.cmake<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/cmake/modules/TableGen.cmake<br class="gmail_msg">URL:<span class="m_-1906414593202572529Apple-converted-space gmail_msg"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/TableGen.cmake?rev=235732&r1=235731&r2=235732&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/TableGen.cmake?rev=235732&r1=235731&r2=235732&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/cmake/modules/TableGen.cmake (original)<br class="gmail_msg">+++ llvm/trunk/cmake/modules/TableGen.cmake Fri Apr 24 12:09:20 2015<br class="gmail_msg">@@ -32,7 +32,7 @@ function(tablegen project ofn)<br class="gmail_msg">     # The file in LLVM_TARGET_DEFINITIONS may be not in the current<br class="gmail_msg">     # directory and local_tds may not contain it, so we must<br class="gmail_msg">     # explicitly list it here:<br class="gmail_msg">-    DEPENDS ${${project}_TABLEGEN_EXE} ${local_tds} ${global_tds}<br class="gmail_msg">+    DEPENDS ${${project}_TABLEGEN_TARGET} ${local_tds} ${global_tds}<br class="gmail_msg"></blockquote><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I think it'd be wrong. Order-only dependency is generated in trunk.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">  build include/llvm/IR/Intrinsics.gen.tmp: CUSTOM_COMMAND<span class="m_-1906414593202572529Apple-converted-space gmail_msg"> </span><a href="http://foo.td/" class="gmail_msg" target="_blank">foo.td</a><span class="m_-1906414593202572529Apple-converted-space gmail_msg"> </span>...</div><div class="gmail_msg">  || utils/TableGen/LLVM-tablegen-host<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I think it should be right with<span class="m_-1906414593202572529inbox-inbox-Apple-converted-space gmail_msg"> </span>${${project}_TABLEGEN_EXE}. Files (or executable targets) may be described here.</div><div class="gmail_msg"><br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">     ${LLVM_TARGET_DEFINITIONS_ABSOLUTE}<br class="gmail_msg">     COMMENT "Building ${ofn}..."<br class="gmail_msg">     )<br class="gmail_msg">@@ -90,6 +90,7 @@ macro(add_tablegen target project)<br class="gmail_msg"><br class="gmail_msg">   # Effective tblgen executable to be used:<br class="gmail_msg">   set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE)<br class="gmail_msg">+  set(${project}_TABLEGEN_TARGET ${${project}_TABLEGEN} PARENT_SCOPE)<br class="gmail_msg"><br class="gmail_msg">   if(LLVM_USE_HOST_TOOLS)<br class="gmail_msg">     if( ${${project}_TABLEGEN} STREQUAL "${target}" )<br class="gmail_msg">@@ -101,8 +102,8 @@ macro(add_tablegen target project)<br class="gmail_msg">         DEPENDS CONFIGURE_LLVM_NATIVE ${target}<br class="gmail_msg">         WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}<br class="gmail_msg">         COMMENT "Building native TableGen...")<br class="gmail_msg">-      add_custom_target(${project}NativeTableGen DEPENDS ${${project}_TABLEGEN_EXE})<br class="gmail_msg">-      add_dependencies(${project}NativeTableGen CONFIGURE_LLVM_NATIVE)<br class="gmail_msg">+      add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE})<br class="gmail_msg">+      set(${project}_TABLEGEN_TARGET ${project}-tablegen-host PARENT_SCOPE)<br class="gmail_msg">     endif()<br class="gmail_msg">   endif()<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg">_______________________________________________<br class="gmail_msg">llvm-commits mailing list<br class="gmail_msg"><a href="mailto:llvm-commits@cs.uiuc.edu" class="gmail_msg" target="_blank">llvm-commits@cs.uiuc.edu</a><br class="gmail_msg"><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></blockquote></div></div></div></blockquote></div><br class="gmail_msg"></div></div></blockquote></div>