threads / discuss / 45531

Git fails to build on Ubuntu Server 16.04

Subject: Git fails to build on Ubuntu Server 16.04

## tl;dr

2 messages between Mar 28, 2017 and Mar 29, 2017.

replies: 1people: 2as markdown or json

Jeffrey Walton· Mar 28, 2017, 23:17 UTC · lore
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

If the makefile is modified after 'make configure':
    find `pwd` -name Makefile -exec sed -i 's|-lrt|-lrt -lpthread|g' {} \;
Then Git builds successfully.
It appears the request to use pthreads is not being honored.
Thanks.
Jeff King· Mar 29, 2017, 03:18 UTC · re: Jeffrey Walton · lore

Re: Git fails to build on Ubuntu Server 16.04

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

← back to recent threads