Merge r57791:
Improve detection of MT requirement of MPI.

Some MPI implementation report -lpthread in the compilation flags. Previously,
we'd add -lpthread, but did not set threading=multi, as we really should.
One manifestation of this issue is that when building with such an MPI,
and requesting "threading=single threading=multi", we'd actually try
to build two variants of everything, including "mpi.so" Python extension.
And since Python extensions, at present, do not have their name adjusted
for different variants, we'd get duplicate target name error.