boostorg / fiber

userland threads
464 stars 108 forks source link

Fix build with cmake and MinGW #281

Closed yh-sb closed 2 years ago

yh-sb commented 3 years ago

It fixes the following error during build using CMake and MinGW-w64: (it allows to build whole Boost successfully)

[ 27%] Building CXX object libs/fiber/CMakeFiles/boost_fiber_numa.dir/src/numa/windows/pin_thread.cpp.obj
C:\boost\libs\fiber\src\numa\windows\pin_thread.cpp: In function 'void boost::fibers::numa::pin_thread(uint32_t)':
C:\boost\libs\fiber\src\numa\windows\pin_thread.cpp:26:42: error: invalid conversion from 'HANDLE' {aka 'void*'} to 'std::thread::native_handle_type' {aka 'long long unsigned int'} [-fpermissive]
   26 |     pin_thread( cpuid, ::GetCurrentThread() );
      |                        ~~~~~~~~~~~~~~~~~~^~
      |                                          |
      |                                          HANDLE {aka void*}
In file included from C:\boost\libs\fiber\src\numa\windows\pin_thread.cpp:7:
C:/boost/libs/fiber/include/boost/fiber/numa/pin_thread.hpp:26:33: note:   initializing argument 2 of 'void boost::fibers::numa::pin_thread(uint32_t, std::thread::native_handle_type)'
   26 | void pin_thread( std::uint32_t, std::thread::native_handle_type);
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/boost/libs/config/include/boost/config.hpp:39,
                 from C:/boost/libs/fiber/include/boost/fiber/numa/pin_thread.hpp:13,
                 from C:\boost\libs\fiber\src\numa\windows\pin_thread.cpp:7:
C:\boost\libs\fiber\src\numa\windows\pin_thread.cpp: In function 'void boost::fibers::numa::pin_thread(uint32_t, std::thread::native_handle_type)':
C:\boost\libs\fiber\src\numa\windows\pin_thread.cpp:40:57: error: invalid conversion from 'std::thread::native_handle_type' {aka 'long long unsigned int'} to 'HANDLE' {aka 'void*'} [-fpermissive]
   40 |     if ( BOOST_UNLIKELY( 0 == ::SetThreadGroupAffinity( h, & affinity, nullptr) ) ) {
      |                                                         ^
      |                                                         |
      |                                                         std::thread::native_handle_type {aka long long unsigned int}
C:/boost/libs/config/include/boost/config/compiler/gcc.hpp:96:44: note: in definition of macro 'BOOST_UNLIKELY'
   96 | #define BOOST_UNLIKELY(x) __builtin_expect(x, 0)
      |                                            ^
In file included from c:\mydevtools\mingw64\x86_64-w64-mingw32\include\winbase.h:30,
                 from c:\mydevtools\mingw64\x86_64-w64-mingw32\include\windows.h:70,
                 from C:\boost\libs\fiber\src\numa\windows\pin_thread.cpp:10:
c:\mydevtools\mingw64\x86_64-w64-mingw32\include\processtopologyapi.h:22:60: note:   initializing argument 1 of 'WINBOOL SetThreadGroupAffinity(HANDLE, const GROUP_AFFINITY*, PGROUP_AFFINITY)'
   22 |   WINBASEAPI WINBOOL WINAPI SetThreadGroupAffinity (HANDLE hThread, CONST GROUP_AFFINITY *GroupAffinity, PGROUP_AFFINITY PreviousGroupAffinity);
      |                                                     ~~~~~~~^~~~~~~
mingw32-make[2]: *** [libs\fiber\CMakeFiles\boost_fiber_numa.dir\build.make:76: libs/fiber/CMakeFiles/boost_fiber_numa.dir/src/numa/windows/pin_thread.cpp.obj] Error 1

Also see sibling issues, which are fixed by this merge request:

yh-sb commented 3 years ago

Hello @olk, I hope you are doing well. What do you think about this MR? I would be very grateful for merge.

egorpugin commented 2 years ago

Bump. Same for me.

olk commented 2 years ago

ty