{"thread":{"id":"45531","subject":"Git fails to build on Ubuntu Server 16.04","startedAt":"2017-03-28T23:17:27Z","lastAt":"2017-03-29T03:18:45Z","messageCount":2,"participants":["Jeffrey Walton","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"315631","messageId":"CAH8yC8kexrV8d7Tg_vCCM+GWsNH82386HEyN=XSguqZjcOuPzQ@mail.gmail.com","threadId":"45531","inReplyTo":null,"subject":"Git fails to build on Ubuntu Server 16.04","fromName":"Jeffrey Walton","fromEmail":"noloader@gmail.com","sentAt":"2017-03-28T23:17:16Z","receivedAt":"2017-03-28T23:17:27Z","isPatch":false,"sender":{"key":"noloader@gmail.com","avatar":null},"body":"I configured with --enable-pthreads, and LIBS included -lpthread.\n\n$ make V=1\ngcc -I/usr/local/include -g -O2 -I. -DHAVE_ALLOCA_H\n-I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -I/usr/local/include\n-I/usr/local/include  -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY\n-DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_GETDELIM\n-DSHA1_HEADER='<openssl/sha.h>'  -DNO_STRLCPY -DSHELL_PATH='\"/bin/sh\"'\n-DPAGER_ENV='\"LESS=FRX LV=-c\"' -o git-credential-store\n-Wl,-rpath,/usr/local/lib -L/usr/local/lib  credential-store.o\ncommon-main.o libgit.a xdiff/lib.a  -L/usr/local/lib\n-Wl,-rpath,/usr/local/lib -lz -L/usr/local/lib\n-Wl,-rpath,/usr/local/lib -lcrypto  -lrt\n/usr/bin/ld: libgit.a(run-command.o): undefined reference to symbol\n'pthread_sigmask@@GLIBC_2.2.5'\n//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO\nmissing from command line\ncollect2: error: ld returned 1 exit status\nMakefile:2053: recipe for target 'git-credential-store' failed\nmake: *** [git-credential-store] Error 1\n\n\nIf the makefile is modified after 'make configure':\n\n    find `pwd` -name Makefile -exec sed -i 's|-lrt|-lrt -lpthread|g' {} \\;\n\nThen Git builds successfully.\n\nIt appears the request to use pthreads is not being honored.\n\nThanks.\n"},{"id":"315647","messageId":"20170329031836.h2j3hja4ktocbv6i@sigill.intra.peff.net","threadId":"45531","inReplyTo":"CAH8yC8kexrV8d7Tg_vCCM+GWsNH82386HEyN=XSguqZjcOuPzQ@mail.gmail.com","subject":"Re: Git fails to build on Ubuntu Server 16.04","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-03-29T03:18:37Z","receivedAt":"2017-03-29T03:18:45Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Mar 28, 2017 at 07:17:16PM -0400, Jeffrey Walton wrote:\n\n> I configured with --enable-pthreads, and LIBS included -lpthread.\n> \n> $ make V=1\n> gcc -I/usr/local/include -g -O2 -I. -DHAVE_ALLOCA_H\n> -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -I/usr/local/include\n> -I/usr/local/include  -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY\n> -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_GETDELIM\n> -DSHA1_HEADER='<openssl/sha.h>'  -DNO_STRLCPY -DSHELL_PATH='\"/bin/sh\"'\n> -DPAGER_ENV='\"LESS=FRX LV=-c\"' -o git-credential-store\n> -Wl,-rpath,/usr/local/lib -L/usr/local/lib  credential-store.o\n> common-main.o libgit.a xdiff/lib.a  -L/usr/local/lib\n> -Wl,-rpath,/usr/local/lib -lz -L/usr/local/lib\n> -Wl,-rpath,/usr/local/lib -lcrypto  -lrt\n> /usr/bin/ld: libgit.a(run-command.o): undefined reference to symbol\n> 'pthread_sigmask@@GLIBC_2.2.5'\n> //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO\n> missing from command line\n> collect2: error: ld returned 1 exit status\n> Makefile:2053: recipe for target 'git-credential-store' failed\n> make: *** [git-credential-store] Error 1\n\nHmm. I can reproduce with:\n\n  LIBS=-lpthread ./configure --enable-pthreads\n  make\n\nI think the problem is that $LIBS is meaningful to autoconf, but not to\nGit's Makefile. So it tricks autoconf into writing a blank PTHREAD_LIBS\nvariable (because it can compile a pthread program without any extra\noptions), but the Makefile does not include $LIBS.\n\nJust doing:\n\n  ./configure --enable-pthreads\n  make\n\nworks fine. So should:\n\n  ./configure\n  make\n\nwhich should detect pthreads. Or just:\n\n  make\n\nas building with pthreads is the default on Linux.\n\nSo depending on your perspective, it's either:\n\n  - not a bug (because we do not advertise $LIBS as a meaningful input\n    to the build process)\n\n  - a bug that the configure script respects $LIBS at all, since it is\n    not meaningful to the Makefile\n\n  - a bug that the configure script does not propagate $LIBS into\n    something the Makefile _does_ understand, like $EXTLIBS\n\n  - a bug that the Makefile does not care about $LIBS\n\nPatches welcome for any of the latter three (I do not have an opinion\nmyself; I don't use autoconf at all).\n\n-Peff\n"}]}