Skip to content

Commit 4bb36df

Browse files
committed
[libomptarget][amdcgn] Add build dependency for llvm-link and opt
D107156 and D107320 are not sufficient when OpenMP is built as llvm runtime (LLVM_ENABLE_RUNTIMES=openmp) because dependencies only work within the same cmake instance. We could limit the dependency to cases where libomptarget/plugins are really built. But compared to the whole llvm project, building openmp runtime is negligible and postponing the build of OpenMP runtime after the dependencies are ready seems reasonable. The direct dependency introduced in D107156 and D107320 is necessary for the case where OpenMP is built as llvm project (LLVM_ENABLE_PROJECTS=openmp). Differential Revision: https://reviews.llvm.org/D108404
1 parent 77b435a commit 4bb36df

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

llvm/runtimes/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,19 @@ if(runtimes)
350350
# Create a runtimes target that uses this file as its top-level CMake file.
351351
# The runtimes target is a configuration of all the runtime libraries
352352
# together in a single CMake invocaiton.
353+
if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
354+
message(STATUS "Adding dependencies opt llvm-link")
355+
set(extra_deps opt llvm-link)
356+
endif()
353357
if(NOT LLVM_RUNTIME_TARGETS)
354358
runtime_default_target(
355-
DEPENDS ${deps}
359+
DEPENDS ${deps} ${extra_deps}
356360
PREFIXES ${prefixes})
357361
set(test_targets check-runtimes)
358362
else()
359363
if("default" IN_LIST LLVM_RUNTIME_TARGETS)
360364
runtime_default_target(
361-
DEPENDS ${deps}
365+
DEPENDS ${deps} ${extra_deps}
362366
PREFIXES ${prefixes})
363367
list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
364368
else()

openmp/libomptarget/DeviceRTL/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ endif()
151151

152152
# Create target to build all Bitcode libraries.
153153
add_custom_target(omptarget-new-nvptx-bc)
154+
add_dependencies(omptarget-new-nvptx-bc opt llvm-link)
154155

155156
# Generate a Bitcode library for all the compute capabilities the user requested
156157
foreach(sm ${nvptx_sm_list})
@@ -197,6 +198,7 @@ foreach(sm ${nvptx_sm_list})
197198

198199
add_custom_target(${bclib_target_name} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${bclib_name}_opt)
199200
add_dependencies(omptarget-new-nvptx-bc ${bclib_target_name})
201+
add_dependencies(${bclib_target_name} opt llvm-link)
200202

201203
# Copy library to destination.
202204
add_custom_command(TARGET ${bclib_target_name} POST_BUILD

openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ foreach(mcpu ${mcpus})
157157
add_custom_command(
158158
OUTPUT ${bc_libname}
159159
COMMAND ${LINK_TOOL} ${bc_files} | ${OPT_TOOL} --always-inline -o ${OUTPUTDIR}/${bc_libname}
160-
DEPENDS ${bc_files} opt)
160+
DEPENDS ${bc_files} llvm-link opt)
161161

162162
add_custom_target(lib${libname}-${mcpu} ALL DEPENDS ${bc_libname})
163163

0 commit comments

Comments
 (0)