Skip to content

Commit 799f28d

Browse files
authored
[OpenMP] Fix runtimes default build (#149871)
The default build of openmp (`cmake -S <llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=openmp`) current fails with ``` CMake Error at /home/meinersbur/src/llvm/flangrt/_src/cmake/Modules/GetClangResourceDir.cmake:17 (string): string sub-command REGEX, mode MATCH needs at least 5 arguments total to command. Call Stack (most recent call first): /home/meinersbur/src/llvm/flangrt/_src/openmp/CMakeLists.txt:126 (get_clang_resource_dir) ``` The reason is that because it is not a bootstrapping-build, the clang resource dir that it intends to write files such as `omp-tools.h` into, is unavailable. Using the Clang resource dir for writing files is conceptually broken, as that dir might be located in `/usr/lib/clang/<version>/`. Writing to it is only intended in bootstrapping builds where Clang is built alongside openmp. This patch unifies the identification of being in a bootstrapping built. The same `LLVM_TREE_AVAILABLE` definition is going to be used in #137828. No reason for each runtime to define its own.
1 parent 15b0368 commit 799f28d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

openmp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
115115
option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
116116

117117
# Header install location
118-
if(${OPENMP_STANDALONE_BUILD})
118+
if(NOT LLVM_TREE_AVAILABLE)
119119
set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
120120
else()
121121
include(GetClangResourceDir)

openmp/runtime/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
include(ExtendPath)
1212

1313
# The generated headers will be placed in clang's resource directory if present.
14-
if(OPENMP_STANDALONE_BUILD OR NOT LLVM_RUNTIMES_BUILD)
14+
if(NOT LLVM_TREE_AVAILABLE)
1515
set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
1616
else()
1717
set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})

runtimes/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ include(LLVMCheckCompilerLinkerFlag)
9292
include(CheckCCompilerFlag)
9393
include(CheckCXXCompilerFlag)
9494

95+
96+
# Determine whether we are in the runtimes/runtimes-bins directory of a
97+
# bootstrap build.
98+
set(LLVM_TREE_AVAILABLE OFF)
99+
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
100+
set(LLVM_TREE_AVAILABLE ON)
101+
endif()
102+
95103
# CMake omits default compiler include paths, but in runtimes build, we use
96104
# -nostdinc and -nostdinc++ and control include paths manually so this behavior
97105
# is undesirable. Filtering CMAKE_{LANG}_IMPLICIT_INCLUDE_DIRECTORIES to remove

0 commit comments

Comments
 (0)