[2340] Revert "[2340] specify thread flag as part CPPFLAGS, not LDFLAGS."
This reverts commit daf81c8846bf0b4e4308068a019c96beb09c5199.
I believe the sense of the change is correct, but it has effects on
other OSes, so it's probably better to use clang specific workaround
(will commit it later).