Skip to content

Commit

Permalink
configure.ac: use $LIBS not $CFLAGS when testing -lpthread
Browse files Browse the repository at this point in the history
Some linkers, namely the one on IRIX are rather strict concerning
the order or arguments for symbol resolution, i.e. no libraries
listed before objects or other libraries on the command line are
considered for symbol resolution.  Therefore, -lpthread can't work
if it's put in CFLAGS, because it will not be considered for
resolving pthread_key_create in conftest.o. Use $LIBS instead.

Signed-off-by: Rainer Canavan <git@canavan.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Rainer M. Canavan authored and Junio C Hamano committed Nov 6, 2015
1 parent 282616c commit bac2c5b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,12 @@ elif test -z "$PTHREAD_CFLAGS"; then
# would then trigger compiler warnings on every single file we compile.
for opt in "" -mt -pthread -lpthread; do
old_CFLAGS="$CFLAGS"
CFLAGS="$opt $CFLAGS"
old_LIBS="$LIBS"
case "$opt" in
-l*) LIBS="$opt $LIBS" ;;
*) CFLAGS="$opt $CFLAGS" ;;
esac

AC_MSG_CHECKING([for POSIX Threads with '$opt'])
AC_LINK_IFELSE([PTHREADTEST_SRC],
[AC_MSG_RESULT([yes])
Expand All @@ -1025,6 +1030,7 @@ elif test -z "$PTHREAD_CFLAGS"; then
],
[AC_MSG_RESULT([no])])
CFLAGS="$old_CFLAGS"
LIBS="$old_LIBS"
done
if test $threads_found != yes; then
AC_CHECK_LIB([pthread], [pthread_create],
Expand Down

0 comments on commit bac2c5b

Please sign in to comment.