Skip to content

Commit 7be3285

Browse files
committed
[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 `<prefix>/lib/clang/<version>/include` such that `clang` can find those headers without using `-I <prefix>/include` because those headers will be copied to `<prefix>/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
1 parent 894d2db commit 7be3285

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

llvm/runtimes/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
6060
project(Runtimes C CXX ASM)
6161

6262
find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
63+
find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
6364

6465
# Add the root project's CMake modules, and the LLVM build's modules to the
6566
# CMake module path.
@@ -136,8 +137,11 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
136137
# The subdirectories need to treat this as standalone builds. D57992 tried
137138
# to get rid of this, but the runtimes treat *_STANDALONE_BUILD=OFF as if
138139
# llvm & clang are configured in the same CMake, and setup dependencies
139-
# against their targets.
140-
set(${canon_name}_STANDALONE_BUILD ON)
140+
# against their targets. OpenMP has fixed the issue so we don't set the
141+
# variable.
142+
if (NOT ${canon_name} STREQUAL "OPENMP")
143+
set(${canon_name}_STANDALONE_BUILD ON)
144+
endif()
141145

142146
if(LLVM_RUNTIMES_LIBDIR_SUBDIR)
143147
set(${canon_name}_LIBDIR_SUBDIR "${LLVM_RUNTIMES_LIBDIR_SUBDIR}" CACHE STRING "" FORCE)

openmp/cmake/OpenMPTesting.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,14 @@ function(add_openmp_testsuite target comment)
190190
${comment}
191191
${ARG_UNPARSED_ARGUMENTS}
192192
EXCLUDE_FROM_CHECK_ALL
193-
DEPENDS clang clang-resource-headers FileCheck ${ARG_DEPENDS}
193+
DEPENDS clang FileCheck ${ARG_DEPENDS}
194194
ARGS ${ARG_ARGS}
195195
)
196196
else()
197197
add_lit_testsuite(${target}
198198
${comment}
199199
${ARG_UNPARSED_ARGUMENTS}
200-
DEPENDS clang clang-resource-headers FileCheck ${ARG_DEPENDS}
200+
DEPENDS clang FileCheck ${ARG_DEPENDS}
201201
ARGS ${ARG_ARGS}
202202
)
203203
endif()

0 commit comments

Comments
 (0)