From 714daaf5706e9e2b196beb5446cc4f53d1652c75 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 19 Sep 2016 00:51:35 -0400 Subject: [PATCH] Fix broken Clang compile with -march=x86-64 (Issue 283) It would be great if Clang stopped pretending to be other compilers. In the absence of honesty, it would be nice if it consumed the same programs GCC does --- config.compat | 14 ++++++++++++-- config.h | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config.compat b/config.compat index a6dd2fb6..824009ef 100644 --- a/config.compat +++ b/config.compat @@ -127,7 +127,9 @@ // Under GCC, the library uses init_priority attribute in the range // [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows, // CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)". -// #define CRYPTOPP_INIT_PRIORITY 250 +#ifndef CRYPTOPP_INIT_PRIORITY +// # define CRYPTOPP_INIT_PRIORITY 250 +#endif // CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++ // and managing C++ static object creation. It is guaranteed not to conflict with @@ -135,7 +137,7 @@ #if defined(CRYPTOPP_INIT_PRIORITY) && (CRYPTOPP_INIT_PRIORITY > 0) # define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY + 101) #else -# define CRYPTOPP_USER_PRIORITY 250 +# define CRYPTOPP_USER_PRIORITY 350 #endif // CRYPTOPP_DEBUG enables the library's CRYPTOPP_ASSERT. CRYPTOPP_ASSERT @@ -232,6 +234,14 @@ typedef unsigned int word32; typedef word64 lword; const lword LWORD_MAX = W64LIT(0xffffffffffffffff); +// Clang pretends to be GCC, but can't consume the same programs. It breaks completely with -march-x86-64 +#if defined(__GNUC__) && defined(__clang__) +# undef __GNUC__ +# undef __GNUC_MINOR__ +# undef __GNUC_PATCHLEVEL__ +# define __GNUC__ 4 +#endif + // Clang pretends to be VC++, too. // See http://github.com/weidai11/cryptopp/issues/147 #if defined(_MSC_VER) && defined(__clang__) diff --git a/config.h b/config.h index 691b57ca..ed924f58 100644 --- a/config.h +++ b/config.h @@ -127,7 +127,9 @@ // Under GCC, the library uses init_priority attribute in the range // [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows, // CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)". -#define CRYPTOPP_INIT_PRIORITY 250 +#ifndef CRYPTOPP_INIT_PRIORITY +# define CRYPTOPP_INIT_PRIORITY 250 +#endif // CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++ // and managing C++ static object creation. It is guaranteed not to conflict with @@ -135,7 +137,7 @@ #if defined(CRYPTOPP_INIT_PRIORITY) && (CRYPTOPP_INIT_PRIORITY > 0) # define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY + 101) #else -# define CRYPTOPP_USER_PRIORITY 250 +# define CRYPTOPP_USER_PRIORITY 350 #endif // CRYPTOPP_DEBUG enables the library's CRYPTOPP_ASSERT. CRYPTOPP_ASSERT @@ -232,6 +234,14 @@ typedef unsigned int word32; typedef word64 lword; const lword LWORD_MAX = W64LIT(0xffffffffffffffff); +// Clang pretends to be GCC, but can't consume the same programs. It breaks completely with -march-x86-64 +#if defined(__GNUC__) && defined(__clang__) +# undef __GNUC__ +# undef __GNUC_MINOR__ +# undef __GNUC_PATCHLEVEL__ +# define __GNUC__ 4 +#endif + // Clang pretends to be VC++, too. // See http://github.com/weidai11/cryptopp/issues/147 #if defined(_MSC_VER) && defined(__clang__)