Author: Shilei Tian Date: 2021-01-06T17:06:16-05:00 New Revision: e2a623094f6bc1b01f9661043b3df908ca1bd037
URL: https://github.com/llvm/llvm-project/commit/e2a623094f6bc1b01f9661043b3df908ca1bd037 DIFF: https://github.com/llvm/llvm-project/commit/e2a623094f6bc1b01f9661043b3df908ca1bd037.diff LOG: [OpenMP] Fixed the test environment when building along with LLVM Currently all built libraries in OpenMP are anywhere if building along with LLVM. It is not an issue if we don't execute any test. However, almost all tests for `libomptarget` fails because in the lit configuration, we only set `<build_dir>/libomptarget` to `LD_LIBRARY_PATH` and `LIBRARY_PATH`. Since those libraries are everywhere, `clang` can no longer find `libomptarget.so` or those deviceRTLs anymore. In this patch, we set a unified path for all built libraries, no matter whether it is built along with LLVM or not. In this way, our lit configuration can work propoerly. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D93736 Added: Modified: openmp/libomptarget/CMakeLists.txt openmp/libomptarget/src/CMakeLists.txt Removed: ################################################################################ diff --git a/openmp/libomptarget/CMakeLists.txt b/openmp/libomptarget/CMakeLists.txt index 4d6ebb4381bc..06db7b4c35e2 100644 --- a/openmp/libomptarget/CMakeLists.txt +++ b/openmp/libomptarget/CMakeLists.txt @@ -1,9 +1,9 @@ ##===----------------------------------------------------------------------===## -# +# # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# +# ##===----------------------------------------------------------------------===## # # Build offloading library and related plugins. @@ -17,11 +17,12 @@ endif() # Add cmake directory to search for custom cmake functions. set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) -if(OPENMP_STANDALONE_BUILD) - # Build all libraries into a common place so that tests can find them. - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -endif() +# Set the path of all resulting libraries to a unified location so that it can +# be used for testing. +set(LIBOMPTARGET_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR}) # Message utilities. include(LibomptargetUtils) @@ -66,13 +67,6 @@ include_directories(${LIBOMPTARGET_INCLUDE_DIR}) set(LIBOMPTARGET_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) add_subdirectory(${LIBOMPTARGET_SRC_DIR}) -# Retrieve the path to the resulting library so that it can be used for -# testing. -get_target_property(LIBOMPTARGET_LIBRARY_DIR omptarget LIBRARY_OUTPUT_DIRECTORY) -if(NOT LIBOMPTARGET_LIBRARY_DIR) - set(LIBOMPTARGET_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) -endif() - # Definitions for testing, for reuse when testing libomptarget-nvptx. if(OPENMP_STANDALONE_BUILD) set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src" CACHE STRING diff --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt index 894b5ec6f21b..35ff4ed549cc 100644 --- a/openmp/libomptarget/src/CMakeLists.txt +++ b/openmp/libomptarget/src/CMakeLists.txt @@ -39,6 +39,12 @@ else() target_compile_definitions(omptarget PUBLIC OMPTARGET_PROFILE_ENABLED) endif() +# libomptarget needs to be set separately because add_llvm_library doesn't +# conform with location configuration of its parent scope. +set_target_properties(omptarget + PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR}) + # Install libomptarget under the lib destination folder. install(TARGETS omptarget LIBRARY COMPONENT omptarget DESTINATION "${OPENMP_INSTALL_LIBDIR}") _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits