Index: cmake/OpenMPTesting.cmake =================================================================== --- cmake/OpenMPTesting.cmake +++ cmake/OpenMPTesting.cmake @@ -99,7 +99,7 @@ # project is built which is too late for detecting the compiler... file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/DetectTestCompiler) execute_process( - COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_LIST_DIR}/DetectTestCompiler + COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} ${CMAKE_CURRENT_LIST_DIR}/DetectTestCompiler -DCMAKE_C_COMPILER=${OPENMP_TEST_C_COMPILER} -DCMAKE_CXX_COMPILER=${OPENMP_TEST_CXX_COMPILER} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/DetectTestCompiler Index: runtime/cmake/LibompHandleFlags.cmake =================================================================== --- runtime/cmake/LibompHandleFlags.cmake +++ runtime/cmake/LibompHandleFlags.cmake @@ -50,6 +50,7 @@ libomp_append(flags_local /GS LIBOMP_HAVE_GS_FLAG) libomp_append(flags_local /EHsc LIBOMP_HAVE_EHSC_FLAG) libomp_append(flags_local /Oy- LIBOMP_HAVE_OY__FLAG) + libomp_append(flags_local -mrtm LIBOMP_HAVE_MRTM_FLAG) # Intel(R) C Compiler flags libomp_append(flags_local /Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) libomp_append(flags_local -Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG) Index: runtime/cmake/config-ix.cmake =================================================================== --- runtime/cmake/config-ix.cmake +++ runtime/cmake/config-ix.cmake @@ -73,13 +73,18 @@ libomp_check_architecture_flag(-mmic LIBOMP_HAVE_MMIC_FLAG) libomp_check_architecture_flag(-m32 LIBOMP_HAVE_M32_FLAG) if(WIN32) - # Check Windows MSVC style flags. - check_c_compiler_flag(/TP LIBOMP_HAVE_TP_FLAG) - check_cxx_compiler_flag(/EHsc LIBOMP_HAVE_EHSC_FLAG) - check_cxx_compiler_flag(/GS LIBOMP_HAVE_GS_FLAG) - check_cxx_compiler_flag(/Oy- LIBOMP_HAVE_Oy__FLAG) - check_cxx_compiler_flag(/arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG) - check_cxx_compiler_flag(/Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) + if(MSVC) + # Check Windows MSVC style flags. + check_c_compiler_flag(/TP LIBOMP_HAVE_TP_FLAG) + check_cxx_compiler_flag(/EHsc LIBOMP_HAVE_EHSC_FLAG) + check_cxx_compiler_flag(/GS LIBOMP_HAVE_GS_FLAG) + check_cxx_compiler_flag(/Oy- LIBOMP_HAVE_Oy__FLAG) + check_cxx_compiler_flag(/arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG) + check_cxx_compiler_flag(/Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) + endif() + if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + check_c_compiler_flag(-mrtm LIBOMP_HAVE_MRTM_FLAG) + endif() # It is difficult to create a dummy masm assembly file # and then check the MASM assembler to see if these flags exist and work, # so we assume they do for Windows. Index: runtime/src/dllexports =================================================================== --- runtime/src/dllexports +++ runtime/src/dllexports @@ -558,9 +558,6 @@ omp_thread_mem_alloc DATA %endif # OMP_50 -%ifdef OMP_50 - omp_control_tool 891 -%endif # OMP_50 %ifndef stub # Ordinals between 900 and 999 are reserved Index: runtime/src/kmp.h =================================================================== --- runtime/src/kmp.h +++ runtime/src/kmp.h @@ -560,7 +560,7 @@ // GROUP_AFFINITY is already defined for _MSC_VER>=1600 (VS2010 and later). #if KMP_OS_WINDOWS -#if _MSC_VER < 1600 +#if _MSC_VER < 1600 && !defined(__MINGW32__) typedef struct GROUP_AFFINITY { KAFFINITY Mask; WORD Group; Index: runtime/src/kmp_dispatch.cpp =================================================================== --- runtime/src/kmp_dispatch.cpp +++ runtime/src/kmp_dispatch.cpp @@ -24,7 +24,7 @@ #include "kmp_itt.h" #include "kmp_stats.h" #include "kmp_str.h" -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !defined(__clang__) #include #endif #include "kmp_lock.h" @@ -478,7 +478,7 @@ /* commonly used term: (2 nproc - 1)/(2 nproc) */ DBL x; -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !defined(__clang__) /* Linux* OS already has 64-bit computation by default for long double, and on Windows* OS on Intel(R) 64, /Qlong_double doesn't work. On Windows* OS on IA-32 architecture, we need to set precision to 64-bit @@ -573,7 +573,7 @@ pr->u.p.count = tc - __kmp_dispatch_guided_remaining( tc, GUIDED_ANALYTICAL_WORKAROUND, cross) - cross * chunk; -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !defined(__clang__) // restore FPCW _control87(oldFpcw, _MCW_PC); #endif @@ -1625,7 +1625,7 @@ case kmp_sch_guided_analytical_chunked: { T chunkspec = pr->u.p.parm1; UT chunkIdx; -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !defined(__clang__) /* for storing original FPCW value for Windows* OS on IA-32 architecture 8-byte version */ unsigned int oldFpcw; @@ -1662,7 +1662,7 @@ Windows* OS. This check works around the possible effect that init != 0 for chunkIdx == 0. */ -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !defined(__clang__) /* If we haven't already done so, save original FPCW and set precision to 64-bit, as Windows* OS on IA-32 architecture defaults to 53-bit */ @@ -1690,7 +1690,7 @@ } // if } // if } // while (1) -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !defined(__clang__) /* restore FPCW if necessary AC: check fpcwSet flag first because oldFpcw can be uninitialized here */ Index: runtime/src/kmp_lock.cpp =================================================================== --- runtime/src/kmp_lock.cpp +++ runtime/src/kmp_lock.cpp @@ -1716,7 +1716,7 @@ /* RTM Adaptive locks */ -#if KMP_COMPILER_ICC && __INTEL_COMPILER >= 1300 +#if (KMP_COMPILER_ICC && __INTEL_COMPILER >= 1300) || defined(__clang__) #include #define SOFT_ABORT_MASK (_XABORT_RETRY | _XABORT_CONFLICT | _XABORT_EXPLICIT) Index: runtime/src/kmp_os.h =================================================================== --- runtime/src/kmp_os.h +++ runtime/src/kmp_os.h @@ -246,7 +246,7 @@ #define KMP_EXPORT extern /* export declaration in guide libraries */ -#if __GNUC__ >= 4 +#if __GNUC__ >= 4 && !defined(__MINGW32__) #define __forceinline __inline #endif @@ -296,7 +296,7 @@ #define KMP_NORETURN __attribute__((noreturn)) #endif -#if KMP_OS_WINDOWS +#if KMP_OS_WINDOWS && !defined(__clang__) #define KMP_ALIGN(bytes) __declspec(align(bytes)) #define KMP_THREAD_LOCAL __declspec(thread) #define KMP_ALIAS /* Nothing */ Index: runtime/src/kmp_platform.h =================================================================== --- runtime/src/kmp_platform.h +++ runtime/src/kmp_platform.h @@ -82,7 +82,7 @@ #define KMP_ARCH_MIPS64 0 #if KMP_OS_WINDOWS -#if defined _M_AMD64 +#if defined(_M_AMD64) || defined(__x86_64) #undef KMP_ARCH_X86_64 #define KMP_ARCH_X86_64 1 #else Index: runtime/src/kmp_safe_c_api.h =================================================================== --- runtime/src/kmp_safe_c_api.h +++ runtime/src/kmp_safe_c_api.h @@ -15,7 +15,7 @@ // Not every unsafe call listed here is handled now, but keeping everything // in one place should be handy for future maintenance. -#if KMP_OS_WINDOWS +#if KMP_OS_WINDOWS && !defined(__MINGW32__) #define RSIZE_MAX_STR (4UL << 10) // 4KB Index: runtime/src/kmp_wrapper_getpid.h =================================================================== --- runtime/src/kmp_wrapper_getpid.h +++ runtime/src/kmp_wrapper_getpid.h @@ -39,7 +39,9 @@ // "process.h". #include // Let us simulate Unix. +#ifndef __MINGW32__ typedef int pid_t; +#endif #define getpid _getpid #define __kmp_gettid() GetCurrentThreadId() Index: runtime/src/kmp_wrapper_malloc.h =================================================================== --- runtime/src/kmp_wrapper_malloc.h +++ runtime/src/kmp_wrapper_malloc.h @@ -93,7 +93,9 @@ // Include alloca() declaration. #if KMP_OS_WINDOWS #include // Windows* OS: _alloca() declared in "malloc.h". +#ifndef __MINGW32__ #define alloca _alloca // Allow to use alloca() with no underscore. +#endif #elif KMP_OS_FREEBSD || KMP_OS_NETBSD // Declared in "stdlib.h". #elif KMP_OS_UNIX Index: runtime/src/libomp.rc.var =================================================================== --- runtime/src/libomp.rc.var +++ runtime/src/libomp.rc.var @@ -11,7 +11,7 @@ ////===----------------------------------------------------------------------===// // -#include "winres.h" +#include "winresrc.h" #include "kmp_config.h" LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // English (U.S.) resources Index: runtime/src/z_Windows_NT_util.cpp =================================================================== --- runtime/src/z_Windows_NT_util.cpp +++ runtime/src/z_Windows_NT_util.cpp @@ -887,6 +887,7 @@ return 1e9 * __kmp_win32_tick * now.QuadPart; } +extern "C" void *__stdcall __kmp_launch_worker(void *arg) { volatile void *stack_data; void *exit_val;