# Git fails to build on Ubuntu Server 16.04

2 messages from 2017-03-28 to 2017-03-29. Participants: Jeffrey Walton, Jeff King.
Thread: https://gitlist.dev/t/45531

## Jeffrey Walton, 2017-03-28 23:17

Subject: Git fails to build on Ubuntu Server 16.04
Message-ID: <CAH8yC8kexrV8d7Tg_vCCM+GWsNH82386HEyN=XSguqZjcOuPzQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAH8yC8kexrV8d7Tg_vCCM%2BGWsNH82386HEyN%3DXSguqZjcOuPzQ%40mail.gmail.com

```
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, 2017-03-29 03:18

Subject: Re: Git fails to build on Ubuntu Server 16.04
Message-ID: <20170329031836.h2j3hja4ktocbv6i@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20170329031836.h2j3hja4ktocbv6i%40sigill.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:

> 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

```
