[Openmp-commits] [openmp] 5ea1c37 - [libomptarget][amdcgn] Only add opt/llvm-link dependency if TARGET is available

Joachim Protze via Openmp-commits openmp-commits at lists.llvm.org
Mon Aug 30 08:33:51 PDT 2021


Author: Joachim Protze
Date: 2021-08-30T17:32:11+02:00
New Revision: 5ea1c37118699f0ed1da17e0d8562011d0002edd

URL: https://github.com/llvm/llvm-project/commit/5ea1c37118699f0ed1da17e0d8562011d0002edd
DIFF: https://github.com/llvm/llvm-project/commit/5ea1c37118699f0ed1da17e0d8562011d0002edd.diff

LOG: [libomptarget][amdcgn] Only add opt/llvm-link dependency if TARGET is available

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.

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

Differential Revision: https://reviews.llvm.org/D108868

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index b972933b1f795..3436cd8bdfbef 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -350,9 +350,14 @@ if(runtimes)
   # 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(

diff  --git a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
index a0aa471594f70..ec830b0961dd5 100644
--- a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
+++ b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
@@ -163,6 +163,14 @@ endmacro()
 
 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})
@@ -171,7 +179,7 @@ foreach(mcpu ${mcpus})
   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})
 


        


More information about the Openmp-commits mailing list