Skip to content

Commit d022f6b

Browse files
committed
[Libomp] Place generated OpenMP headers into build resource directory (#88007)
Summary: These headers are a part of the compiler's resource directory once installed. However, they are currently placed in the binary directory temporarily. This makes it more difficult to use the compiler out of the build directory and will cause issues when moving to `liboffload`. This patch changes the logic to write these instead to the copmiler's resource directory inside of the build tree. NOTE: This doesn't change the Fortran headers, I don't know enough about those and it won't use the same directory.
1 parent 0c92f86 commit d022f6b

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

clang/test/Headers/Inputs/include/stdint.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
1616
#error Every target should have __INTPTR_TYPE__
1717
#endif
1818

19+
#ifdef __INTPTR_MAX__
20+
#define INTPTR_MAX __INTPTR_MAX__
21+
#endif
22+
23+
#ifdef __UINTPTR_MAX__
24+
#define UINTPTR_MAX __UINTPTR_MAX__
25+
#endif
26+
1927
#endif /* STDINT_H */

openmp/runtime/src/CMakeLists.txt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010

1111
include(ExtendPath)
1212

13+
# The generated headers will be placed in clang's resource directory if present.
14+
if(OPENMP_STANDALONE_BUILD OR NOT LLVM_RUNTIMES_BUILD)
15+
set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
16+
else()
17+
set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
18+
endif()
19+
1320
# Configure omp.h, kmp_config.h and omp-tools.h if necessary
14-
configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY)
15-
configure_file(${LIBOMP_INC_DIR}/ompx.h.var ompx.h @ONLY)
16-
configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
21+
configure_file(${LIBOMP_INC_DIR}/omp.h.var ${LIBOMP_HEADERS_INTDIR}/omp.h @ONLY)
22+
configure_file(${LIBOMP_INC_DIR}/ompx.h.var ${LIBOMP_HEADERS_INTDIR}/ompx.h @ONLY)
23+
configure_file(kmp_config.h.cmake ${LIBOMP_HEADERS_INTDIR}/kmp_config.h @ONLY)
1724
if(${LIBOMP_OMPT_SUPPORT})
18-
configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
25+
configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var ${LIBOMP_HEADERS_INTDIR}/omp-tools.h @ONLY)
1926
endif()
2027

2128
# Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
@@ -48,6 +55,7 @@ include_directories(
4855
${LIBOMP_SRC_DIR}/i18n
4956
${LIBOMP_INC_DIR}
5057
${LIBOMP_SRC_DIR}/thirdparty/ittnotify
58+
${LIBOMP_HEADERS_INTDIR}
5159
)
5260

5361
# Building with time profiling support requires LLVM directory includes.
@@ -419,15 +427,15 @@ else()
419427
endif()
420428
install(
421429
FILES
422-
${CMAKE_CURRENT_BINARY_DIR}/omp.h
423-
${CMAKE_CURRENT_BINARY_DIR}/ompx.h
430+
${LIBOMP_HEADERS_INTDIR}/omp.h
431+
${LIBOMP_HEADERS_INTDIR}/ompx.h
424432
DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
425433
)
426434
if(${LIBOMP_OMPT_SUPPORT})
427-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH})
435+
install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH})
428436
# install under legacy name ompt.h
429-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
430-
set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
437+
install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
438+
set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_HEADERS_INTDIR} PARENT_SCOPE)
431439
endif()
432440
if(${BUILD_FORTRAN_MODULES})
433441
set (destination ${LIBOMP_HEADERS_INSTALL_PATH})

0 commit comments

Comments
 (0)