Re: Git fails to build on Ubuntu Server 16.04
- From
Jeff King <peff@peff.net>
- Date
- Mar 29, 2017, 03:18 UTC
- Message-ID
- <20170329031836.h2j3hja4ktocbv6i@sigill.intra.peff.net>
- In-Reply-To
- <CAH8yC8kexrV8d7Tg_vCCM+GWsNH82386HEyN=XSguqZjcOuPzQ@mail.gmail.com>
On Tue, Mar 28, 2017 at 07:17:16PM -0400, Jeffrey Walton wrote:
Show 20 quoted lines
> I configured with --enable-pthreads, and LIBS included -lpthread. > > $ make V=1 > gcc -I/usr/local/include -g -O2 -I. -DHAVE_ALLOCA_H > -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -I/usr/local/include > -I/usr/local/include -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY > -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_GETDELIM > -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRLCPY -DSHELL_PATH='"/bin/sh"' > -DPAGER_ENV='"LESS=FRX LV=-c"' -o git-credential-store > -Wl,-rpath,/usr/local/lib -L/usr/local/lib credential-store.o > common-main.o libgit.a xdiff/lib.a -L/usr/local/lib > -Wl,-rpath,/usr/local/lib -lz -L/usr/local/lib > -Wl,-rpath,/usr/local/lib -lcrypto -lrt > /usr/bin/ld: libgit.a(run-command.o): undefined reference to symbol > 'pthread_sigmask@@GLIBC_2.2.5' > //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO > missing from command line > collect2: error: ld returned 1 exit status > Makefile:2053: recipe for target 'git-credential-store' failed > make: *** [git-credential-store] Error 1
Hmm. I can reproduce with:
LIBS=-lpthread ./configure --enable-pthreads make
I think the problem is that $LIBS is meaningful to autoconf, but not to Git's Makefile. So it tricks autoconf into writing a blank PTHREAD_LIBS variable (because it can compile a pthread program without any extra options), but the Makefile does not include $LIBS.
Just doing:
./configure --enable-pthreads make
works fine. So should:
./configure make
which should detect pthreads. Or just:
make
as building with pthreads is the default on Linux.
So depending on your perspective, it's either:
- not a bug (because we do not advertise $LIBS as a meaningful input
to the build process) - a bug that the configure script respects $LIBS at all, since it is
not meaningful to the Makefile - a bug that the configure script does not propagate $LIBS into
something the Makefile _does_ understand, like $EXTLIBS- a bug that the Makefile does not care about $LIBS
Patches welcome for any of the latter three (I do not have an opinion myself; I don't use autoconf at all).
-Peff