Skip to contentSkip to conversation

Makefile: fix default regex settings on Darwin

PATCH In review David Aguilar 3 participants 8 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 Makefile: fix default regex settings on Darwin

t0070-fundamental.sh fails on Mac OS X 10.8:

	$ uname -a
	Darwin lustrous 12.2.0 Darwin Kernel Version 12.2.0:
	Sat Aug 25 00:48:52 PDT 2012;
	root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
	$ ./t0070-fundamental.sh -v
	fatal: regex bug confirmed: re-build git with NO_REGEX=1

Fix it by using Git's regex library.

---
Added uname output and Jonathan's review tag.

 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index 0f931a2..f698c1a 100644
@@ -1054,6 +1054,7 @@ ifeq ($(uname_S),Darwin)
 			BASIC_LDFLAGS += -L/opt/local/lib
 		endif
 	endif
+	NO_REGEX = YesPlease
 	PTHREAD_LIBS =
 endif
 
Signature · 1 line
1.8.3.rc1.47.g41936fa
#1 lore raw

PATCH v2 2/3 imap-send: eliminate HMAC warnings on OS X 10.8

Mac OS X Mountain Lion warns that HMAC_Init() and friends are deprecated. Use CommonCrypto's HMAC to eliminate the warnings.

---
Rebased to 2/3.

 Makefile    |  5 +++++
 imap-send.c | 10 ++++++++++
 2 files changed, 15 insertions(+)
Makefile +5 -0
index f698c1a..25282b4 100644
@@ -1054,6 +1054,7 @@ ifeq ($(uname_S),Darwin)
 			BASIC_LDFLAGS += -L/opt/local/lib
 		endif
 	endif
+	COMMON_DIGEST_HMAC = YesPlease
 	NO_REGEX = YesPlease
 	PTHREAD_LIBS =
 endif
@@ -1393,6 +1394,10 @@ else
 	EXTLIBS += $(LIB_4_CRYPTO)
 endif
 endif
+
+ifdef COMMON_DIGEST_HMAC
+	BASIC_CFLAGS += -DCOMMON_DIGEST_FOR_HMAC=1
+endif
 ifdef NO_PERL_MAKEMAKER
 	export NO_PERL_MAKEMAKER
 endif
imap-send.c +10 -0
index d9bcfb4..1b2e69c 100644
@@ -29,8 +29,18 @@
 #ifdef NO_OPENSSL
 typedef void *SSL;
 #else
+#ifdef COMMON_DIGEST_FOR_HMAC
+#include <CommonCrypto/CommonHMAC.h>
+#define HMAC_CTX CCHmacContext
+#define HMAC_Init(hmac, key, len, algo) CCHmacInit(hmac, algo, key, len)
+#define HMAC_Update CCHmacUpdate
+#define HMAC_Final(hmac, hash, ptr) CCHmacFinal(hmac, hash)
+#define HMAC_CTX_cleanup
+#define EVP_md5() kCCHmacAlgMD5
+#else
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
+#endif
 #include <openssl/x509v3.h>
 #endif
 
Signature · 1 line
1.8.3.rc1.47.g41936fa
#2 lore raw

PATCH v2 3/3 cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8

Mac OS X Mountain Lion prints warnings when building git:

warning: 'SHA1_Init' is deprecated (declared at /usr/include/openssl/sha.h:121)

Silence the warnings by using the Common Digest SHA-1 functions for SHA1_Init(), SHA1_Update(), and SHA1_Final().

Add a COMMON_DIGEST_SHA1 knob to the Makefile to allow choosing this implementation and define it by default on Darwin.

---
Unchanged since last time; rebased to 3/3.

 Makefile | 7 +++++++
 cache.h  | 7 +++++++
 2 files changed, 14 insertions(+)
Makefile +7 -0
index 25282b4..8b2f9cc 100644
@@ -1055,6 +1055,7 @@ ifeq ($(uname_S),Darwin)
 		endif
 	endif
 	COMMON_DIGEST_HMAC = YesPlease
+	COMMON_DIGEST_SHA1 = YesPlease
 	NO_REGEX = YesPlease
 	PTHREAD_LIBS =
 endif
@@ -1390,10 +1391,16 @@ ifdef PPC_SHA1
 	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
 	LIB_H += ppc/sha1.h
 else
+ifdef COMMON_DIGEST_SHA1
+	BASIC_CFLAGS += -DCOMMON_DIGEST_FOR_SHA1=1
+	SHA1_HEADER = <CommonCrypto/CommonDigest.h>
+	EXTLIBS += $(LIB_4_CRYPTO)
+else
 	SHA1_HEADER = <openssl/sha.h>
 	EXTLIBS += $(LIB_4_CRYPTO)
 endif
 endif
+endif
 
 ifdef COMMON_DIGEST_HMAC
 	BASIC_CFLAGS += -DCOMMON_DIGEST_FOR_HMAC=1
cache.h +7 -0
index 94ca1ac..e2b24c6 100644
@@ -10,11 +10,18 @@
 
 #include SHA1_HEADER
 #ifndef git_SHA_CTX
+#ifdef COMMON_DIGEST_FOR_SHA1
+#define git_SHA_CTX	CC_SHA1_CTX
+#define git_SHA1_Init	CC_SHA1_Init
+#define git_SHA1_Update	CC_SHA1_Update
+#define git_SHA1_Final	CC_SHA1_Final
+#else
 #define git_SHA_CTX	SHA_CTX
 #define git_SHA1_Init	SHA1_Init
 #define git_SHA1_Update	SHA1_Update
 #define git_SHA1_Final	SHA1_Final
 #endif
+#endif
 
 #include <zlib.h>
 typedef struct git_zstream {
Signature · 1 line
1.8.3.rc1.47.g41936fa
#3 lore raw

Re: [PATCH v2 3/3] cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8

Quoted 8 lines · David Aguilar

Mac OS X Mountain Lion prints warnings when building git:

warning: 'SHA1_Init' is deprecated (declared at /usr/include/openssl/sha.h:121)

Silence the warnings by using the Common Digest SHA-1 functions for SHA1_Init(), SHA1_Update(), and SHA1_Final().

Quoted 6 lines

Add a COMMON_DIGEST_SHA1 knob to the Makefile to allow choosing this implementation and define it by default on Darwin.

---
Unchanged since last time; rebased to 3/3.

Ignore my earlier response. I had not seen your revised patches. With this patch series, the SHA1_Foo() warnings are indeed resolved, however, there are still a bunch of remaining deprecation warnings regarding ERR_error_string, SSL_get_error, X509_get_ext_d2i, and so forth.

#4 lore raw

Re: [PATCH v2 3/3] cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8

Quoted 16 lines · Eric Sunshine
Quoted 8 lines · David Aguilar

Mac OS X Mountain Lion prints warnings when building git:

warning: 'SHA1_Init' is deprecated (declared at /usr/include/openssl/sha.h:121)

Silence the warnings by using the Common Digest SHA-1 functions for SHA1_Init(), SHA1_Update(), and SHA1_Final().

Quoted 6 lines

Add a COMMON_DIGEST_SHA1 knob to the Makefile to allow choosing this implementation and define it by default on Darwin.

---
Unchanged since last time; rebased to 3/3.

Quoted 5 lines

Ignore my earlier response. I had not seen your revised patches. With this patch series, the SHA1_Foo() warnings are indeed resolved, however, there are still a bunch of remaining deprecation warnings regarding ERR_error_string, SSL_get_error, X509_get_ext_d2i, and so forth.

Yup, warnings still remain, but only in imap-send.c. All the SHA1 ones are gone. Those were particularly bothersome since they affected several files.

I haven't dug to deeply into how to fix these. In case anyone has any pointers, the warnings look like this:

imap-send.c: In function ‘ssl_socket_perror’:
imap-send.c:185: warning: ‘ERR_error_string’ is deprecated (declared at /usr/include/openssl/err.h:279)
imap-send.c:185: warning: ‘ERR_get_error’ is deprecated (declared at /usr/include/openssl/err.h:266)
imap-send.c: In function ‘socket_perror’:
imap-send.c:193: warning: ‘SSL_get_error’ is deprecated (declared at /usr/include/openssl/ssl.h:1501)
imap-send.c: In function ‘verify_hostname’:
imap-send.c:245: warning: ‘X509_get_ext_d2i’ is deprecated (declared at /usr/include/openssl/x509.h:1151)
imap-send.c:246: warning: ‘sk_num’ is deprecated (declared at /usr/include/openssl/stack.h:81)
imap-send.c:248: warning: ‘sk_value’ is deprecated (declared at /usr/include/openssl/stack.h:82)
imap-send.c:254: warning: ‘sk_pop_free’ is deprecated (declared at /usr/include/openssl/stack.h:89)
imap-send.c:260: warning: ‘X509_get_subject_name’ is deprecated (declared at /usr/include/openssl/x509.h:1013) imap-send.c:262: warning: ‘X509_NAME_get_text_by_NID’ is deprecated (declared at /usr/include/openssl/x509.h:1099)
imap-send.c: In function ‘ssl_socket_connect’:
imap-send.c:281: warning: ‘SSL_library_init’ is deprecated (declared at /usr/include/openssl/ssl.h:1553)
imap-send.c:282: warning: ‘SSL_load_error_strings’ is deprecated (declared at /usr/include/openssl/ssl.h:1416) imap-send.c:285: warning: ‘TLSv1_method’ is deprecated (declared at /usr/include/openssl/ssl.h:1519)
imap-send.c:287: warning: ‘SSLv23_method’ is deprecated (declared at /usr/include/openssl/ssl.h:1515)
imap-send.c:294: warning: ‘SSL_CTX_new’ is deprecated (declared at /usr/include/openssl/ssl.h:1346)
imap-send.c:297: warning: ‘SSL_CTX_set_verify’ is deprecated (declared at /usr/include/openssl/ssl.h:1459)
imap-send.c:299: warning: ‘SSL_CTX_set_default_verify_paths’ is deprecated (declared at /usr/include/openssl/ssl.h:1570) imap-send.c:303: warning: ‘SSL_new’ is deprecated (declared at /usr/include/openssl/ssl.h:1481)
imap-send.c:308: warning: ‘SSL_set_rfd’ is deprecated (declared at /usr/include/openssl/ssl.h:1371)
imap-send.c:312: warning: ‘SSL_set_wfd’ is deprecated (declared at /usr/include/openssl/ssl.h:1372)
imap-send.c:323: warning: ‘SSL_ctrl’ is deprecated (declared at /usr/include/openssl/ssl.h:1496)
imap-send.c:328: warning: ‘SSL_connect’ is deprecated (declared at /usr/include/openssl/ssl.h:1492)
imap-send.c:336: warning: ‘SSL_get_peer_certificate’ is deprecated (declared at /usr/include/openssl/ssl.h:1450)
imap-send.c: In function ‘socket_read’:
imap-send.c:352: warning: ‘SSL_read’ is deprecated (declared at /usr/include/openssl/ssl.h:1493)
imap-send.c: In function ‘socket_write’:
imap-send.c:370: warning: ‘SSL_write’ is deprecated (declared at /usr/include/openssl/ssl.h:1495)
imap-send.c: In function ‘socket_shutdown’:
imap-send.c:387: warning: ‘SSL_shutdown’ is deprecated (declared at /usr/include/openssl/ssl.h:1532)
imap-send.c:388: warning: ‘SSL_free’ is deprecated (declared at /usr/include/openssl/ssl.h:1490)
imap-send.c: In function ‘cram’:
imap-send.c:906: warning: ‘EVP_DecodeBlock’ is deprecated (declared at /usr/include/openssl/evp.h:634)
imap-send.c:913: warning: statement with no effect imap-send.c:927: warning: ‘EVP_EncodeBlock’ is deprecated (declared at /usr/include/openssl/evp.h:627)

Cheers,
--
David

#5 lore raw

Re: [PATCH v2 3/3] cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8

Quoted 10 lines · David Aguilar

Yup, warnings still remain, but only in imap-send.c. All the SHA1 ones are gone. Those were particularly bothersome since they affected several files.

I haven't dug to deeply into how to fix these. In case anyone has any pointers, the warnings look like this:

imap-send.c: In function ‘ssl_socket_perror’:
imap-send.c:185: warning: ‘ERR_error_string’ is deprecated (declared at /usr/include/openssl/err.h:279)

Hmph.

I thought your separate imap-send patch switched to CommonCrypto. Why are you still including from /usr/include/openssl/?

By the way, is CommonCrypo anything "common"? I am geting an impression that it is an Apple-only thing, and if that is the case the naming feels somewhat funny.

#6 lore raw

Re: [PATCH v2 3/3] cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8

Quoted 13 lines · Junio C Hamano
Quoted 10 lines · David Aguilar

Yup, warnings still remain, but only in imap-send.c. All the SHA1 ones are gone. Those were particularly bothersome since they affected several files.

I haven't dug to deeply into how to fix these. In case anyone has any pointers, the warnings look like this:

imap-send.c: In function ‘ssl_socket_perror’:
imap-send.c:185: warning: ‘ERR_error_string’ is deprecated (declared at /usr/include/openssl/err.h:279)

Quoted 8 lines

Hmph.

I thought your separate imap-send patch switched to CommonCrypto. Why are you still including from /usr/include/openssl/?

By the way, is CommonCrypo anything "common"? I am geting an impression that it is an Apple-only thing, and if that is the case the naming feels somewhat funny.

Far from common -- it's an Apple-ism.

The imap-send patch switches the HMAC parts to CommonCrypto and do eliminate the HMAC warnings. It still includes the x509 headers from SSL. I haven't figured those out.
--
David

#7 lore raw

Re: [PATCH v2 3/3] cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8

In reply to David Aguilar
Quoted 25 lines · David Aguilar

Mac OS X Mountain Lion prints warnings when building git:

warning: 'SHA1_Init' is deprecated (declared at /usr/include/openssl/sha.h:121)

Silence the warnings by using the Common Digest SHA-1 functions for SHA1_Init(), SHA1_Update(), and SHA1_Final().

Add a COMMON_DIGEST_SHA1 knob to the Makefile to allow choosing this implementation and define it by default on Darwin.

---
Unchanged since last time; rebased to 3/3.

cache.h +2 -0
index 94ca1ac..e2b24c6 100644
 @@ -10,11 +10,18 @@
 
 #include SHA1_HEADER
 #ifndef git_SHA_CTX
+#ifdef COMMON_DIGEST_FOR_SHA1
+#define git_SHA_CTX CC_SHA1_CTX

cache.h

Quoted 10 lines
cache.h +5 -0
+#define git_SHA1_Init CC_SHA1_Init
+#define git_SHA1_Update CC_SHA1_Update
+#define git_SHA1_Final CC_SHA1_Final
+#else
 #define git_SHA_CTX SHA_CTX
 #define git_SHA1_Init SHA1_Init
 #define git_SHA1_Update SHA1_Update
 #define git_SHA1_Final SHA1_Final
 #endif
+#endif

Reading [*1*], it appears that you can get these defines for free by #defining COMMON_DIGEST_FOR_OPENSSL before including <CommonCrypto/CommonDigest.h>, so this patch hunk can be eliminated, which is nice since you don't have to pollute cache.h with any Apple-specific ugliness. Also, according to [*1*], you need only link against libSystem (or System.framework), so you can drop the $(LIB_4_CRYPTO) reference too. The entire patch therefore reduces to (excuse whitespace corruption):

-->8--

Makefile +6 -0
index 25282b4..a080d20 100644
@@ -1055,6 +1055,7 @@ ifeq ($(uname_S),Darwin)
                endif
        endif
        COMMON_DIGEST_HMAC = YesPlease
+       COMMON_DIGEST_SHA1 = YesPlease
        NO_REGEX = YesPlease
        PTHREAD_LIBS =
 endif
@@ -1390,10 +1391,15 @@ ifdef PPC_SHA1
        LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
        LIB_H += ppc/sha1.h
 else
+ifdef COMMON_DIGEST_SHA1
+       BASIC_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL
+       SHA1_HEADER = <CommonCrypto/CommonDigest.h>
+else
        SHA1_HEADER = <openssl/sha.h>
        EXTLIBS += $(LIB_4_CRYPTO)
 endif
 endif
+endif
 
 ifdef COMMON_DIGEST_HMAC
        BASIC_CFLAGS += -DCOMMON_DIGEST_FOR_HMAC=1

-->8--

[*1*] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/CommonCrypto/CommonDigest.h