threads / discuss / 40546

Solaris: Fail to build git with CFLAGS=-m64

Subject: Solaris: Fail to build git with CFLAGS=-m64

## tl;dr

3 messages between Oct 13, 2015 and Oct 13, 2015.

replies: 2people: 2as markdown or json

evgeny litvinenko· Oct 13, 2015, 06:30 UTC · lore
Hi.

Tried to build git-2.6.1 on Solaris (Oracle Solaris 11.2 and OpenIndiana 151.1.9) with CFLAGS="-m64" and got an error during make step:

GIT_VERSION = 2.6.1
    * new build flags
gcc -o credential-store.o -c -MF ./.depend/credential-store.o.d -MQ
credential-store.o -MMD -MP  --save-temps -O2 -m64 -I.
-D__EXTENSIONS__ -D__sun__ -DHAVE_ALLOCA_H -DNO_D_TYPE_IN_DIRENT
-DNO_INET_NTOP -DNO_INET_PTON  -DHAVE_PATHS_H -DHAVE_STRINGS_H
-DHAVE_DEV_TTY -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC
-DHAVE_GETDELIM -DSHA1_HEADER='<openssl/sha.h>'  -Icompat/regex
-DSHELL_PATH='"/bin/bash"'  credential-store.c
In file included from cache.h:4:0,
                 from credential-store.c:1:
git-compat-util.h:689:13: error: conflicting types for inet_ntop
/usr/include/arpa/inet.h:43:20: note: previous declaration of inet_ntop was here
gmake: *** [credential-store.o] Error 1
Solaris has the following prototype in the file /usr/include/arpa/inet.h:

extern const char *inet_ntop(int, const void *_RESTRICT_KYWD, char *_RESTRICT_KYWD, socklen_t);

Git's prototype for inet_ntop is in file git-compat-util.h:

#ifdef NO_INET_NTOP const char *inet_ntop(int af, const void *src, char *dst, size_t size); #endif

When build with -m64 typedefs for socklen_t

typedef unsigned int uint32_t; typedef uint32_t socklen_t;

and typedefs for size_t

typedef unsigned long ulong_t; typedef ulong_t size_t;

With -m32 both socklen_t and size_t are "unsigned int" and there is no any errors.

Also Solaris has the functions inet_ntop and inet_pton in libnsl.so so I did the following correction to configure.ac to build git with -m64:

diff --git a/configure.ac b/configure.ac
index 14012fa..4cf1929 100644
--- a/configure.ac
+++ b/configure.ac
@@ -637,6 +637,11 @@ AC_CHECK_FUNC([inet_ntop],
        [NEEDS_RESOLV=YesPlease],
        [NO_INET_NTOP=YesPlease])
 ])
+if test "x$ac_cv_func_inet_ntop" != xyes; then
+AC_CHECK_LIB([nsl], [inet_ntop],
+       [NEEDS_NSL=YesPlease; NO_INET_NTOP=],
+       [])
+fi
 GIT_CONF_SUBST([NO_INET_NTOP])
 #
 # Define NO_INET_PTON if linking with -lresolv is not enough.
@@ -648,6 +653,11 @@ AC_CHECK_FUNC([inet_pton],
        [NEEDS_RESOLV=YesPlease],
        [NO_INET_PTON=YesPlease])
 ])
+if test "x$ac_cv_func_inet_pton" != xyes; then
+AC_CHECK_LIB([nsl], [inet_pton],
+       [NEEDS_NSL=YesPlease; NO_INET_PTON=],
+       [])
+fi
 GIT_CONF_SUBST([NO_INET_PTON])
 #
 # Define NO_HSTRERROR if linking with -lresolv is not enough.

Is it possible to change prototype for inet_ntop in git-compat-util.h
or use Solaris's inet_ntop and inet_pton
?

Evgeny
Junio C Hamano· Oct 13, 2015, 07:39 UTC · re: evgeny litvinenko · lore

Re: Solaris: Fail to build git with CFLAGS=-m64

evgeny litvinenko <evgeny.v.litvinenko@gmail.com> writes:
Show 10 quoted lines
> Solaris has the following prototype in the file /usr/include/arpa/inet.h:
>
> extern const char *inet_ntop(int, const void *_RESTRICT_KYWD, char
> *_RESTRICT_KYWD, socklen_t);
>
> Git's prototype for inet_ntop is in file git-compat-util.h:
>
> #ifdef NO_INET_NTOP
> const char *inet_ntop(int af, const void *src, char *dst, size_t size);
> #endif

This tells me that it is designed to be used only when the platform does not offer inet_ntop(). If your platform does have it, why is your build define NO_INET_NTOP?

Perhaps configure generated by autoconf is faulty?

In this project, use of autoconf/configure is optional---in other words, it is expected that you can build successfully by setting and unsetting necessary Makefile macros in your own config.mak without using autoconf/configure at all. I'd try without configure and make sure I do not define NO_INET_NTOP (and if you have inet_pton(), then make sure you do not define NO_INET_PTON either) in config.mak if I were you.

evgeny litvinenko· Oct 13, 2015, 19:06 UTC · re: Junio C Hamano · lore

Re: Solaris: Fail to build git with CFLAGS=-m64

Hi Junio,
On 10/13/15, Junio C Hamano <gitster@pobox.com> wrote:
Show 16 quoted lines
> evgeny litvinenko <evgeny.v.litvinenko@gmail.com> writes:
>
>> Solaris has the following prototype in the file /usr/include/arpa/inet.h:
>>
>> extern const char *inet_ntop(int, const void *_RESTRICT_KYWD, char
>> *_RESTRICT_KYWD, socklen_t);
>>
>> Git's prototype for inet_ntop is in file git-compat-util.h:
>>
>> #ifdef NO_INET_NTOP
>> const char *inet_ntop(int af, const void *src, char *dst, size_t size);
>> #endif
>
> This tells me that it is designed to be used only when the platform
> does not offer inet_ntop().  If your platform does have it, why is
> your build define NO_INET_NTOP?

I think this is because configure.ac doesn't check for inet_ntop in libnsl (in Solaris 11.2 inet_ntop and inet_pton are in libnsl) configure.ac checks for these function in libresolv only.

Show 10 quoted lines
> Perhaps configure generated by autoconf is faulty?
>
> In this project, use of autoconf/configure is optional---in other
> words, it is expected that you can build successfully by setting and
> unsetting necessary Makefile macros in your own config.mak without
> using autoconf/configure at all.  I'd try without configure and make
> sure I do not define NO_INET_NTOP (and if you have inet_pton(), then
> make sure you do not define NO_INET_PTON either) in config.mak if I
> were you.
>

Yes, if I do not define NO_INET_NTOP/NO_INET_PTON the build is successful as libnsl is linked - in configure.ac there is 'NEEDS_NSL = YesPlease' for SunOS'es.

evgeny.

← back to recent threads