From 19181b5e2c161432bf18cf2eae5bedfff1edb88c Mon Sep 17 00:00:00 2001 From: despair Date: Thu, 8 Nov 2018 10:50:34 -0600 Subject: [PATCH] fuck the apple compiler bad merge! make -Werror optional for end-users --- CMakeLists.txt | 28 +++++++++++-------- .../chacha20/dolbeau/chacha20_dolbeau-avx2.c | 5 ++++ crypto/salsa20/xmm6int/salsa20_xmm6int-avx2.c | 5 ++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7ec5088a..70f8c6300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ project(${PROJECT_NAME} C CXX ASM) option(USE_LIBABYSS "enable libabyss" ) option(USE_CXX17 "enable c++17 features" ) option(USE_AVX2 "enable avx2 code" ) +option(WARNINGS_AS_ERRORS "Use -Werror. Not recommended for end-users" ON) + # Require C++11 # or C++17 on win32 if (NOT WIN32) @@ -41,13 +43,21 @@ if(CMAKE_HOST_WIN32) add_compile_options(-Wno-cast-function-type) endif() if (USING_CLANG) -add_compile_options(-Wno-unused-command-line-argument -Wno-c++11-narrowing) +add_compile_options(-Wno-unused-command-line-argument -Wno-c++11-narrowing -Wno-bad-function-cast) # because clang is insane enough to inline whole sections of the C++ library! # May have been fixed in llvm-7. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-multiple-definition --rtlib=libgcc") +else() +add_compile_options(-Wno-cast-function-type -Wno-narrowing) endif(USING_CLANG) endif() +if(WIN32) +add_compile_options($<$:-Wno-bad-function-cast>) +add_compile_options(-Wno-stringop-overflow) +set(FS_LIB stdc++fs) +endif(WIN32) + if(DEBIAN) add_definitions(-DDEBIAN) endif() @@ -107,14 +117,12 @@ if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") endif() if(NOT ANDROID) -if (USE_AVX2) -set(CRYPTO_FLAGS -march=native) -set(CMAKE_ASM_FLAGS "-march=native ${CMAKE_ASM_FLAGS} $ENV{ASFLAGS}") -else() -if(WIN32) +if (NOT USE_AVX2) set(CRYPTO_FLAGS -march=core2) -set(CMAKE_ASM_FLAGS "-march=core2 ${CMAKE_ASM_FLAGS} $ENV{ASFLAGS}") -endif() +set(CMAKE_ASM_FLAGS "-march=core2") +else() +set(CRYPTO_FLAGS -march=haswell -mtune=native) +set(CMAKE_ASM_FLAGS "-march=haswell -mtune=native ${CMAKE_ASM_FLAGS} $ENV{ASFLAGS}") endif() endif() if(RPI) @@ -149,10 +157,6 @@ if(JEMALLOC) set(MALLOC_LIB jemalloc) endif() -if (WIN32) -set(FS_LIB stdc++fs) -endif(WIN32) - # FS_LIB should resolve to nothing on all other platforms # it is only required on win32 -rick set(LIBS Threads::Threads ${MALLOC_LIB} ${FS_LIB}) diff --git a/crypto/chacha20/dolbeau/chacha20_dolbeau-avx2.c b/crypto/chacha20/dolbeau/chacha20_dolbeau-avx2.c index 0cbf51389..9960112d6 100644 --- a/crypto/chacha20/dolbeau/chacha20_dolbeau-avx2.c +++ b/crypto/chacha20/dolbeau/chacha20_dolbeau-avx2.c @@ -23,7 +23,12 @@ #include #ifndef __amd64__ +#ifdef __clang__ #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2"))) +#else +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __target__("sse2"))) +#endif + static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtsi64_si128(long long __a) { diff --git a/crypto/salsa20/xmm6int/salsa20_xmm6int-avx2.c b/crypto/salsa20/xmm6int/salsa20_xmm6int-avx2.c index 4ef572dff..2362b2eb3 100644 --- a/crypto/salsa20/xmm6int/salsa20_xmm6int-avx2.c +++ b/crypto/salsa20/xmm6int/salsa20_xmm6int-avx2.c @@ -23,7 +23,12 @@ #include #ifndef __amd64__ +#ifdef __clang__ #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2"))) +#else +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __target__("sse2"))) +#endif + static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtsi64_si128(long long __a) {