| Issue |
162801
|
| Summary |
LLDB build broken on mingw with libstdc++ with posix threads
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
mstorsjo
|
Since #145621, building LLDB for windows/mingw fails, if using libstdc++ configured with posix threads. (This is commonly the default configuration of libstdc++.) CC @ashgti
Building fails with errors like these:
```
/home/martin/code/llvm-project/lldb/source/Host/windows/MainLoopWindows.cpp: In destructor ‘virtual {anonymous}::PipeEvent::~PipeEvent()’:
/home/martin/code/llvm-project/lldb/source/Host/windows/MainLoopWindows.cpp:61:66: error: invalid conversion from ‘std::thread::native_handle_type’ {aka ‘long long unsigned int’} to ‘HANDLE’ {aka ‘void*’} [-fpermissive]
61 | } while (WaitForSingleObject(m_monitor_thread.native_handle(), 1) ==
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
| |
| std::thread::native_handle_type {aka long long unsigned int}
In file included from /home/martin/gcc-mingw/x86_64-w64-mingw32/include/winbase.h:35,
from /home/martin/gcc-mingw/x86_64-w64-mingw32/include/windows.h:70,
from /home/martin/code/llvm-project/lldb/include/lldb/Host/windows/windows.h:19,
from /home/martin/code/llvm-project/lldb/include/lldb/Host/SocketAddress.h:15,
from /home/martin/code/llvm-project/lldb/include/lldb/Host/Socket.h:20,
from /home/martin/code/llvm-project/lldb/source/Host/windows/MainLoopWindows.cpp:11:
/home/martin/gcc-mingw/x86_64-w64-mingw32/include/synchapi.h:115:55: note: initializing argument 1 of ‘DWORD WaitForSingleObject(HANDLE, DWORD)’
115 | WINBASEAPI DWORD WINAPI WaitForSingleObject (HANDLE hHandle, DWORD dwMilliseconds);
| ~~~~~~~^~~~~~
```
When libstdc++ is configured with posix threads, the native thread handle isn't a win32 `HANDLE`, but a `pthread_t`.
It's possible to try to inspect the C++ standard libraries to see which way they are configured, but this is not a stable API or something a consumer is supposed to inspect; see b4130bee6bfd34d8045f02fc9f951bcb5db9d85c for an earlier attempt at doing the same elsewhere, which ended up being backed out in 87f4bc0acad65b1d20160d4160c7778b187125fc as libc++ changed the internal interface that was inspected.
Instead of mixing `std::thread` and native Windows APIs like `WaitForSingleObject`, is it possible to achieve the same with standard C++ `std::thread` methods?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs