{"thread":{"id":"8120","subject":"[PATCH] Make git compile with SUNs forte12 compiler","startedAt":"2007-05-12T21:35:10Z","lastAt":"2007-05-13T12:52:53Z","messageCount":6,"participants":["Thomas Glanzmann","Matthieu CASTET","Johannes Schindelin","matthieu castet"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"41972","messageId":"11790057101792-git-send-email-sithglan@stud.uni-erlangen.de","threadId":"8120","inReplyTo":null,"subject":"[PATCH] Make git compile with SUNs forte12 compiler","fromName":"Thomas Glanzmann","fromEmail":"sithglan@stud.uni-erlangen.de","sentAt":"2007-05-12T21:35:10Z","receivedAt":"2007-05-12T21:35:10Z","isPatch":true,"sender":{"key":"sithglan@stud.uni-erlangen.de","avatar":null},"body":"This patch moves two inline functions from a header file to the corresponding c\nfile. Otherwise forte12 refuses to compile git with the following error:\n\n    LINK git-convert-objects\nld: fatal: symbol `tree_entry_extract' is multiply-defined:\n        (file libgit.a(sha1_name.o) type=FUNC; file libgit.a(tree.o) type=FUNC);\nld: fatal: symbol `tree_entry_extract' is multiply-defined:\n        (file libgit.a(sha1_name.o) type=FUNC; file libgit.a(tree-walk.o) type=FUNC);\nld: fatal: File processing errors. No output written to git-convert-objects\ngmake[1]: *** [git-convert-objects] Error 1\n\nSigned-off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>\n---\n tree-walk.c |   14 ++++++++++++++\n tree-walk.h |   13 +------------\n 2 files changed, 15 insertions(+), 12 deletions(-)\n\ndiff --git a/tree-walk.c b/tree-walk.c\nindex cbb24eb..ef57951 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -2,6 +2,20 @@\n #include \"tree-walk.h\"\n #include \"tree.h\"\n \n+inline int tree_entry_len(const char *name, const unsigned char *sha1)\n+{\n+\treturn (char *)sha1 - (char *)name - 1;\n+}\n+\n+inline const unsigned char *tree_entry_extract(struct tree_desc *desc,\n+                                     const char **pathp, unsigned int *modep)\n+{\n+\t*pathp = desc->entry.path;\n+\t*modep = canon_mode(desc->entry.mode);\n+\treturn desc->entry.sha1;\n+}\n+\n+\n static const char *get_mode(const char *str, unsigned int *modep)\n {\n \tunsigned char c;\ndiff --git a/tree-walk.h b/tree-walk.h\nindex 43458cf..984f19e 100644\n--- a/tree-walk.h\n+++ b/tree-walk.h\n@@ -13,21 +13,10 @@ struct tree_desc {\n \tunsigned int size;\n };\n \n-static inline const unsigned char *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)\n-{\n-\t*pathp = desc->entry.path;\n-\t*modep = canon_mode(desc->entry.mode);\n-\treturn desc->entry.sha1;\n-}\n-\n-static inline int tree_entry_len(const char *name, const unsigned char *sha1)\n-{\n-\treturn (char *)sha1 - (char *)name - 1;\n-}\n-\n void update_tree_entry(struct tree_desc *);\n void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);\n const unsigned char *tree_entry_extract(struct tree_desc *, const char **, unsigned int *);\n+int tree_entry_len(const char *name, const unsigned char *sha1);\n \n /* Helper function that does both of the above and returns true for success */\n int tree_entry(struct tree_desc *, struct name_entry *);\n-- \n1.5.1.3\n"},{"id":"42009","messageId":"pan.2007.05.13.09.47.32@free.fr","threadId":"8120","inReplyTo":"11790057101792-git-send-email-sithglan@stud.uni-erlangen.de","subject":"Re: [PATCH] Make git compile with SUNs forte12 compiler","fromName":"Matthieu CASTET","fromEmail":"castet.matthieu@free.fr","sentAt":"2007-05-13T09:47:32Z","receivedAt":"2007-05-13T09:47:32Z","isPatch":true,"sender":{"key":"castet.matthieu@free.fr","avatar":null},"body":"Hi,\n\nOn Sat, 12 May 2007 23:35:10 +0200, Thomas Glanzmann wrote:\n\n> This patch moves two inline functions from a header file to the\n> corresponding c file. Otherwise forte12 refuses to compile git with the\n> following error:\n> \nDid you understand what you did ?\n\nYou can't put a inline global function in a *.c : you need to put it in \nthe header so that when parsing other files the compiler finds the \ndefinition and can inline it.\n\nIn your patch, you transform a static inline function to a global \nfunction whith is not the same thing...\n\n\nMatthieu\n"},{"id":"42010","messageId":"20070513103038.GC18546@cip.informatik.uni-erlangen.de","threadId":"8120","inReplyTo":"pan.2007.05.13.09.47.32@free.fr","subject":"Re: [PATCH] Make git compile with SUNs forte12 compiler","fromName":"Thomas Glanzmann","fromEmail":"thomas@glanzmann.de","sentAt":"2007-05-13T10:30:38Z","receivedAt":"2007-05-13T10:30:38Z","isPatch":true,"sender":{"key":"thomas@glanzmann.de","avatar":null},"body":"Hello,\n\n[ Junio please drop the patch, if you thought about putting it upstream ]\n\n> Did you understand what you did ?\n\nI do. But my objective wasn't get that function inline but get git to compile\nunder forte12. However. After you pushed me in the right direction I read the\ncompiler documentation and found a compiler option called \"-features=no%extinl\"\nwhich makes it possible to compile git as is using forte12.\n\nSo if anyone tries to build git for Solaris using forte12 try this\ncommandline:\n\nexport PATH=\"/opt/forte12/x86/SUNWspro/bin:/usr/ccs/bin:/usr/bin:/usr/openwin/bin\"\n\n/opt/csw/bin/gmake \\\n        CFLAGS='-O -features=no%extinl' \\\n        CC=/opt/forte12/x86/SUNWspro/bin/cc \\\n        DESTDIR=/var/tmp/sithglan-pkg/git-1.5.1.4-buildroot \\\n        ETC_GITCONFIG=/etc/gitconfig \\\n        INSTALL=/opt/csw/bin/ginstall \\\n        NO_CURL=1 \\\n        NO_EXPAT=1 \\\n        NO_ICONV=1 \\\n        NO_OPENSSL=1 \\\n        TAR=/opt/csw/bin/gtar \\\n        mandir=/usr/share/man \\\n        prefix=/usr \\\n        install\n\nThanks,\n        Thomas\n"},{"id":"42012","messageId":"Pine.LNX.4.64.0705131238420.6410@racer.site","threadId":"8120","inReplyTo":"11790057101792-git-send-email-sithglan@stud.uni-erlangen.de","subject":"Re: [PATCH] Make git compile with SUNs forte12 compiler","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-05-13T10:39:41Z","receivedAt":"2007-05-13T10:39:41Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 12 May 2007, Thomas Glanzmann wrote:\n\n> This patch moves two inline functions from a header file to the \n> corresponding c file.\n\nI think that it is wrong to move inline functions out of a header file. \nMany C compilers will not be able to inline it then.\n\nA better solution (IMHO) is to make it \"static inline\".\n\nCiao,\nDscho\n"},{"id":"42014","messageId":"20070513105210.GD18546@cip.informatik.uni-erlangen.de","threadId":"8120","inReplyTo":"Pine.LNX.4.64.0705131238420.6410@racer.site","subject":"Re: [PATCH] Make git compile with SUNs forte12 compiler","fromName":"Thomas Glanzmann","fromEmail":"thomas@glanzmann.de","sentAt":"2007-05-13T10:52:10Z","receivedAt":"2007-05-13T10:52:10Z","isPatch":true,"sender":{"key":"thomas@glanzmann.de","avatar":null},"body":"Hello,\n\n> A better solution (IMHO) is to make it \"static inline\".\n\nthey're already static inline. Maybe the sun compiler got confused by\nthe prototype which is a few lines below and missing the \"static\". Let\nme check ... actually that's it. I make a patch ready.\n\n        Thomas\n"},{"id":"42020","messageId":"46470A25.70703@free.fr","threadId":"8120","inReplyTo":"20070513103038.GC18546@cip.informatik.uni-erlangen.de","subject":"Re: [PATCH] Make git compile with SUNs forte12 compiler","fromName":"matthieu castet","fromEmail":"castet.matthieu@free.fr","sentAt":"2007-05-13T12:52:53Z","receivedAt":"2007-05-13T12:52:53Z","isPatch":true,"sender":{"key":"castet.matthieu@free.fr","avatar":null},"body":"Hi Thomas,\n\nThomas Glanzmann wrote:\n> Hello,\n> \n> [ Junio please drop the patch, if you thought about putting it upstream ]\n> \n>> Did you understand what you did ?\n> \n> I do. But my objective wasn't get that function inline but get git to compile\n> under forte12. However. After you pushed me in the right direction I read the\n> compiler documentation and found a compiler option called \"-features=no%extinl\"\n> which makes it possible to compile git as is using forte12.\nWhat's strange with your compiler is that it seems to not take care of \nthe \"static\" keyword and thinks about an \"extern inline\".\nNow it could be interesting to understand why.\n\nLet's look at your error [1].\nFirst it only complain about tree_entry_extract not tree_entry_len.\n\nLet's see why ?\nIf you look in tree-walk.h and search for tree_entry_extract, you will see :\n\nstatic inline const unsigned char *tree_entry_extract(struct tree_desc \n*desc, const char **pathp, unsigned int *modep)\n[...]\nconst unsigned char *tree_entry_extract(struct tree_desc *, const char \n**, unsigned int *);\n\nThis is bad, tree_entry_extract is declared as static inline and as extern.\n\nIf you remove the \"const unsigned char *tree_entry_extract(struct \ntree_desc *, const char **, unsigned int *);\", I bet everybody will be \nhappy and no need to extra option for the sun compiler. [2]\n\n\nMatthieu\n\n[1]\nLINK git-convert-objects\nld: fatal: symbol `tree_entry_extract' is multiply-defined:\n         (file libgit.a(sha1_name.o) type=FUNC; file libgit.a(tree.o) \ntype=FUNC);\nld: fatal: symbol `tree_entry_extract' is multiply-defined:\n         (file libgit.a(sha1_name.o) type=FUNC; file \nlibgit.a(tree-walk.o) type=FUNC);\nld: fatal: File processing errors. No output written to git-convert-objects\n\n[2] see attached patch\n\n\n\n--- a/tree-walk.h\t2007-05-13 14:51:01.451827585 +0200\n+++ b/tree-walk.h\t2007-05-13 14:51:07.450235889 +0200\n@@ -27,7 +27,6 @@\n \n void update_tree_entry(struct tree_desc *);\n void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);\n-const unsigned char *tree_entry_extract(struct tree_desc *, const char **, unsigned int *);\n \n /* Helper function that does both of the above and returns true for success */\n int tree_entry(struct tree_desc *, struct name_entry *);\n"}]}