summaryrefslogtreecommitdiff
path: root/openmp/cmake
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2022-08-01 13:43:18 -0500
committerJonathan Peyton <jonathan.l.peyton@intel.com>2022-08-02 17:05:56 -0500
commit9cf6511bff97007401238f6cff6bf80cb9af04a5 (patch)
treee3f186fe3298fee079e7a3c72cdb40fb746a0e75 /openmp/cmake
parentee4d8150083792242b3c56e5a7f9fe8aaa374b72 (diff)
downloadllvm-9cf6511bff97007401238f6cff6bf80cb9af04a5.tar.gz
[OpenMP][libomp] Detect if test compiler has omp.h
omp50_taskdep_depobj.c relies on the test compiler's omp.h file. If the test compiler does not have an omp.h file, then use the one within the build tree. Fixes: https://github.com/llvm/llvm-project/issues/56820 Differential Revision: https://reviews.llvm.org/D131000
Diffstat (limited to 'openmp/cmake')
-rw-r--r--openmp/cmake/DetectTestCompiler/CMakeLists.txt11
-rw-r--r--openmp/cmake/OpenMPTesting.cmake4
2 files changed, 14 insertions, 1 deletions
diff --git a/openmp/cmake/DetectTestCompiler/CMakeLists.txt b/openmp/cmake/DetectTestCompiler/CMakeLists.txt
index c8afd47a2b3b..dc709f59684a 100644
--- a/openmp/cmake/DetectTestCompiler/CMakeLists.txt
+++ b/openmp/cmake/DetectTestCompiler/CMakeLists.txt
@@ -3,6 +3,8 @@ project(DetectTestCompiler C CXX)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
+include(CheckIncludeFile)
+include(CheckIncludeFileCXX)
function(write_compiler_information lang)
set(information "${CMAKE_${lang}_COMPILER}")
@@ -11,6 +13,7 @@ function(write_compiler_information lang)
set(information "${information}\\;${${lang}_FLAGS}")
set(information "${information}\\;${${lang}_HAS_TSAN_FLAG}")
set(information "${information}\\;${${lang}_HAS_OMIT_FRAME_POINTER}")
+ set(information "${information}\\;${${lang}_HAS_OMP_H}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${lang}CompilerInformation.txt ${information})
endfunction(write_compiler_information)
@@ -44,9 +47,15 @@ endif()
check_c_compiler_flag("-fno-omit-frame-pointer" C_HAS_OMIT_FRAME_POINTER)
check_cxx_compiler_flag("-fno-omit-frame-pointer" CXX_HAS_OMIT_FRAME_POINTER)
-SET(CMAKE_REQUIRED_FLAGS "-fsanitize=thread")
+set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+set(CMAKE_REQUIRED_FLAGS "-fsanitize=thread")
check_c_compiler_flag("" C_HAS_TSAN_FLAG)
check_cxx_compiler_flag("" CXX_HAS_TSAN_FLAG)
+set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
+
+# Check if omp.h header exists for the test compiler
+check_include_file_cxx(omp.h CXX_HAS_OMP_H)
+check_include_file(omp.h C_HAS_OMP_H)
write_compiler_information(C)
write_compiler_information(CXX)
diff --git a/openmp/cmake/OpenMPTesting.cmake b/openmp/cmake/OpenMPTesting.cmake
index 0370b5feaccd..1a9e0ded01aa 100644
--- a/openmp/cmake/OpenMPTesting.cmake
+++ b/openmp/cmake/OpenMPTesting.cmake
@@ -77,6 +77,7 @@ macro(extract_test_compiler_information lang file)
list(GET information 3 openmp_flags)
list(GET information 4 has_tsan_flags)
list(GET information 5 has_omit_frame_pointer_flags)
+ list(GET information 6 has_omp_h)
set(OPENMP_TEST_${lang}_COMPILER_PATH ${path})
set(OPENMP_TEST_${lang}_COMPILER_ID ${id})
@@ -84,6 +85,7 @@ macro(extract_test_compiler_information lang file)
set(OPENMP_TEST_${lang}_COMPILER_OPENMP_FLAGS ${openmp_flags})
set(OPENMP_TEST_${lang}_COMPILER_HAS_TSAN_FLAGS ${has_tsan_flags})
set(OPENMP_TEST_${lang}_COMPILER_HAS_OMIT_FRAME_POINTER_FLAGS ${has_omit_frame_pointer_flags})
+ set(OPENMP_TEST_${lang}_COMPILER_HAS_OMP_H ${has_omp_h})
endmacro()
# Function to set variables with information about the test compiler.
@@ -101,6 +103,7 @@ function(set_test_compiler_information dir)
set(OPENMP_TEST_COMPILER_OPENMP_FLAGS "${OPENMP_TEST_C_COMPILER_OPENMP_FLAGS}" PARENT_SCOPE)
set(OPENMP_TEST_COMPILER_HAS_TSAN_FLAGS "${OPENMP_TEST_C_COMPILER_HAS_TSAN_FLAGS}" PARENT_SCOPE)
set(OPENMP_TEST_COMPILER_HAS_OMIT_FRAME_POINTER_FLAGS "${OPENMP_TEST_C_COMPILER_HAS_OMIT_FRAME_POINTER_FLAGS}" PARENT_SCOPE)
+ set(OPENMP_TEST_COMPILER_HAS_OMP_H "${OPENMP_TEST_C_COMPILER_HAS_OMP_H}" PARENT_SCOPE)
# Determine major version.
string(REGEX MATCH "[0-9]+" major "${OPENMP_TEST_C_COMPILER_VERSION}")
@@ -150,6 +153,7 @@ else()
else()
set(OPENMP_TEST_COMPILER_HAS_TSAN_FLAGS 0)
endif()
+ set(OPENMP_TEST_COMPILER_HAS_OMP_H 1)
# TODO: Implement blockaddress in GlobalISel and remove this flag!
set(OPENMP_TEST_COMPILER_OPENMP_FLAGS "-fopenmp ${OPENMP_TEST_COMPILER_THREAD_FLAGS} -fno-experimental-isel")
set(OPENMP_TEST_COMPILER_HAS_OMIT_FRAME_POINTER_FLAGS 1)