[PATCH] D82659: Fix missing build dependency on omp_gen.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 26 08:10:28 PDT 2020


simon_tatham created this revision.
simon_tatham added reviewers: clementval, thakis, chandlerc.
Herald added subscribers: llvm-commits, sstefan1, mgorny.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.

`include/llvm/Frontend/OpenMP/CMakeLists.txt` creates a new target
called `omp_gen`, which is automatically added to
`LLVM_COMMON_DEPENDS` by the `add_public_tablegen_target` macro. But
it only gets added to the version of `LLVM_COMMON_DEPENDS` in the
scope of that subsidiary CMakeLists file, and it doesn't propagate all
the way back up to the permanent version of that variable which is
actually used to set dependencies.

The visible effect is that the output build scripts contain a missing
dependency. For example, if I run cmake in Ninja output mode, and then
run

  ninja -t commands tools/clang/examples/PrintFunctionNames/CMakeFiles/PrintFunctionNames.dir/PrintFunctionNames.cpp.o

to list all the commands that are prerequisites of building that
object file, then the list does not include the llvm-tblgen command
that builds `include/llvm/Frontend/OpenMP/OMP.h.inc`, even though that
generated include file is needed (by a chain of includes starting from
`clang/AST/AST.h`), and that object file can't be compiled without it.
This missing dependency can cause intermittent build failures,
depending on the order that Ninja (or whatever) happens to schedule
its commands.

I've fixed it by adding a `set` command in two levels of
`CMakeLists.txt` to propagate the modified version of
`LLVM_COMMON_DEPENDS` back up through the parent scopes so that
`omp_gen` does end up on the version seen by the main
`llvm/CMakeLists.txt`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82659

Files:
  llvm/include/llvm/CMakeLists.txt
  llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt


Index: llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
+++ llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
@@ -1,3 +1,5 @@
 set(LLVM_TARGET_DEFINITIONS OMP.td)
 tablegen(LLVM OMP.h.inc --gen-directive-decls)
 add_public_tablegen_target(omp_gen)
+
+set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
Index: llvm/include/llvm/CMakeLists.txt
===================================================================
--- llvm/include/llvm/CMakeLists.txt
+++ llvm/include/llvm/CMakeLists.txt
@@ -7,3 +7,5 @@
 if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
   configure_file(module.modulemap.build module.modulemap COPYONLY)
 endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
+
+set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82659.273735.patch
Type: text/x-patch
Size: 891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200626/e895d595/attachment.bin>


More information about the llvm-commits mailing list