Skip to content

Commit 8671429

Browse files
authored
[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 e276dce commit 8671429

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-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: 16 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})
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
@@ -419,15 +426,15 @@ else()
419426
endif()
420427
install(
421428
FILES
422-
${CMAKE_CURRENT_BINARY_DIR}/omp.h
423-
${CMAKE_CURRENT_BINARY_DIR}/ompx.h
429+
${LIBOMP_HEADERS_INTDIR}/omp.h
430+
${LIBOMP_HEADERS_INTDIR}/ompx.h
424431
DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
425432
)
426433
if(${LIBOMP_OMPT_SUPPORT})
427-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH})
434+
install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH})
428435
# 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)
436+
install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
437+
set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_HEADERS_INTDIR} PARENT_SCOPE)
431438
endif()
432439
if(${BUILD_FORTRAN_MODULES})
433440
set (destination ${LIBOMP_HEADERS_INSTALL_PATH})

0 commit comments

Comments
 (0)