From 7be3285248bf54d0784a76174cf44cf7c1e780a5 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Sun, 10 Jan 2021 16:46:09 -0500 Subject: [PATCH] [OpenMP] Not set OPENMP_STANDALONE_BUILD=ON when building OpenMP along with LLVM For now, `*_STANDALONE_BUILD` is set to ON even if they're built along with LLVM because of issues mentioned in the comments. This can cause some issues. For example, if we build OpenMP along with LLVM, we'd like to copy those OpenMP headers to `/lib/clang//include` such that `clang` can find those headers without using `-I /include` because those headers will be copied to `/include` if it is built standalone. In this patch, we fixed the dependence issue in OpenMP such that it can be built correctly even with `OPENMP_STANDALONE_BUILD=OFF`. The issue is in the call to `add_lit_testsuite`, where `clang` and `clang-resource-headers` are passed as `DEPENDS`. Since we're building OpenMP along with LLVM, `clang` is set by CMake to be the C/C++ compiler, therefore these two dependences are no longer needed, where caused the dependence issue. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D93738 --- llvm/runtimes/CMakeLists.txt | 8 ++++++-- openmp/cmake/OpenMPTesting.cmake | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt index 2a03fbfbcded2..d2f5d6bf80f09 100644 --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -60,6 +60,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) project(Runtimes C CXX ASM) find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) # Add the root project's CMake modules, and the LLVM build's modules to the # CMake module path. @@ -136,8 +137,11 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) # The subdirectories need to treat this as standalone builds. D57992 tried # to get rid of this, but the runtimes treat *_STANDALONE_BUILD=OFF as if # llvm & clang are configured in the same CMake, and setup dependencies - # against their targets. - set(${canon_name}_STANDALONE_BUILD ON) + # against their targets. OpenMP has fixed the issue so we don't set the + # variable. + if (NOT ${canon_name} STREQUAL "OPENMP") + set(${canon_name}_STANDALONE_BUILD ON) + endif() if(LLVM_RUNTIMES_LIBDIR_SUBDIR) set(${canon_name}_LIBDIR_SUBDIR "${LLVM_RUNTIMES_LIBDIR_SUBDIR}" CACHE STRING "" FORCE) diff --git a/openmp/cmake/OpenMPTesting.cmake b/openmp/cmake/OpenMPTesting.cmake index 1d46b141ffdf8..7290bc48969f8 100644 --- a/openmp/cmake/OpenMPTesting.cmake +++ b/openmp/cmake/OpenMPTesting.cmake @@ -190,14 +190,14 @@ function(add_openmp_testsuite target comment) ${comment} ${ARG_UNPARSED_ARGUMENTS} EXCLUDE_FROM_CHECK_ALL - DEPENDS clang clang-resource-headers FileCheck ${ARG_DEPENDS} + DEPENDS clang FileCheck ${ARG_DEPENDS} ARGS ${ARG_ARGS} ) else() add_lit_testsuite(${target} ${comment} ${ARG_UNPARSED_ARGUMENTS} - DEPENDS clang clang-resource-headers FileCheck ${ARG_DEPENDS} + DEPENDS clang FileCheck ${ARG_DEPENDS} ARGS ${ARG_ARGS} ) endif()