Skip to content

Commit

Permalink
[Libomptarget] Fix lookup of the libcgpu.a library
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhuber6 committed Oct 5, 2023
1 parent 9188299 commit 4e9054d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
9 changes: 0 additions & 9 deletions openmp/libomptarget/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,6 @@ if("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND (LIBC_GPU_BUILD OR
set(LIBC_GPU_SUPPORT TRUE)
endif()

# Find the path of the GPU libc static library.
find_library(GPU_LIBC_PATH NAMES cgpu
PATHS ${LIBOMPTARGET_LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
if((NOT GPU_LIBC_PATH) OR (NOT LIBC_GPU_SUPPORT))
set(GPU_LIBC_PATH "")
endif()

set(LIBOMPTARGET_GPU_LIBC_PATH ${GPU_LIBC_PATH} CACHE STRING
"Location of the 'libcgpu.a' library ")
set(LIBOMPTARGET_GPU_LIBC_SUPPORT ${LIBC_GPU_SUPPORT} CACHE BOOL
"Libomptarget support for the GPU libc")
pythonize_bool(LIBOMPTARGET_GPU_LIBC_SUPPORT)
Expand Down
6 changes: 4 additions & 2 deletions openmp/libomptarget/test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ def remove_suffix_if_present(name):
return name

def add_libraries(source):
return source + " " + config.libomptarget_libc_path + " " + \
config.library_dir + "/libomptarget.devicertl.a"
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"

# substitutions
# - for targets that exist in the system create the actual command.
Expand Down
2 changes: 1 addition & 1 deletion openmp/libomptarget/test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ config.cuda_libdir = "@CUDA_LIBDIR@"
config.cuda_test_arch = "@LIBOMPTARGET_DEP_CUDA_ARCH@"
config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@/@CURRENT_TARGET@"
config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
config.llvm_library_dir = "@LIBOMPTARGET_LLVM_LIBRARY_DIR@"
config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"
config.omp_host_rtl_directory = "@LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER@"
config.llvm_lib_directory = "@LIBOMPTARGET_LLVM_LIBRARY_DIR@"
Expand All @@ -23,7 +24,6 @@ config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@"
config.libomptarget_debug = @LIBOMPTARGET_DEBUG@
config.has_libomptarget_ompt = @LIBOMPTARGET_OMPT_SUPPORT@
config.libomptarget_has_libc = @LIBOMPTARGET_GPU_LIBC_SUPPORT@
config.libomptarget_libc_path = "@LIBOMPTARGET_GPU_LIBC_PATH@"

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

0 comments on commit 4e9054d

Please sign in to comment.