Merge pull request #326 from alonbl/build

Add DISABLE_CXXFLAGS_OPTIMIZATIONS option
pull/339/head
Jeffrey Walton 2016-10-25 15:38:52 -04:00 committed by GitHub
commit 2e3f359626
2 changed files with 40 additions and 33 deletions

View File

@ -39,6 +39,7 @@ option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentati
option(DISABLE_ASM "Disable ASM" OFF) option(DISABLE_ASM "Disable ASM" OFF)
option(DISABLE_SSSE3 "Disable SSSE3" OFF) option(DISABLE_SSSE3 "Disable SSSE3" OFF)
option(DISABLE_AESNI "Disable AES-NI" OFF) option(DISABLE_AESNI "Disable AES-NI" OFF)
option(DISABLE_CXXFLAGS_OPTIMIZATIONS "Disable CXXFLAGS optimizations" OFF)
set(CRYPTOPP_DATA_DIR "" CACHE PATH "Crypto++ test data directory") set(CRYPTOPP_DATA_DIR "" CACHE PATH "Crypto++ test data directory")
#============================================================================ #============================================================================
@ -125,7 +126,7 @@ if ((NOT CRYPTOPP_CROSS_COMPILE) AND (NOT (WINDOWS OR WINDOWS_STORE OR WINDOWS_P
endif() endif()
# -march=native for GCC, Clang and ICC in any version that does support it. # -march=native for GCC, Clang and ICC in any version that does support it.
if ((NOT CRYPTOPP_CROSS_COMPILE) AND (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU|Intel")) if ((NOT DISABLE_CXXFLAGS_OPTIMIZATIONS) AND (NOT CRYPTOPP_CROSS_COMPILE) AND (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU|Intel"))
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_OPT_ARCH_NATIVE_SUPPORTED) CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_OPT_ARCH_NATIVE_SUPPORTED)
if (COMPILER_OPT_ARCH_NATIVE_SUPPORTED AND NOT CMAKE_CXX_FLAGS MATCHES "-march=") if (COMPILER_OPT_ARCH_NATIVE_SUPPORTED AND NOT CMAKE_CXX_FLAGS MATCHES "-march=")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
@ -134,6 +135,7 @@ endif()
# Solaris specific # Solaris specific
if ((NOT CRYPTOPP_CROSS_COMPILE) AND "${UNAME_SYSTEM}" STREQUAL "SunOS") if ((NOT CRYPTOPP_CROSS_COMPILE) AND "${UNAME_SYSTEM}" STREQUAL "SunOS")
if (NOT DISABLE_CXXFLAGS_OPTIMIZATIONS)
# SunCC needs -native # SunCC needs -native
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -native") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -native")
@ -154,6 +156,7 @@ if ((NOT CRYPTOPP_CROSS_COMPILE) AND "${UNAME_SYSTEM}" STREQUAL "SunOS")
else() else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif() endif()
endif()
# GCC needs to enable use of '/' # GCC needs to enable use of '/'
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")

View File

@ -49,6 +49,8 @@ IS_X86 := $(shell isainfo -k 2>/dev/null | grep -i -c "i386")
IS_X64 := $(shell isainfo -k 2>/dev/null | grep -i -c "amd64") IS_X64 := $(shell isainfo -k 2>/dev/null | grep -i -c "amd64")
endif endif
DISABLE_CXXFLAGS_OPTIMIZATIONS := 0
########################################################### ###########################################################
##### General Variables ##### ##### General Variables #####
########################################################### ###########################################################
@ -125,12 +127,13 @@ ifeq ($(IS_X86)$(IS_X32)$(IS_CYGWIN)$(IS_MINGW)$(SUN_COMPILER),00000)
endif endif
endif endif
# Guard use of -march=native ifeq ($(DISABLE_CXXFLAGS_OPTIMIZATIONS),0)
ifeq ($(GCC42_OR_LATER)$(IS_NETBSD),10) # Guard use of -march=native
ifeq ($(GCC42_OR_LATER)$(IS_NETBSD),10)
CXXFLAGS += -march=native CXXFLAGS += -march=native
else ifneq ($(CLANG_COMPILER)$(INTEL_COMPILER),00) else ifneq ($(CLANG_COMPILER)$(INTEL_COMPILER),00)
CXXFLAGS += -march=native CXXFLAGS += -march=native
else else
# GCC 3.3 and "unknown option -march=" # GCC 3.3 and "unknown option -march="
# Ubuntu GCC 4.1 compiler crash with -march=native # Ubuntu GCC 4.1 compiler crash with -march=native
# NetBSD GCC 4.8 compiler and "bad value (native) for -march= switch" # NetBSD GCC 4.8 compiler and "bad value (native) for -march= switch"
@ -140,6 +143,7 @@ else
else ifeq ($(SUN_COMPILER)$(IS_X86),01) else ifeq ($(SUN_COMPILER)$(IS_X86),01)
CXXFLAGS += -m32 CXXFLAGS += -m32
endif # X86/X32/X64 endif # X86/X32/X64
endif
endif endif
# Aligned access required for -O3 and above due to vectorization # Aligned access required for -O3 and above due to vectorization