Closed MehdiChinoune closed 4 months ago
@MehdiChinoune Please post the version of mingw-w64 and g++ that you are using.
mingw-w64: master (12.0.0+r81) g++: 14.1.0
I installed them (with apr and apr-util) from MSYS2/UCRT64 environment
@MehdiChinoune I was unable to reproduce the error using gcc 13.2.0
I have not managed to upgrade gcc to 14.1.0. Using the command
pacman -U /c/users/steph/Downloads/mingw-w64-x86_64-gcc-14.1.0-3-any.pkg.tar.zst
results in
resolving dependencies...
warning: cannot resolve "mingw-w64-x86_64-gcc-libs=14.1.0-3", a dependency of "mingw-w64-x86_64-gcc"
:: The following package cannot be upgraded due to unresolvable dependencies:
mingw-w64-x86_64-gcc
Could you post detailed instructions on installing gcc 14.1.0?
pacman -Syu
I have managed to build it with mingw-w64-gcc https://github.com/msys2/MINGW-packages/commit/59ce40c8db but the patch breaks building with mingw-w64-clang. To make it work on both, It should detect whether the threading library is posix (default for g++/libstdc++ through winpthreads) or win32 (default for clang++/libc++). I don't have enough knoweldge about C++ threading so I couldn't implement such detection.
To make it work on both, It should detect whether the threading library is posix (default for g++/libstdc++ through winpthreads) or win32 (default for clang++/libc++).
It should do this already, the error is in the #define WIN32
, so I'm not sure why it's complaining(MSVC works fine).
To make it work on both, It should detect whether the threading library is posix (default for g++/libstdc++ through winpthreads) or win32 (default for clang++/libc++).
It should do this already, the error is in the
#define WIN32
, so I'm not sure why it's complaining(MSVC works fine).
I don't understand?
To make it work on both, It should detect whether the threading library is posix (default for g++/libstdc++ through winpthreads) or win32 (default for clang++/libc++).
The log4cxx build does detect whether the threading library is posix using the cmake try_compile
command on the file:
#include <pthread.h>
int main(){
pthread_t tid;
pthread_setname_np(tid, "name");
}
and sets the macro to 0 or 1 in LOG4CXX_HAS_PTHREAD_SETNAME in build/src/main/include/log4cxx/private/log4cxx_private.h
When I build log4cxx using gcc 14.1.0, the macro LOG4CXX_HAS_PTHREAD_SETNAME is set to 1.
Please try compiling the above code on your system and post the result.
It detects pthread only for UNIX
mingw64 cmake seems to set UNIX to true
When I build log4cxx using /mingw64/bin/clang++.exe version 18.1.8, the macro LOG4CXX_HAS_PTHREAD_SETNAME is set to 1.
What cmake command are you using to build log4cxx?
It detects pthread only for UNIX
mingw64 cmake seems to set UNIX to true
No, It does not
When I build log4cxx using /mingw64/bin/clang++.exe version 18.1.8, the macro LOG4CXX_HAS_PTHREAD_SETNAME is set to 1.
What cmake command are you using to build log4cxx?
I was talking about CLANG64 Environment where libc++ is the default C++ library (like clang on macOS and FreeBSD). On MINGW64 clang is using ibstdc++ by default (like clang on Linux)
Maybe you installed cmake (/usr/bin/cmake) which is a Cygwin (MSYS) app instead on mingw-w64-x86_64-cmake which is a MinGW-w64 app.
Yes, I see that UNIX is not true using mingw-w64-x86_64-cmake. Using the information in this stack overflow post
We now have to decide what we change:
What do you think?
The issue is about detecting the C++ threading backend on MinGW. It's not about cmake on MINGW
The issue is about detecting the C++ threading backend on MinGW.
It seems pthread and Win32 threading are available. We need to pick one.
The issue is about detecting the C++ threading backend on MinGW.
It seems pthread and Win32 threading are available. We need to pick one.
No, that's not the case. libstdc++ use pthread while libc++ uses Win32. If you try to use one with the other It won't work.
If you try to use one with the other It won't work. Using the following code
#include <pthread.h> #include <iostream>
int main(){ pthread_t tid = pthread_self(); pthread_setname_np(tid, "test-name"); char result[16] = {0}; pthread_t current_thread = pthread_self(); if (pthread_getname_np(current_thread, result, sizeof(result)) < 0 || 0 == result[0]) return 1; std::cout << "result=" << result << '\n'; return 0; }
`/mingw64/bin/clang++.exe -o /tmp/test.exe test-pthread-setname.cpp`
results in
`result=test-name`
You don't understand In MSYS2 we have many environments/variants https://www.msys2.org/docs/environments/ In MINGW64 libstdc++ is the default c++ library and It's using winpthreads as the default threading backend. On CLANG64 libc++ is the default c++ library even winpthreads is available, so finding pthread.h doesn't mean It's used by C++ as default backend.
You are testing clang++ on MINGW64.
In MSYS2 we have many environments/variants
So what macros are provided to determine the default threading backend?
In MSYS2 we have many environments/variants
So what macros are provided to determine the default threading backend?
That's what I am asking the maintainers to do.