[Openmp-commits] [openmp] 54b45af - [libomptarget]Add a trap for external omptarget from LLVM

Ye Luo via Openmp-commits openmp-commits at lists.llvm.org
Sat Jun 18 19:09:54 PDT 2022


Author: Ye Luo
Date: 2022-06-18T21:08:53-05:00
New Revision: 54b45afb599ab81355170f00f9ffe41a88a2cea5

URL: https://github.com/llvm/llvm-project/commit/54b45afb599ab81355170f00f9ffe41a88a2cea5
DIFF: https://github.com/llvm/llvm-project/commit/54b45afb599ab81355170f00f9ffe41a88a2cea5.diff

LOG: [libomptarget]Add a trap for external omptarget from LLVM

Old LLVM installation may expose its internal omptarget CMake target when being used by find_package(LLVM) and caused issues in the CMake of libomptarget that is being built. Trap the issue early.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D128129

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/CMakeLists.txt
    openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 540139dbcd042..5a1386f0bfe85 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -20,6 +20,7 @@ endif()
 
 if (LLVM_DIR)
   # Builds that use pre-installed LLVM have LLVM_DIR set.
+  # A standalone or LLVM_ENABLE_RUNTIMES=openmp build takes this route
   find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
   find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR}
     NO_DEFAULT_PATH)
@@ -32,6 +33,7 @@ if (LLVM_DIR)
   endif()
 elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD)
   # LLVM in-tree builds may use CMake target names to discover the tools.
+  # A LLVM_ENABLE_PROJECTS=openmp build takes this route
   set(CLANG_TOOL $<TARGET_FILE:clang>)
   set(LINK_TOOL $<TARGET_FILE:llvm-link>)
   set(OPT_TOOL $<TARGET_FILE:opt>)

diff  --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
index 61704a101e72f..1f2a50667c4fd 100644
--- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -32,6 +32,10 @@ if (OPENMP_STANDALONE_BUILD)
   list(APPEND LIBOMPTARGET_LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
   list(APPEND CMAKE_MODULE_PATH ${LLVM_CMAKE_DIR})
   include(AddLLVM)
+  if(TARGET omptarget)
+    message(FATAL_ERROR "CMake target 'omptarget' already exists. "
+                        "Use an LLVM installation that doesn't expose its 'omptarget' target.")
+  endif()
 else()
   # Note that OPENMP_STANDALONE_BUILD is FALSE, when
   # openmp is built with -DLLVM_ENABLE_RUNTIMES="openmp" vs


        


More information about the Openmp-commits mailing list