Skip to content

Commit 62ff9ac

Browse files
authored
[OpenMP] Use Clang resource dir only in bootstrapping build (#156018)
In an LLVM_ENABLE_PROJECTS=openmp build, the LLVM build tree in which just-built Clang is available, but in contrast to an LLVM_ENABLE_RUNTIMES=openmp build, is not the compiler that openmp is built with (CMAKE_CXX_COMPILER). The latter compiler (which might also be gcc) will not look into the resource directory of just-built Clang, where the OpenMP headers are installed. There may not even be a just-built Clang without LLVM_ENABLE_PROJECTS=clang. We cannot add the OpenMP header output directory to the search path which also include's Clang's internal headers that will conflict with CMAKE_CXX_COMPILER's internal headers. The only choice left is to use what the OpenMP standalone build does: Use CMAKE_CURRENT_BINARY_DIR which is added unconditionally to the header search path to compile openmp itself.
1 parent cacab8a commit 62ff9ac

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

openmp/runtime/src/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111
include(ExtendPath)
1212

13-
# The generated headers will be placed in clang's resource directory if present.
14-
if(NOT LLVM_TREE_AVAILABLE)
15-
set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
16-
else()
13+
# The generated headers will be placed in clang's resource if using it to
14+
# compile openmp in a runtimes-bootstrapping build.
15+
if(LLVM_TREE_AVAILABLE AND LLVM_RUNTIMES_BUILD)
1716
set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
17+
else()
18+
set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
1819
endif()
1920

2021
# Configure omp.h, kmp_config.h and omp-tools.h if necessary

0 commit comments

Comments
 (0)