Repository: bitcoin/bitcoin (language: cpp)

Issue:
qt: Windows build with DEBUG=1 is broken
If you try and cross-compile for Windows using master (d04324a7056a735c1127ba8ccdc720a16e7281a3) `DEBUG=1`, it fails. This is on a Ubuntu Noble machine, with `x86_64-w64-mingw32-g++ (GCC) 13-win32`. Noticed in #29527.
```bash
make -C depends HOST=x86_64-w64-mingw32 DEBUG=1 -j17
<snip>
Checking for STL compatibility... 
+ cd /root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/config.tests/stl && PKG_CONFIG_SYSROOT_DIR=/ PKG_CONFIG_LIBDIR=/root/ci_scratch/depends/x86_64-w64-mingw32/lib/pkgconfig /root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" 'QMAKE_CFLAGS = '\''-pipe -std=c11 -O1 -g  -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -I/root/ci_scratch/depends/x86_64-w64-mingw32/include'\''' 'QMAKE_CXX = '\''x86_64-w64-mingw32-g++-posix'\''' 'QMAKE_CXXFLAGS = '\''-pipe -std=c++20 -O1 -g  -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -I/root/ci_scratch/depends/x86_64-w64-mingw32/include'\''' 'QMAKE_LFLAGS = '\''  -L/root/ci_scratch/depends/x86_64-w64-mingw32/lib'\''' 'QMAKE_LIB = '\''x86_64-w64-mingw32-ar rc'\''' -early "CONFIG += cross_compile" /root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/qtbase/config.tests/stl
+ cd /root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/config.tests/stl && MAKEFLAGS= /usr/bin/gmake
> gmake[1]: Entering directory '/root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/config.tests/stl'
> x86_64-w64-mingw32-g++-posix -c -pipe -std=c++20 -O1 -g  -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -I/root/ci_scratch/depends/x86_64-w64-mingw32/include -O2 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I/root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/qtbase/config.tests/stl -I. -I/root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/qtbase/mkspecs/win32-g++  -o stltest.o /root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/qtbase/config.tests/stl/stltest.cpp
> x86_64-w64-mingw32-g++ -L/root/ci_scratch/depends/x86_64-w64-mingw32/lib -Wl,-s -Wl,-subsystem,console -mthreads -o stl.exe stltest.o  
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_lock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749:(.text+0x809): undefined reference to `pthread_mutex_lock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_unlock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779:(.text+0x81d): undefined reference to `pthread_mutex_unlock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_lock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749:(.text$_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_[_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_]+0x2ce): undefined reference to `pthread_mutex_lock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_unlock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779:(.text$_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_[_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_]+0x2e7): undefined reference to `pthread_mutex_unlock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_lock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749:(.text$_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_[_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_]+0x3c0): undefined reference to `pthread_mutex_lock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_unlock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779:(.text$_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_[_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_]+0x3d9): undefined reference to `pthread_mutex_unlock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_lock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749:(.text$_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_[_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_]+0x4b6): undefined reference to `pthread_mutex_lock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_unlock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779:(.text$_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_[_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_]+0x4cf): undefined reference to `pthread_mutex_unlock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_lock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749:(.text$_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_[_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_]+0x5ac): undefined reference to `pthread_mutex_lock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_unlock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779:(.text$_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_[_ZSt4findIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS7_EESt26random_access_iterator_tagEEiET_SF_SF_RKT0_]+0x5c5): undefined reference to `pthread_mutex_unlock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_lock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749:(.text$_ZSt13__copy_move_aILb0EN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS5_EESt26random_access_iterator_tagSt20back_insert_iteratorISA_EET3_RKN11__gnu_debug14_Safe_iteratorIT0_T1_T2_EESM_SE_[_ZSt13__copy_move_aILb0EN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS5_EESt26random_access_iterator_tagSt20back_insert_iteratorISA_EET3_RKN11__gnu_debug14_Safe_iteratorIT0_T1_T2_EESM_SE_]+0x352): undefined reference to `pthread_mutex_lock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_unlock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779:(.text$_ZSt13__copy_move_aILb0EN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS5_EESt26random_access_iterator_tagSt20back_insert_iteratorISA_EET3_RKN11__gnu_debug14_Safe_iteratorIT0_T1_T2_EESM_SE_[_ZSt13__copy_move_aILb0EN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS5_EESt26random_access_iterator_tagSt20back_insert_iteratorISA_EET3_RKN11__gnu_debug14_Safe_iteratorIT0_T1_T2_EESM_SE_]+0x36b): undefined reference to `pthread_mutex_unlock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_lock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749:(.text.startup+0x60b): undefined reference to `pthread_mutex_lock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_unlock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779:(.text.startup+0x62a): undefined reference to `pthread_mutex_unlock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_lock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749:(.text.startup+0x84b): undefined reference to `pthread_mutex_lock'
> /usr/bin/x86_64-w64-mingw32-ld: stltest.o: in function `__gthread_mutex_unlock':
> /usr/lib/gcc/x86_64-w64-mingw32/13-posix/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779:(.text.startup+0x879): undefined reference to `pthread_mutex_unlock'
> collect2: error: ld returned 1 exit status
> gmake[1]: *** [Makefile:69: stl.exe] Error 1
> gmake[1]: Leaving directory '/root/ci_scratch/depends/work/build/x86_64-w64-mingw32/qt/5.15.11-8c515c34c2a/config.tests/stl'
test config.qtbase.tests.stl FAILED
<snip>
Note: Using static linking will disable the use of dynamically
loaded plugins. Make sure to import all needed static plugins,
or compile needed modules into the library.

ERROR: Qt requires a compliant STL library.
make: *** [funcs.mk:298: /root/ci_scratch/depends/x86_64-w64-mingw32/.qt_stamp_configured] Error 3
make: Leaving directory '/root/ci_scratch/depends'
```


Discussion / hints:

Fix patch:
diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk
index d09ad75eec818..450d0dbea3d5d 100644
--- a/depends/packages/qt.mk
+++ b/depends/packages/qt.mk
@@ -177,6 +177,7 @@ $(package)_config_opts_mingw32 += -xplatform win32-g++
 $(package)_config_opts_mingw32 += "QMAKE_CFLAGS = '$($(package)_cflags) $($(package)_cppflags)'"
 $(package)_config_opts_mingw32 += "QMAKE_CXX = '$($(package)_cxx)'"
 $(package)_config_opts_mingw32 += "QMAKE_CXXFLAGS = '$($(package)_cxxflags) $($(package)_cppflags)'"
+$(package)_config_opts_mingw32 += "QMAKE_LINK = '$($(package)_cxx)'"
 $(package)_config_opts_mingw32 += "QMAKE_LFLAGS = '$($(package)_ldflags)'"
 $(package)_config_opts_mingw32 += "QMAKE_LIB = '$($(package)_ar) rc'"
 $(package)_config_opts_mingw32 += -device-option CROSS_COMPILE="$(host)-"


Test patch: