Skip to content

Commit 3129891

Browse files
committed
Merge branch 'mh/pthreads-autoconf' into maint
* mh/pthreads-autoconf: configure.ac: fix pthreads detection on Mac OS X
2 parents 80ff618 + e0a5227 commit 3129891

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
@@ -1021,7 +1021,17 @@ if test -n "$USER_NOPTHREAD"; then
10211021
# -D_REENTRANT' or some such.
10221022
elif test -z "$PTHREAD_CFLAGS"; then
10231023
threads_found=no
1024-
for opt in -mt -pthread -lpthread; do
1024+
# Attempt to compile and link some code using pthreads to determine
1025+
# required linker flags. The order is somewhat important here: We
1026+
# first try it without any extra flags, to catch systems where
1027+
# pthreads are part of the C library, then go on testing various other
1028+
# flags. We do so to avoid false positives. For example, on Mac OS X
1029+
# pthreads are part of the C library; moreover, the compiler allows us
1030+
# to add "-mt" to the CFLAGS (although it will do nothing except
1031+
# trigger a warning about an unused flag). Hence if we checked for
1032+
# "-mt" before "" we would end up picking it. But unfortunately this
1033+
# would then trigger compiler warnings on every single file we compile.
1034+
for opt in "" -mt -pthread -lpthread; do
10251035
old_CFLAGS="$CFLAGS"
10261036
CFLAGS="$opt $CFLAGS"
10271037
AC_MSG_CHECKING([for POSIX Threads with '$opt'])

0 commit comments

Comments
 (0)