[PATCH] D60576: [cmake] Fix dependency issue in TableGen

Pengxuan Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 13:28:55 PDT 2019


pzheng created this revision.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.

There is a bug in add_tablegen which causes cmake to fail with the following
error message if LLVM_TABLEGEN is set.

CMake Error at cmake/modules/TableGen.cmake:147 (add_dependencies):

  The dependency target "LLVM-tablegen-host" of target "CLANG-tablegen-host"
  does not exist.

Call Stack (most recent call first):

  tools/clang/utils/TableGen/CMakeLists.txt:3 (add_tablegen)

The issue happens because setting LLVM_TABLEGEN causes cmake to skip generating
the LLVM-tablegen-host target. As a result, a non-existent target was added for
CLANG-tablegen-host causing cmake to fail.

In order to fix this issue, this patch adds a guard to check the validity of the
dependency target before adding it as a dependency.


Repository:
  rL LLVM

https://reviews.llvm.org/D60576

Files:
  cmake/modules/TableGen.cmake


Index: cmake/modules/TableGen.cmake
===================================================================
--- cmake/modules/TableGen.cmake
+++ cmake/modules/TableGen.cmake
@@ -143,7 +143,8 @@
       # Create an artificial dependency between tablegen projects, because they
       # compile the same dependencies, thus using the same build folders.
       # FIXME: A proper fix requires sequentially chaining tablegens.
-      if (NOT ${project} STREQUAL LLVM AND TARGET ${project}-tablegen-host)
+      if (NOT ${project} STREQUAL LLVM AND TARGET ${project}-tablegen-host AND
+          TARGET LLVM-tablegen-host)
         add_dependencies(${project}-tablegen-host LLVM-tablegen-host)
       endif()
     endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60576.194739.patch
Type: text/x-patch
Size: 711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190411/f6967829/attachment.bin>


More information about the llvm-commits mailing list