Possibly necessary to get threadsafe stdlib behaviours
#17740 removed this, under the (accidental) false pretence that AC_CHECK_LIB didn't actually cause linkage (it does).
It appears this hasn't been necessary since mingw 2.0 released in 2011 turned it into a dummy library, but CVE-2012-1910 occurred in 2012. Furthermore, we don't have a minimum required version of mingw, and it's possible future releases might use it again (GCC -mthreads still links to it).
Seems safest to just add it back in...