fix-mingw-compilation.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. diff --git a/cmake/compilers/Clang.cmake b/cmake/compilers/Clang.cmake
  2. index dcd66634..c8f67d4a 100644
  3. --- a/cmake/compilers/Clang.cmake
  4. +++ b/cmake/compilers/Clang.cmake
  5. @@ -66,7 +66,7 @@ endif()
  6. set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -Wformat -Wformat-security -Werror=format-security -fPIC $<$<NOT:$<BOOL:${EMSCRIPTEN}>>:-fstack-protector-strong>)
  7. # -z switch is not supported on MacOS
  8. -if (NOT APPLE)
  9. +if (NOT APPLE AND NOT MINGW)
  10. set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -Wl,-z,relro,-z,now)
  11. endif()
  12. diff --git a/cmake/compilers/GNU.cmake b/cmake/compilers/GNU.cmake
  13. index cf6d8bdb..8f4dbc7f 100644
  14. --- a/cmake/compilers/GNU.cmake
  15. +++ b/cmake/compilers/GNU.cmake
  16. @@ -36,6 +36,10 @@ if (NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_CXX_DEPENDS_USE_COMPILER)
  17. endif()
  18. +if(MINGW)
  19. + set(_tbb_gnu_asm_major_version "2")
  20. + set(_tbb_gnu_asm_minor_version "43")
  21. +else()
  22. # Binutils < 2.31.1 do not support the tpause instruction. When compiling with
  23. # a modern version of GCC (supporting it) but relying on an outdated assembler,
  24. # will result in an error reporting "no such instruction: tpause".
  25. @@ -61,6 +65,7 @@ unset(ASSEMBLER_VERSION_LINE_OUT)
  26. unset(ASSEMBLER_VERSION_LINE_ERR)
  27. unset(ASSEMBLER_VERSION_LINE)
  28. message(TRACE "Extracted GNU assembler version: major=${_tbb_gnu_asm_major_version} minor=${_tbb_gnu_asm_minor_version}")
  29. +endif()
  30. math(EXPR _tbb_gnu_asm_version_number "${_tbb_gnu_asm_major_version} * 1000 + ${_tbb_gnu_asm_minor_version}")
  31. set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} "-D__TBB_GNU_ASM_VERSION=${_tbb_gnu_asm_version_number}")
  32. diff --git a/include/oneapi/tbb/profiling.h b/include/oneapi/tbb/profiling.h
  33. index 412b5a35..fccaba5f 100644
  34. --- a/include/oneapi/tbb/profiling.h
  35. +++ b/include/oneapi/tbb/profiling.h
  36. @@ -132,7 +132,7 @@ namespace d1 {
  37. r1::call_itt_notify(static_cast<int>(t), ptr);
  38. }
  39. -#if (_WIN32||_WIN64) && !__MINGW32__
  40. +#if (_WIN32||_WIN64)
  41. inline void itt_set_sync_name(void* obj, const wchar_t* name) {
  42. r1::itt_set_sync_name(obj, name);
  43. }