[Openmp-commits] [PATCH] D108868: [libomptarget][amdcgn] Only add opt/llvm-link dependency if TARGET is available

Joachim Protze via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sat Aug 28 07:45:49 PDT 2021


protze.joachim created this revision.
protze.joachim added reviewers: raj.khem, JonChesterfield, tianshilei1992.
protze.joachim added a project: OpenMP.
Herald added subscribers: mgorny, jvesely.
protze.joachim requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

In some build configurations, the target we depend on is not available for declaring the build dependency.
We only need to declare the build dependency, if the build target is available in the same build.

Should fix the issue raised in https://reviews.llvm.org/D107156#2969862
This patch should go into release/13 together with D108404 <https://reviews.llvm.org/D108404>

If the patch is accepted, please go ahead and commit - I might not be available for the next week.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108868

Files:
  llvm/runtimes/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt


Index: openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
===================================================================
--- openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
@@ -160,6 +160,14 @@
 
 set(libname "omptarget-amdgcn")
 
+set(toolchain_deps "")
+if(TARGET llvm-link)
+  list(APPEND toolchain_deps llvm-link)
+endif()
+if(TARGET opt)
+  list(APPEND toolchain_deps opt)
+endif()
+
 foreach(mcpu ${mcpus})
   set(bc_files)
   add_cuda_bc_library(${cuda_sources})
@@ -168,7 +176,7 @@
   add_custom_command(
     OUTPUT ${bc_libname}
     COMMAND ${LINK_TOOL} ${bc_files} | ${OPT_TOOL} --always-inline -o ${OUTPUTDIR}/${bc_libname}
-    DEPENDS ${bc_files} llvm-link opt)
+    DEPENDS ${bc_files} ${toolchain_deps})
 
   add_custom_target(lib${libname}-${mcpu} ALL DEPENDS ${bc_libname})
 
Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -350,9 +350,14 @@
   # Create a runtimes target that uses this file as its top-level CMake file.
   # The runtimes target is a configuration of all the runtime libraries
   # together in a single CMake invocaiton.
+  set(extra_deps "")
   if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
-    message(STATUS "Adding dependencies opt llvm-link")
-    set(extra_deps opt llvm-link)
+    if(TARGET opt)
+      list(APPEND extra_deps opt)
+    endif()
+    if(TARGET llvm-link)
+      list(APPEND extra_deps llvm-link)
+    endif()
   endif()
   if(NOT LLVM_RUNTIME_TARGETS)
     runtime_default_target(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108868.369259.patch
Type: text/x-patch
Size: 1630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210828/fc4c3175/attachment.bin>


More information about the Openmp-commits mailing list