i tried to fork the bitcoin 0.21 and to compile it throught WSL and Ubuntu 18.04TLS.
When you say "fork"... did you actually make any edits at all to the source code? or did you simply clone the github repo and then attempt to compile it?
EDIT:
I actually just now installed WSL(2)... Ubuntu 18.04... cloned the bitcoin repo then followed the steps here:
https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.mdIt compiled without issue...
When you did this part:
Ubuntu Bionic 18.04
1:
sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
Did you actually select the option that says "posix"?
I ask because the footnote attached to that command mentions issues with
std::mutex... which is also on line 57 in threadsafety.h:
1: Starting from Ubuntu Xenial 16.04, both the 32 and 64 bit Mingw-w64 packages install two different compiler options to allow a choice between either posix or win32 threads. The default option is win32 threads which is the more efficient since it will result in binary code that links directly with the Windows kernel32.lib. Unfortunately, the headers required to support win32 threads conflict with some of the classes in the C++11 standard library, in particular std::mutex. It's not possible to build the Bitcoin Core code using the win32 version of the Mingw-w64 cross compilers (at least not without modifying headers in the Bitcoin Core source code).
and:
// StdMutex provides an annotated version of std::mutex for us,
// and should only be used when sync.h Mutex/LOCK/etc are not usable.
class LOCKABLE StdMutex : public std::mutex
{
public:
#ifdef __clang__
//! For negative capabilities in the Clang Thread Safety Analysis.
//! A negative requirement uses the EXCLUSIVE_LOCKS_REQUIRED attribute, in conjunction
//! with the ! operator, to indicate that a mutex should not be held.
const StdMutex& operator!() const { return *this; }
#endif // __clang__
};