[Openmp-commits] [openmp] 5ffecd2 - [Libomptarget] Don't build the device runtime without a new Clang

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Mon May 16 15:18:39 PDT 2022


Author: Joseph Huber
Date: 2022-05-16T18:18:32-04:00
New Revision: 5ffecd28c9fb3098049f0477759f779122153499

URL: https://github.com/llvm/llvm-project/commit/5ffecd28c9fb3098049f0477759f779122153499
DIFF: https://github.com/llvm/llvm-project/commit/5ffecd28c9fb3098049f0477759f779122153499.diff

LOG: [Libomptarget] Don't build the device runtime without a new Clang

The OpenMP device offloading library is a bitcode library and thus only
expect to build and linked with the same version of clang that was used
to create it. This somewhat copmlicates the building process as we
require the Clang that was just built to be used to create the library.
This is either done with a two-step build, where OpenMP is built with
the Clang that was just installed, or through the
`-DLLLVM_ENABLE_RUNTIMES=openmp` option. This has always been the case,
but recent changes have caused this to make it difficult to build the
rest of OpenMP. This patchs adds a check to not build the OpenMP device
runtime if the current compiler is not Clang with the same version as
the LLVM installation. This should allow users to build OpenMP as a
project using any compiler without it erroring out due to the bitcode
library, but if users require it they will need to use the above methods
to compile it.

Reviewed By: jdoerfert, tianshilei1992, ye-luo

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

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 08ed44aad80a..1a38492aacbc 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -242,6 +242,13 @@ foreach(mcpu ${amdgpu_mcpus})
   compileDeviceRTLLibrary(${mcpu} amdgpu -target amdgcn-amd-amdhsa -D__AMDGCN__ -nogpulib)
 endforeach()
 
+set(LIBOMPTARGET_LLVM_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL LIBOMPTARGET_LLVM_VERSION))
+  libomptarget_say("Not building static library, CMake compiler '${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}' is not 'Clang ${LIBOMPTARGET_LLVM_VERSION}'.")
+  libomptarget_say("  Use the 'LLVM_ENABLE_RUNTIMES=openmp' option instead")
+  return()
+endif()
+
 # Set the flags to build the device runtime from clang.
 set(clang_lib_flags -fopenmp -fopenmp-cuda-mode -foffload-lto -fvisibility=hidden -Xopenmp-target=nvptx64-nvidia-cuda --cuda-feature=+ptx61 -mllvm -openmp-opt-disable -nocudalib -nogpulib -nostdinc -DSHARED_SCRATCHPAD_SIZE=512)
 foreach(arch ${nvptx_sm_list})


        


More information about the Openmp-commits mailing list