{"thread":{"id":"40421","subject":"[PATCH v2 1/1] Makefile: link libcurl before openssl and crypto","startedAt":"2015-09-24T17:43:10Z","lastAt":"2015-09-25T00:15:58Z","messageCount":2,"participants":["Remi Pommarel","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":1},"messages":[{"id":"270639","messageId":"1443116590-6222-1-git-send-email-repk@triplefau.lt","threadId":"40421","inReplyTo":null,"subject":"[PATCH v2 1/1] Makefile: link libcurl before openssl and crypto","fromName":"Remi Pommarel","fromEmail":"repk@triplefau.lt","sentAt":"2015-09-24T17:43:10Z","receivedAt":"2015-09-24T17:43:10Z","isPatch":true,"sender":{"key":"repk@triplefau.lt","avatar":"https://avatars.githubusercontent.com/u/6833759?v=4"},"body":"For static linking especially library order while linking is important. For\nexample libssl contains symbol from libcrypto so the former should be linked\nbefore the latter.\n\nThe global link order should be libcurl then libssl then libcrypto then\nlibintl and finally zlib.\n\nSigned-off-by: Remi Pommarel <repk@triplefau.lt>\n---\n Makefile | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex ce0cfe2..59a0747 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1029,7 +1029,6 @@ ifdef HAVE_ALLOCA_H\n endif\n \n IMAP_SEND_BUILDDEPS =\n-IMAP_SEND_LDFLAGS = $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)\n \n ifdef NO_CURL\n \tBASIC_CFLAGS += -DNO_CURL\n@@ -1086,6 +1085,7 @@ else\n \t\tendif\n \tendif\n endif\n+IMAP_SEND_LDFLAGS += $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)\n \n ifdef ZLIB_PATH\n \tBASIC_CFLAGS += -I$(ZLIB_PATH)/include\n@@ -1971,10 +1971,10 @@ git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)\n \n git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n-\t\t$(LIBS) $(CURL_LIBCURL)\n+\t\t$(CURL_LIBCURL) $(LIBS)\n git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n-\t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n+\t\t$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)\n \n git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \\\n@@ -1988,7 +1988,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)\n \n $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n-\t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n+\t\t$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)\n \n $(LIB_FILE): $(LIB_OBJS)\n \t$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $^\n-- \n2.0.1\n"},{"id":"270728","messageId":"xmqqmvwbuzep.fsf@gitster.mtv.corp.google.com","threadId":"40421","inReplyTo":"1443116590-6222-1-git-send-email-repk@triplefau.lt","subject":"Re: [PATCH v2 1/1] Makefile: link libcurl before openssl and crypto","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-25T00:15:58Z","receivedAt":"2015-09-25T00:15:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Remi Pommarel <repk@triplefau.lt> writes:\n\n> For static linking especially library order while linking is important. For\n> example libssl contains symbol from libcrypto so the former should be linked\n> before the latter.\n\nThat example is not a very good one to use for two reasons:\n\n (1) NEEDS_SSL_WITH_CRYPTO is a conter-example of crypto wanting to\n     be before the latter.\n\n (2) More importantly, you are not changing the order between them.\n\nThe breakage you are fixing with this patch is that libcurl want to\ncome before libssl when building http-push, http-fetch, and remote-curl,\nso that is a very good example to use in the above sentence.\n"}]}