Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion openmp/cmake/DetectTestCompiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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)

Expand Down Expand Up @@ -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)
4 changes: 4 additions & 0 deletions openmp/cmake/OpenMPTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ 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})
set(OPENMP_TEST_${lang}_COMPILER_VERSION ${version})
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.
Expand All @@ -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}")
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions openmp/runtime/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion openmp/runtime/test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions openmp/runtime/test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@"
Expand Down