{"thread":{"id":"15598","subject":"[PATCH] fix openssl headers conflicting with custom SHA1 implementations","startedAt":"2008-09-19T20:11:20Z","lastAt":"2008-09-19T20:11:20Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91138","messageId":"alpine.LFD.1.10.0809191414000.6279@xanadu.home","threadId":"15598","inReplyTo":null,"subject":"[PATCH] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-09-19T20:11:20Z","receivedAt":"2008-09-19T20:11:20Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On ARM I have the following compilation errors:\n\n    CC fast-import.o\nIn file included from cache.h:8,\n                 from builtin.h:6,\n                 from fast-import.c:142:\narm/sha1.h:14: error: conflicting types for 'SHA_CTX'\n/usr/include/openssl/sha.h:105: error: previous declaration of 'SHA_CTX' was here\narm/sha1.h:16: error: conflicting types for 'SHA1_Init'\n/usr/include/openssl/sha.h:115: error: previous declaration of 'SHA1_Init' was here\narm/sha1.h:17: error: conflicting types for 'SHA1_Update'\n/usr/include/openssl/sha.h:116: error: previous declaration of 'SHA1_Update' was here\narm/sha1.h:18: error: conflicting types for 'SHA1_Final'\n/usr/include/openssl/sha.h:117: error: previous declaration of 'SHA1_Final' was here\nmake: *** [fast-import.o] Error 1\n\nThis is because openssl header files are always included in \ngit-compat-util.h since commit 684ec6c63c whenever NO_OPENSSL is not \nset, which somehow brings in <openssl/sha1.h> clashing with the custom \nARM version.  Compilation of git is probably broken on PPC too for the \nsame reason.\n\nTurns out that the only file requiring openssl/ssl.h and openssl/err.h \nis imap-send.c.  But only moving those problematic includes there \ndoesn't solve the issue as it also includes cache.h which brings in the \nconflicting header.  So also conditionally including SHA1_HEADER allows \nfor not including it when compiling imap-send.c.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\n---\n\nThis is a bit ugly but given the rat nest of system includes we have I \ndon't know how to solve this any better.\n\ndiff --git a/Makefile b/Makefile\nindex 3c0664a..a0f86dd 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1242,6 +1242,9 @@ endif\n git-%$X: %.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n \n+imap-send.o: imap-send.c GIT-CFLAGS\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -USHA1_HEADER $<\n+\n git-imap-send$X: imap-send.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)\ndiff --git a/cache.h b/cache.h\nindex de8c2b6..d93e086 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -5,7 +5,10 @@\n #include \"strbuf.h\"\n #include \"hash.h\"\n \n+#ifdef SHA1_HEADER\n #include SHA1_HEADER\n+#endif\n+\n #include <zlib.h>\n \n #if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex db2836f..044f62b 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -99,11 +99,6 @@\n #include <iconv.h>\n #endif\n \n-#ifndef NO_OPENSSL\n-#include <openssl/ssl.h>\n-#include <openssl/err.h>\n-#endif\n-\n /* On most systems <limits.h> would have given us this, but\n  * not on some systems (e.g. GNU/Hurd).\n  */\ndiff --git a/imap-send.c b/imap-send.c\nindex af7e08c..01f1c9a 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -22,11 +22,15 @@\n  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n  */\n \n-#include \"cache.h\"\n #ifdef NO_OPENSSL\n typedef void *SSL;\n+#else\n+#include <openssl/ssl.h>\n+#include <openssl/err.h>\n #endif\n \n+#include \"cache.h\"\n+\n struct store_conf {\n \tchar *name;\n \tconst char *path; /* should this be here? its interpretation is driver-specific */\n\n\n\n\nNicolas\n"}]}