Use -pthread where and only where needed

Passing -pthread to GCC as a flag makes it both link to libpthread, and make C standard library routines reentrant. This makes the additional explicit links unnecessary.

Additionally, on OSX, this is the default behavior, and clang will print a message about it being unused if it's present there.