git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* configure: -lpthread doesn't belong in CFLAGS
@ 2015-11-01 22:30 Rainer M. Canavan
  2015-11-02  8:27 ` Matthieu Moy
  0 siblings, 1 reply; 7+ messages in thread
From: Rainer M. Canavan @ 2015-11-01 22:30 UTC (permalink / raw)
  To: git

Hi,

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. That means that -lpthread can't work if it's 
put in CFLAGS, because it will not be considered for resolving 
pthread_key_create in conftest.o. Apparently only $LIBS goes
after conftest.o when the linker is called.

Without the patch below, the POSIX Threads with '-lpthread' fails, 
with the patch it succeeds. I haven't checked if that is relevant
at all, since that check is immediately followed by 
checking for pthread_create in -lpthread... yes


regards,


rainer


--- ../src/git-2.6.2/configure.ac	Fri Oct 16 23:58:26 CEST 2015
+++ configure.ac	Sun Nov 01 23:19:41 CET 2015
@@ -1126,7 +1126,13 @@
   # 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"
+     if test "$(echo $opt | cut -b 1-2)" = -l ; then
+        LIBS="$opt $LIBS"
+     else
+        CFLAGS="$opt $CFLAGS"
+     fi
+
      AC_MSG_CHECKING([for POSIX Threads with '$opt'])
      AC_LINK_IFELSE([PTHREADTEST_SRC],
 	[AC_MSG_RESULT([yes])
@@ -1138,6 +1144,7 @@
 	],
 	[AC_MSG_RESULT([no])])
       CFLAGS="$old_CFLAGS"
+      LIBS="$old_LIBS"
   done
   if test $threads_found != yes; then
     AC_CHECK_LIB([pthread], [pthread_create],

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-11-20 11:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-01 22:30 configure: -lpthread doesn't belong in CFLAGS Rainer M. Canavan
2015-11-02  8:27 ` Matthieu Moy
2015-11-06  1:11   ` [PATCH] In configure.ac, try -lpthread in $LIBS instead of $CFLAGS to make picky linkers happy Rainer M. Canavan
2015-11-06  8:25     ` Matthieu Moy
2015-11-08 15:28       ` [PATCH] configure.ac: try -lpthread in $LIBS instead of $CFLAGS Rainer M. Canavan
2015-11-08 16:00         ` Matthieu Moy
2015-11-20 11:42           ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).