Skip to content

Commit 5f07937

Browse files
committed
Merge branch 'mh/pthreads-autoconf'
* mh/pthreads-autoconf: configure.ac: fix pthreads detection on Mac OS X
2 parents 8cabd20 + e0a5227 commit 5f07937

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

configure.ac

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,17 @@ if test -n "$USER_NOPTHREAD"; then
10351035
# -D_REENTRANT' or some such.
10361036
elif test -z "$PTHREAD_CFLAGS"; then
10371037
threads_found=no
1038-
for opt in -mt -pthread -lpthread; do
1038+
# Attempt to compile and link some code using pthreads to determine
1039+
# required linker flags. The order is somewhat important here: We
1040+
# first try it without any extra flags, to catch systems where
1041+
# pthreads are part of the C library, then go on testing various other
1042+
# flags. We do so to avoid false positives. For example, on Mac OS X
1043+
# pthreads are part of the C library; moreover, the compiler allows us
1044+
# to add "-mt" to the CFLAGS (although it will do nothing except
1045+
# trigger a warning about an unused flag). Hence if we checked for
1046+
# "-mt" before "" we would end up picking it. But unfortunately this
1047+
# would then trigger compiler warnings on every single file we compile.
1048+
for opt in "" -mt -pthread -lpthread; do
10391049
old_CFLAGS="$CFLAGS"
10401050
CFLAGS="$opt $CFLAGS"
10411051
AC_MSG_CHECKING([for POSIX Threads with '$opt'])

0 commit comments

Comments
 (0)