# [PATCH] Make git compile with SUNs forte12 compiler

6 messages from 2007-05-12 to 2007-05-13. Participants: Thomas Glanzmann, Matthieu CASTET, Johannes Schindelin, matthieu castet.
Thread: https://gitlist.dev/t/8120

## Thomas Glanzmann, 2007-05-12 21:35

Subject: [PATCH] Make git compile with SUNs forte12 compiler
Message-ID: <11790057101792-git-send-email-sithglan@stud.uni-erlangen.de>
URL: https://gitlist.dev/e/11790057101792-git-send-email-sithglan%40stud.uni-erlangen.de

```
This patch moves two inline functions from a header file to the corresponding c
file. Otherwise forte12 refuses to compile git with the following error:

    LINK git-convert-objects
ld: fatal: symbol `tree_entry_extract' is multiply-defined:
        (file libgit.a(sha1_name.o) type=FUNC; file libgit.a(tree.o) type=FUNC);
ld: fatal: symbol `tree_entry_extract' is multiply-defined:
        (file libgit.a(sha1_name.o) type=FUNC; file libgit.a(tree-walk.o) type=FUNC);
ld: fatal: File processing errors. No output written to git-convert-objects
gmake[1]: *** [git-convert-objects] Error 1

Signed-off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
---
 tree-walk.c |   14 ++++++++++++++
 tree-walk.h |   13 +------------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/tree-walk.c b/tree-walk.c
index cbb24eb..ef57951 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -2,6 +2,20 @@
 #include "tree-walk.h"
 #include "tree.h"
 
+inline int tree_entry_len(const char *name, const unsigned char *sha1)
+{
+	return (char *)sha1 - (char *)name - 1;
+}
+
+inline const unsigned char *tree_entry_extract(struct tree_desc *desc,
+                                     const char **pathp, unsigned int *modep)
+{
+	*pathp = desc->entry.path;
+	*modep = canon_mode(desc->entry.mode);
+	return desc->entry.sha1;
+}
+
+
 static const char *get_mode(const char *str, unsigned int *modep)
 {
 	unsigned char c;
diff --git a/tree-walk.h b/tree-walk.h
index 43458cf..984f19e 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -13,21 +13,10 @@ struct tree_desc {
 	unsigned int size;
 };
 
-static inline const unsigned char *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
-{
-	*pathp = desc->entry.path;
-	*modep = canon_mode(desc->entry.mode);
-	return desc->entry.sha1;
-}
-
-static inline int tree_entry_len(const char *name, const unsigned char *sha1)
-{
-	return (char *)sha1 - (char *)name - 1;
-}
-
 void update_tree_entry(struct tree_desc *);
 void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);
 const unsigned char *tree_entry_extract(struct tree_desc *, const char **, unsigned int *);
+int tree_entry_len(const char *name, const unsigned char *sha1);
 
 /* Helper function that does both of the above and returns true for success */
 int tree_entry(struct tree_desc *, struct name_entry *);
-- 
1.5.1.3

```

## Matthieu CASTET, 2007-05-13 09:47

Subject: Re: [PATCH] Make git compile with SUNs forte12 compiler
Message-ID: <pan.2007.05.13.09.47.32@free.fr>
URL: https://gitlist.dev/e/pan.2007.05.13.09.47.32%40free.fr
In-Reply-To: <11790057101792-git-send-email-sithglan@stud.uni-erlangen.de>

```
Hi,

On Sat, 12 May 2007 23:35:10 +0200, Thomas Glanzmann wrote:

> This patch moves two inline functions from a header file to the
> corresponding c file. Otherwise forte12 refuses to compile git with the
> following error:
> 
Did you understand what you did ?

You can't put a inline global function in a *.c : you need to put it in 
the header so that when parsing other files the compiler finds the 
definition and can inline it.

In your patch, you transform a static inline function to a global 
function whith is not the same thing...


Matthieu

```

## Thomas Glanzmann, 2007-05-13 10:30

Subject: Re: [PATCH] Make git compile with SUNs forte12 compiler
Message-ID: <20070513103038.GC18546@cip.informatik.uni-erlangen.de>
URL: https://gitlist.dev/e/20070513103038.GC18546%40cip.informatik.uni-erlangen.de
In-Reply-To: <pan.2007.05.13.09.47.32@free.fr>

```
Hello,

[ Junio please drop the patch, if you thought about putting it upstream ]

> Did you understand what you did ?

I do. But my objective wasn't get that function inline but get git to compile
under forte12. However. After you pushed me in the right direction I read the
compiler documentation and found a compiler option called "-features=no%extinl"
which makes it possible to compile git as is using forte12.

So if anyone tries to build git for Solaris using forte12 try this
commandline:

export PATH="/opt/forte12/x86/SUNWspro/bin:/usr/ccs/bin:/usr/bin:/usr/openwin/bin"

/opt/csw/bin/gmake \
        CFLAGS='-O -features=no%extinl' \
        CC=/opt/forte12/x86/SUNWspro/bin/cc \
        DESTDIR=/var/tmp/sithglan-pkg/git-1.5.1.4-buildroot \
        ETC_GITCONFIG=/etc/gitconfig \
        INSTALL=/opt/csw/bin/ginstall \
        NO_CURL=1 \
        NO_EXPAT=1 \
        NO_ICONV=1 \
        NO_OPENSSL=1 \
        TAR=/opt/csw/bin/gtar \
        mandir=/usr/share/man \
        prefix=/usr \
        install

Thanks,
        Thomas

```

## Johannes Schindelin, 2007-05-13 10:39

Subject: Re: [PATCH] Make git compile with SUNs forte12 compiler
Message-ID: <Pine.LNX.4.64.0705131238420.6410@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0705131238420.6410%40racer.site
In-Reply-To: <11790057101792-git-send-email-sithglan@stud.uni-erlangen.de>

```
Hi,

On Sat, 12 May 2007, Thomas Glanzmann wrote:

> This patch moves two inline functions from a header file to the 
> corresponding c file.

I think that it is wrong to move inline functions out of a header file. 
Many C compilers will not be able to inline it then.

A better solution (IMHO) is to make it "static inline".

Ciao,
Dscho

```

## Thomas Glanzmann, 2007-05-13 10:52

Subject: Re: [PATCH] Make git compile with SUNs forte12 compiler
Message-ID: <20070513105210.GD18546@cip.informatik.uni-erlangen.de>
URL: https://gitlist.dev/e/20070513105210.GD18546%40cip.informatik.uni-erlangen.de
In-Reply-To: <Pine.LNX.4.64.0705131238420.6410@racer.site>

```
Hello,

> A better solution (IMHO) is to make it "static inline".

they're already static inline. Maybe the sun compiler got confused by
the prototype which is a few lines below and missing the "static". Let
me check ... actually that's it. I make a patch ready.

        Thomas

```

## matthieu castet, 2007-05-13 12:52

Subject: Re: [PATCH] Make git compile with SUNs forte12 compiler
Message-ID: <46470A25.70703@free.fr>
URL: https://gitlist.dev/e/46470A25.70703%40free.fr
In-Reply-To: <20070513103038.GC18546@cip.informatik.uni-erlangen.de>

```
Hi Thomas,

Thomas Glanzmann wrote:
> Hello,
> 
> [ Junio please drop the patch, if you thought about putting it upstream ]
> 
>> Did you understand what you did ?
> 
> I do. But my objective wasn't get that function inline but get git to compile
> under forte12. However. After you pushed me in the right direction I read the
> compiler documentation and found a compiler option called "-features=no%extinl"
> which makes it possible to compile git as is using forte12.
What's strange with your compiler is that it seems to not take care of 
the "static" keyword and thinks about an "extern inline".
Now it could be interesting to understand why.

Let's look at your error [1].
First it only complain about tree_entry_extract not tree_entry_len.

Let's see why ?
If you look in tree-walk.h and search for tree_entry_extract, you will see :

static inline const unsigned char *tree_entry_extract(struct tree_desc 
*desc, const char **pathp, unsigned int *modep)
[...]
const unsigned char *tree_entry_extract(struct tree_desc *, const char 
**, unsigned int *);

This is bad, tree_entry_extract is declared as static inline and as extern.

If you remove the "const unsigned char *tree_entry_extract(struct 
tree_desc *, const char **, unsigned int *);", I bet everybody will be 
happy and no need to extra option for the sun compiler. [2]


Matthieu

[1]
LINK git-convert-objects
ld: fatal: symbol `tree_entry_extract' is multiply-defined:
         (file libgit.a(sha1_name.o) type=FUNC; file libgit.a(tree.o) 
type=FUNC);
ld: fatal: symbol `tree_entry_extract' is multiply-defined:
         (file libgit.a(sha1_name.o) type=FUNC; file 
libgit.a(tree-walk.o) type=FUNC);
ld: fatal: File processing errors. No output written to git-convert-objects

[2] see attached patch



--- a/tree-walk.h	2007-05-13 14:51:01.451827585 +0200
+++ b/tree-walk.h	2007-05-13 14:51:07.450235889 +0200
@@ -27,7 +27,6 @@
 
 void update_tree_entry(struct tree_desc *);
 void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);
-const unsigned char *tree_entry_extract(struct tree_desc *, const char **, unsigned int *);
 
 /* Helper function that does both of the above and returns true for success */
 int tree_entry(struct tree_desc *, struct name_entry *);

```
