{"thread":{"id":"40701","subject":"configure: -lpthread doesn't belong in CFLAGS","startedAt":"2015-11-01T22:30:16Z","lastAt":"2015-11-20T11:42:07Z","messageCount":7,"participants":["Rainer M. Canavan","Matthieu Moy","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"272713","messageId":"201511012230.tA1MUGa5016836@tezro.nonet","threadId":"40701","inReplyTo":null,"subject":"configure: -lpthread doesn't belong in CFLAGS","fromName":"Rainer M. Canavan","fromEmail":"git@canavan.de","sentAt":"2015-11-01T22:30:16Z","receivedAt":"2015-11-01T22:30:16Z","isPatch":false,"sender":{"key":"git@canavan.de","avatar":null},"body":"Hi,\n\nsome linkers, namely the one on IRIX are rather strict concerning the \norder or arguments for symbol resolution, i.e. no libraries listed\nbefore objects or other libraries on the command line are considered\nfor symbol resolution. That means that -lpthread can't work if it's \nput in CFLAGS, because it will not be considered for resolving \npthread_key_create in conftest.o. Apparently only $LIBS goes\nafter conftest.o when the linker is called.\n\nWithout the patch below, the POSIX Threads with '-lpthread' fails, \nwith the patch it succeeds. I haven't checked if that is relevant\nat all, since that check is immediately followed by \nchecking for pthread_create in -lpthread... yes\n\n\nregards,\n\n\nrainer\n\n\n--- ../src/git-2.6.2/configure.ac\tFri Oct 16 23:58:26 CEST 2015\n+++ configure.ac\tSun Nov 01 23:19:41 CET 2015\n@@ -1126,7 +1126,13 @@\n   # would then trigger compiler warnings on every single file we compile.\n   for opt in \"\" -mt -pthread -lpthread; do\n      old_CFLAGS=\"$CFLAGS\"\n-     CFLAGS=\"$opt $CFLAGS\"\n+     old_LIBS=\"$LIBS\"\n+     if test \"$(echo $opt | cut -b 1-2)\" = -l ; then\n+        LIBS=\"$opt $LIBS\"\n+     else\n+        CFLAGS=\"$opt $CFLAGS\"\n+     fi\n+\n      AC_MSG_CHECKING([for POSIX Threads with '$opt'])\n      AC_LINK_IFELSE([PTHREADTEST_SRC],\n \t[AC_MSG_RESULT([yes])\n@@ -1138,6 +1144,7 @@\n \t],\n \t[AC_MSG_RESULT([no])])\n       CFLAGS=\"$old_CFLAGS\"\n+      LIBS=\"$old_LIBS\"\n   done\n   if test $threads_found != yes; then\n     AC_CHECK_LIB([pthread], [pthread_create],\n"},{"id":"272726","messageId":"vpqa8qwst4y.fsf@anie.imag.fr","threadId":"40701","inReplyTo":"201511012230.tA1MUGa5016836@tezro.nonet","subject":"Re: configure: -lpthread doesn't belong in CFLAGS","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-11-02T08:27:41Z","receivedAt":"2015-11-02T08:27:41Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Rainer M. Canavan\" <git@canavan.de> writes:\n\n> Hi,\n\nHi,\n\nThanks for the patch. However, it will need a bit more work to be\nintegrated into git.git.\n\nPlease, read\nhttps://github.com/git/git/blob/master/Documentation/SubmittingPatches\n\nThe body of your email should end up being the commit message. It is not\n(yet) properly written as such. Also, read about Developer's Certificate\nof Origin in the document above.\n\n>    for opt in \"\" -mt -pthread -lpthread; do\n>       old_CFLAGS=\"$CFLAGS\"\n> -     CFLAGS=\"$opt $CFLAGS\"\n> +     old_LIBS=\"$LIBS\"\n> +     if test \"$(echo $opt | cut -b 1-2)\" = -l ; then\n\nDon't use \"echo\" on string that may begin with - (different versions of\necho will have different behaviors). One option is to use \"printf\" which\nis more robust. Another one, more elegant IMHO in this case is to use a\ncase:\n\ncase \"$opt\" in\n   -l*)\n      # ...\n      ;;\n   *)\n      # ...\n      ;;\nesac\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"272984","messageId":"201511060111.tA61BbFX084361@tezro.nonet","threadId":"40701","inReplyTo":"vpqa8qwst4y.fsf@anie.imag.fr","subject":"[PATCH] In configure.ac, try -lpthread in $LIBS instead of $CFLAGS to make picky linkers happy","fromName":"Rainer M. Canavan","fromEmail":"git@canavan.de","sentAt":"2015-11-06T01:11:37Z","receivedAt":"2015-11-06T01:11:37Z","isPatch":true,"sender":{"key":"git@canavan.de","avatar":null},"body":"Some linkers, namely the one on IRIX are rather strict concerning the order or\narguments for symbol resolution, i.e. no libraries listed before objects or\nother libraries on the command line are considered for symbol resolution. \nTherefore, -lpthread can't work if it's put in CFLAGS, because it will not be\nconsidered for resolving pthread_key_create in conftest.o. Use $LIBS instead.\n\nSigned-off-by: Rainer Canavan <git@canavan.de>\n---\n configure.ac | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/configure.ac b/configure.ac\nindex fd22d41..1f55009 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -1149,7 +1149,12 @@ elif test -z \"$PTHREAD_CFLAGS\"; then\n   # would then trigger compiler warnings on every single file we compile.\n   for opt in \"\" -mt -pthread -lpthread; do\n      old_CFLAGS=\"$CFLAGS\"\n-     CFLAGS=\"$opt $CFLAGS\"\n+     old_LIBS=\"$LIBS\"\n+     case \"$opt\" in\n+        -l*)  LIBS=\"$opt $LIBS\" ;;\n+        *)    CFLAGS=\"$opt $CFLAGS\" ;;\n+     esac\n+\n      AC_MSG_CHECKING([for POSIX Threads with '$opt'])\n      AC_LINK_IFELSE([PTHREADTEST_SRC],\n \t[AC_MSG_RESULT([yes])\n@@ -1161,6 +1166,7 @@ elif test -z \"$PTHREAD_CFLAGS\"; then\n \t],\n \t[AC_MSG_RESULT([no])])\n       CFLAGS=\"$old_CFLAGS\"\n+      LIBS=\"$old_LIBS\"\n   done\n   if test $threads_found != yes; then\n     AC_CHECK_LIB([pthread], [pthread_create],\n-- \n2.6.2\n"},{"id":"272995","messageId":"vpqbnb7edqn.fsf@anie.imag.fr","threadId":"40701","inReplyTo":"201511060111.tA61BbFX084361@tezro.nonet","subject":"Re: [PATCH] In configure.ac, try -lpthread in $LIBS instead of $CFLAGS to make picky linkers happy","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-11-06T08:25:20Z","receivedAt":"2015-11-06T08:25:20Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Rainer M. Canavan\" <git@canavan.de> writes:\n\n> Subject: Re: [PATCH] In configure.ac, try -lpthread in $LIBS instead of $CFLAGS to make picky linkers happy\n\nThe patch looks good, but the subject should be improved. We normally\ntry to stick to 50 characters (to let \"git log --oneline\" fit in a 80\ncolumns terminal). 50 is a bit strict and not always followed, but yours\nis definitely too long.\n\nAlso, the convention is \"subsystem: what you did\". I'd suggest this:\n\nconfigure.ac: try -lpthread in $LIBS instead of $CFLAGS\n\nThe \"to make picky linkers happy\" is important, but redundant with the\nbody of the message.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"273067","messageId":"201511081528.tA8FSgdc003895@tezro.nonet","threadId":"40701","inReplyTo":"vpqbnb7edqn.fsf@anie.imag.fr","subject":"[PATCH] configure.ac: try -lpthread in $LIBS instead of $CFLAGS","fromName":"Rainer M. Canavan","fromEmail":"git@canavan.de","sentAt":"2015-11-08T15:28:42Z","receivedAt":"2015-11-08T15:28:42Z","isPatch":true,"sender":{"key":"git@canavan.de","avatar":null},"body":"Some linkers, namely the one on IRIX are rather strict concerning the order or\narguments for symbol resolution, i.e. no libraries listed before objects or\nother libraries on the command line are considered for symbol resolution. That\nmeans that -lpthread can't work if it's put in CFLAGS, because it will not be\nconsidered for resolving pthread_key_create in conftest.o. Use $LIBS instead.\n\nSigned-off-by: Rainer Canavan <git@canavan.de>\n---\n configure.ac | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/configure.ac b/configure.ac\nindex fd22d41..1f55009 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -1149,7 +1149,12 @@ elif test -z \"$PTHREAD_CFLAGS\"; then\n   # would then trigger compiler warnings on every single file we compile.\n   for opt in \"\" -mt -pthread -lpthread; do\n      old_CFLAGS=\"$CFLAGS\"\n-     CFLAGS=\"$opt $CFLAGS\"\n+     old_LIBS=\"$LIBS\"\n+     case \"$opt\" in\n+        -l*)  LIBS=\"$opt $LIBS\" ;;\n+        *)    CFLAGS=\"$opt $CFLAGS\" ;;\n+     esac\n+\n      AC_MSG_CHECKING([for POSIX Threads with '$opt'])\n      AC_LINK_IFELSE([PTHREADTEST_SRC],\n \t[AC_MSG_RESULT([yes])\n@@ -1161,6 +1166,7 @@ elif test -z \"$PTHREAD_CFLAGS\"; then\n \t],\n \t[AC_MSG_RESULT([no])])\n       CFLAGS=\"$old_CFLAGS\"\n+      LIBS=\"$old_LIBS\"\n   done\n   if test $threads_found != yes; then\n     AC_CHECK_LIB([pthread], [pthread_create],\n-- \n2.6.2\n"},{"id":"273068","messageId":"vpqy4e8cwhr.fsf@anie.imag.fr","threadId":"40701","inReplyTo":"201511081528.tA8FSgdc003895@tezro.nonet","subject":"Re: [PATCH] configure.ac: try -lpthread in $LIBS instead of $CFLAGS","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-11-08T16:00:00Z","receivedAt":"2015-11-08T16:00:00Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Rainer M. Canavan\" <git@canavan.de> writes:\n\n>  configure.ac | 8 +++++++-\n>  1 file changed, 7 insertions(+), 1 deletion(-)\n\nLooks all right to me. Thanks for you contribution and for your\npatience!\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"273535","messageId":"20151120114207.GG11198@sigill.intra.peff.net","threadId":"40701","inReplyTo":"vpqy4e8cwhr.fsf@anie.imag.fr","subject":"Re: [PATCH] configure.ac: try -lpthread in $LIBS instead of $CFLAGS","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-11-20T11:42:07Z","receivedAt":"2015-11-20T11:42:07Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 08, 2015 at 05:00:00PM +0100, Matthieu Moy wrote:\n\n> \"Rainer M. Canavan\" <git@canavan.de> writes:\n> \n> >  configure.ac | 8 +++++++-\n> >  1 file changed, 7 insertions(+), 1 deletion(-)\n> \n> Looks all right to me. Thanks for you contribution and for your\n> patience!\n\nThanks, both. I've queued this to eventually hit \"maint\".\n\n-Peff\n"}]}