Skip to content

Commit

Permalink
[libomptarget][amdcgn] Only add opt/llvm-link dependency if TARGET is…
Browse files Browse the repository at this point in the history
… 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

(cherry picked from commit 5ea1c37)
  • Loading branch information
jprotze authored and tstellar committed Sep 3, 2021
1 parent 7f3d00c commit c45fa58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 7 additions & 2 deletions llvm/runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 9 additions & 1 deletion openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,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})
Expand All @@ -157,7 +165,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})

Expand Down

0 comments on commit c45fa58

Please sign in to comment.