Skip to content

Commit 4e9054d

Browse files
committed
[Libomptarget] Fix lookup of the libcgpu.a library
Summary: The `libcgpu.a` library was added to support certain libc functions. A recent patch made us pass its location directly on the commandline, however it used `find_library`. This doesn't work because the ordering of CMake might run `fine_library` before it builds the library we're trying to find. This patch changes this to just use the destimation we know it will end up in and checks it manually.
1 parent 9188299 commit 4e9054d

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

openmp/libomptarget/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,6 @@ if("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND (LIBC_GPU_BUILD OR
9696
set(LIBC_GPU_SUPPORT TRUE)
9797
endif()
9898

99-
# Find the path of the GPU libc static library.
100-
find_library(GPU_LIBC_PATH NAMES cgpu
101-
PATHS ${LIBOMPTARGET_LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
102-
if((NOT GPU_LIBC_PATH) OR (NOT LIBC_GPU_SUPPORT))
103-
set(GPU_LIBC_PATH "")
104-
endif()
105-
106-
set(LIBOMPTARGET_GPU_LIBC_PATH ${GPU_LIBC_PATH} CACHE STRING
107-
"Location of the 'libcgpu.a' library ")
10899
set(LIBOMPTARGET_GPU_LIBC_SUPPORT ${LIBC_GPU_SUPPORT} CACHE BOOL
109100
"Libomptarget support for the GPU libc")
110101
pythonize_bool(LIBOMPTARGET_GPU_LIBC_SUPPORT)

openmp/libomptarget/test/lit.cfg

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ def remove_suffix_if_present(name):
153153
return name
154154

155155
def add_libraries(source):
156-
return source + " " + config.libomptarget_libc_path + " " + \
157-
config.library_dir + "/libomptarget.devicertl.a"
156+
if config.libomptarget_has_libc:
157+
return source + " " + config.llvm_library_dir + "/libcgpu.a " + \
158+
config.library_dir + "/libomptarget.devicertl.a"
159+
return source + " " + config.library_dir + "/libomptarget.devicertl.a"
158160

159161
# substitutions
160162
# - for targets that exist in the system create the actual command.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ config.cuda_libdir = "@CUDA_LIBDIR@"
1212
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@"
15+
config.llvm_library_dir = "@LIBOMPTARGET_LLVM_LIBRARY_DIR@"
1516
config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"
1617
config.omp_host_rtl_directory = "@LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER@"
1718
config.llvm_lib_directory = "@LIBOMPTARGET_LLVM_LIBRARY_DIR@"
@@ -23,7 +24,6 @@ config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@"
2324
config.libomptarget_debug = @LIBOMPTARGET_DEBUG@
2425
config.has_libomptarget_ompt = @LIBOMPTARGET_OMPT_SUPPORT@
2526
config.libomptarget_has_libc = @LIBOMPTARGET_GPU_LIBC_SUPPORT@
26-
config.libomptarget_libc_path = "@LIBOMPTARGET_GPU_LIBC_PATH@"
2727

2828
# Let the main config do the real work.
2929
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")

0 commit comments

Comments
 (0)