Skip to content

Commit 0ec4b82

Browse files
authored
[Libomptarget] Output the DeviceRTL alongside the other libraries (#73705)
Summary: Currently, the `libomp.so` and `libomptarget.so` are emitted in the `./lib` build directory generally. This logic is internal to the `add_llvm_library` function we use to build `libomptarget`. The DeviceRTl static library however is in the middle of the OpenMP runtime build, which can vary depending on if this is a runtimes or projects build. This patch changes this to install the DeviceRTL static library alongside the other OpenMP libraries so they are easier to find.
1 parent fce4c0a commit 0ec4b82

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

openmp/libomptarget/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR})
2424
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR})
2525
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR})
2626

27+
if(LLVM_LIBRARY_OUTPUT_INTDIR)
28+
set(LIBOMPTARGET_INTDIR ${LIBOMPTARGET_LIBRARY_DIR})
29+
else()
30+
set(LIBOMPTARGET_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
31+
endif()
32+
2733
# Message utilities.
2834
include(LibomptargetUtils)
2935

@@ -115,6 +121,8 @@ set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${LIBOMP_LIBRARY_DIR}" CACHE STRING
115121
"Path to folder containing libomp.so, and libLLVMSupport.so with profiling enabled")
116122
set(LIBOMPTARGET_LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE STRING
117123
"Path to folder containing llvm library libomptarget.so")
124+
set(LIBOMPTARGET_LLVM_LIBRARY_INTDIR "${LIBOMPTARGET_INTDIR}" CACHE STRING
125+
"Path to folder where intermediate libraries will be output")
118126

119127
# Build offloading plugins and device RTLs if they are available.
120128
add_subdirectory(plugins-nextgen)

openmp/libomptarget/DeviceRTL/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ endforeach()
301301

302302
# Archive all the object files generated above into a static library
303303
add_library(omptarget.devicertl STATIC)
304-
set_target_properties(omptarget.devicertl PROPERTIES LINKER_LANGUAGE CXX)
304+
set_target_properties(omptarget.devicertl PROPERTIES
305+
ARCHIVE_OUTPUT_DIRECTORY ${LIBOMPTARGET_LLVM_LIBRARY_INTDIR}
306+
LINKER_LANGUAGE CXX
307+
)
305308
target_link_libraries(omptarget.devicertl PRIVATE omptarget.devicertl.all_objs)
306309

307310
install(TARGETS omptarget.devicertl ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR})

openmp/libomptarget/test/lit.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def remove_suffix_if_present(name):
156156
def add_libraries(source):
157157
if config.libomptarget_has_libc:
158158
return source + " " + config.llvm_library_dir + "/libcgpu.a " + \
159-
config.library_dir + "/libomptarget.devicertl.a"
160-
return source + " " + config.library_dir + "/libomptarget.devicertl.a"
159+
config.llvm_library_intdir + "/libomptarget.devicertl.a"
160+
return source + " " + config.llvm_library_intdir + "/libomptarget.devicertl.a"
161161

162162
# substitutions
163163
# - for targets that exist in the system create the actual command.

openmp/libomptarget/test/lit.site.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config.cuda_test_arch = "@LIBOMPTARGET_DEP_CUDA_ARCH@"
1313
config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@/@CURRENT_TARGET@"
1414
config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
1515
config.llvm_library_dir = "@LIBOMPTARGET_LLVM_LIBRARY_DIR@"
16+
config.llvm_library_intdir = "@LIBOMPTARGET_LLVM_LIBRARY_INTDIR@"
1617
config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"
1718
config.omp_host_rtl_directory = "@LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER@"
1819
config.llvm_lib_directory = "@LIBOMPTARGET_LLVM_LIBRARY_DIR@"

0 commit comments

Comments
 (0)