forked from OSchip/llvm-project
[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
This commit is contained in:
parent
ee4d815008
commit
9cf6511bff
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -31,6 +31,7 @@ pythonize_bool(LIBOMP_HAVE_LIBM)
|
|||
pythonize_bool(LIBOMP_HAVE_LIBATOMIC)
|
||||
pythonize_bool(OPENMP_STANDALONE_BUILD)
|
||||
pythonize_bool(OPENMP_TEST_COMPILER_HAS_OMIT_FRAME_POINTER_FLAGS)
|
||||
pythonize_bool(OPENMP_TEST_COMPILER_HAS_OMP_H)
|
||||
|
||||
add_library(ompt-print-callback INTERFACE)
|
||||
target_include_directories(ompt-print-callback INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/ompt)
|
||||
|
|
|
@ -140,7 +140,7 @@ config.substitutions.append(("%clang", config.test_c_compiler))
|
|||
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
|
||||
# %flags-use-compiler-omp-h allows us to use the test compiler's omp.h file which
|
||||
# may have different definitions of structures than our omp.h file.
|
||||
if config.is_standalone_build:
|
||||
if config.is_standalone_build and config.test_compiler_has_omp_h:
|
||||
config.substitutions.append(("%flags-use-compiler-omp-h",
|
||||
config.test_flags_use_compiler_omp_h))
|
||||
else:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@"
|
||||
config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@"
|
||||
config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@
|
||||
config.test_compiler_has_omp_h = @OPENMP_TEST_COMPILER_HAS_OMP_H@
|
||||
config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
|
||||
config.test_not = "@OPENMP_NOT_EXECUTABLE@"
|
||||
config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@"
|
||||
|
|
Loading…
Reference in New Issue