[Openmp-commits] [openmp] [Libomptarget] Output the DeviceRTL alongside the other libraries (PR #73705)

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 29 08:02:22 PST 2023


https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/73705

>From a8f0245c2aab1212e29125b8f98929f390949a8a Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Tue, 28 Nov 2023 16:03:36 -0600
Subject: [PATCH] [Libomptarget] Output the DeviceRTL alongside the other
 libraries

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.
---
 openmp/libomptarget/DeviceRTL/CMakeLists.txt |  6 ++++++
 openmp/libomptarget/test/lit.cfg             | 11 +++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index df8e4a5126fd443..43458517f07f2f5 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -304,4 +304,10 @@ add_library(omptarget.devicertl STATIC)
 set_target_properties(omptarget.devicertl PROPERTIES LINKER_LANGUAGE CXX)
 target_link_libraries(omptarget.devicertl PRIVATE omptarget.devicertl.all_objs)
 
+# Install this alongside the LLVM libraries is possible.
+if(NOT OPENMP_STANDALONE_BUILD)
+  set_target_properties(omptarget.devicertl PROPERTIES 
+                        ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR})
+endif()
+
 install(TARGETS omptarget.devicertl ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR})
diff --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg
index 6dab31bd35a9f31..1388be578789664 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -153,11 +153,18 @@ def remove_suffix_if_present(name):
     else:
         return name
 
+def get_devicertl():
+    for dir in [config.llvm_library_dir, config.library_dir]:
+        path = os.path.join(dir, "libomptarget.devicertl.a")
+        if os.path.exists(path):
+            return path
+    return "";
+
 def add_libraries(source):
     if config.libomptarget_has_libc:
         return source + " " + config.llvm_library_dir + "/libcgpu.a " + \
-               config.library_dir + "/libomptarget.devicertl.a"
-    return source + " " + config.library_dir + "/libomptarget.devicertl.a"
+               get_devicertl()
+    return source + " " + get_devicertl()
 
 # substitutions
 # - for targets that exist in the system create the actual command.



More information about the Openmp-commits mailing list