PTHREAD_LIBS is defined as "-pthread". It should be "-lpthread". Quoting tijl@ "FreeBSD used to have two libc, one without threading (libc.so) and one with (libc_r.so). With -pthread the compiler would link with libc_r instead of libc. Nowadays there's only one libc and -pthread tells the compiler to link with libpthread, exactly like -lpthread does. Both work and patches that change -lpthread into -pthread or vice versa are redundant." I'll commit the patch if this is approved.
Based on Tijl's comment I see no reason to change it.
Using -pthread is wrong. The infrastructure should not be doing the wrong thing by default. We certainly should not be patching good -lpthread with -pthread, which multitudes of ports are doing. It's hard to tell people not to do it when the PTHREAD_LIBS variable is defined the same. In context, tijl's comment was there to support the removal of -pthread, not justify keeping it.
It has been discussed long ago, and some people already went through working on this (we for example provided a blanket to gahr long ago to work on this issue, but he never got time to finish). The work was to entirely drop the PTHREAD_LIBS from bsd.port.mk by first remove all PTHREAD_LIBS references from the ports and then drop entirely PTHREAD_LIBS from bsd.port.mk
Based on more conversations I will say I agree that we should not be using PTHREAD_LIBS or replacing -pthread or -lpthread with the alternative. Doing that cleanup effort is worth it. I may have misunderstood the original intent; I don't think we should prefer -pthread over -lpthread.
So going back to the original description, we should have a goal of removing PTHREAD_LIBS. Changing it doesn't make sense.
using find/grep, a quick estimate is that 410 ports use PTHREAD_LIBS (FYI)
more info on breakdown by category: 1 archivers 1 dns 1 french 1 japanese 1 news 1 ports-mgmt 1 sysutils 1 x11-wm 2 cad 2 devel 2 java 2 x11-fm 3 biology 3 deskutils 3 irc 3 x11-clocks 4 benchmarks 4 misc 4 textproc 4 www 5 ftp 5 net-im 5 net-mgmt 6 editors 6 x11 7 x11-toolkits 8 print 8 science 9 emulators 9 net-p2p 11 comms 15 math 20 security 26 databases 26 mail 27 lang 28 multimedia 33 graphics 37 audio 37 games 38 net
okay, I think all the ${PTHREAD_LIBS} in ports have been removed. Can we remove it from mk.port.mk now?
It's done (r382294)