diff --git a/Makefile b/Makefile index 35d76b82..e469aa32 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,6 @@ DAEMON_SRC_DIR := daemon include filelist.mk USE_AESNI := yes -USE_AVX := yes USE_STATIC := no USE_MESHNET := no USE_UPNP := no diff --git a/Makefile.homebrew b/Makefile.homebrew index 64301c02..c4fa5d8e 100644 --- a/Makefile.homebrew +++ b/Makefile.homebrew @@ -37,9 +37,6 @@ endif ifeq ($(USE_AESNI),yes) CXXFLAGS += -maes endif -ifeq ($(USE_AVX),1) - CXXFLAGS += -mavx -endif install: all install -d ${PREFIX}/bin ${PREFIX}/etc/i2pd ${PREFIX}/share/doc/i2pd ${PREFIX}/share/i2pd ${PREFIX}/share/man/man1 ${PREFIX}/var/lib/i2pd diff --git a/Makefile.linux b/Makefile.linux index 3ef4793c..f0d69728 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -68,10 +68,3 @@ ifneq ($(shell $(GREP) -c aes /proc/cpuinfo),0) endif endif endif - -ifeq ($(USE_AVX),yes) -#check if AVX supported by CPU -ifneq ($(shell $(GREP) -c avx /proc/cpuinfo),0) - CPU_FLAGS += -mavx -endif -endif diff --git a/Makefile.mingw b/Makefile.mingw index 2782b715..b6667ada 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -52,15 +52,8 @@ ifeq ($(USE_WINXP_FLAGS), yes) CXXFLAGS += -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 endif -# don't change following line to ifeq ($(USE_AESNI),yes) !!! -ifeq ($(USE_AESNI),1) +ifeq ($(USE_AESNI),yes) CPU_FLAGS += -maes -else - CPU_FLAGS += -msse -endif - -ifeq ($(USE_AVX),1) - CPU_FLAGS += -mavx endif ifeq ($(USE_ASLR),yes) diff --git a/Makefile.osx b/Makefile.osx index c6af4fc2..dbdd5deb 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -27,7 +27,3 @@ ifeq ($(USE_AESNI),1) else CXXFLAGS += -msse endif - -ifeq ($(USE_AVX),1) - CXXFLAGS += -mavx -endif diff --git a/Win32/installer.iss b/Win32/installer.iss index cc40c409..073ca159 100644 --- a/Win32/installer.iss +++ b/Win32/installer.iss @@ -11,7 +11,7 @@ DefaultGroupName=I2Pd UninstallDisplayIcon={app}\I2Pd.exe OutputDir=. LicenseFile=../LICENSE -OutputBaseFilename=setup_{#I2Pd_AppName}_v{#I2Pd_ver} +OutputBaseFilename=../build/setup_{#I2Pd_AppName}_v{#I2Pd_ver} SetupIconFile=mask.ico InternalCompressLevel=ultra64 Compression=lzma/ultra64 diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 827e20d3..c2794224 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -12,8 +12,8 @@ if(WIN32 OR MSVC OR MSYS OR MINGW) endif() # configurale options -option(WITH_AESNI "Use AES-NI instructions set" OFF) -option(WITH_AVX "Use AVX instructions" OFF) +option(WITH_AESNI "Use AES-NI instructions set" ON) +option(WITH_AVX "deprecated" OFF) option(WITH_HARDENING "Use hardening compiler flags" OFF) option(WITH_LIBRARY "Build library" ON) option(WITH_BINARY "Build binary" ON) @@ -194,10 +194,6 @@ if(WITH_AESNI) add_definitions(-DAESNI) endif() -if(WITH_AVX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx") -endif() - if(WITH_ADDRSANITIZER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") @@ -309,7 +305,6 @@ message(STATUS "Architecture : ${ARCHITECTURE}") message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}") message(STATUS "Options:") message(STATUS " AESNI : ${WITH_AESNI}") -message(STATUS " AVX : ${WITH_AVX}") message(STATUS " HARDENING : ${WITH_HARDENING}") message(STATUS " LIBRARY : ${WITH_LIBRARY}") message(STATUS " BINARY : ${WITH_BINARY}") diff --git a/libi2pd/CPU.cpp b/libi2pd/CPU.cpp index e7eff473..95ca49bb 100644 --- a/libi2pd/CPU.cpp +++ b/libi2pd/CPU.cpp @@ -29,6 +29,7 @@ namespace cpu void Detect() { + __builtin_cpu_init(); #if defined(__AES__) || defined(__AVX__) #if defined(__x86_64__) || defined(__i386__) @@ -37,11 +38,13 @@ namespace cpu if (info[0] >= 0x00000001) { __cpuid(0x00000001, info[0], info[1], info[2], info[3]); #ifdef __AES__ - aesni = info[2] & bit_AES; // AESNI + if (__builtin_cpu_supports("aes")) { + aesni = info[2] & bit_AES; // AESNI + } #endif // __AES__ -#ifdef __AVX__ - avx = info[2] & bit_AVX; // AVX -#endif // __AVX__ + if (__builtin_cpu_supports("avx")) { + avx = info[2] & bit_AVX; // AVX + } } #endif // defined(__x86_64__) || defined(__i386__) @@ -51,12 +54,10 @@ namespace cpu LogPrint(eLogInfo, "AESNI enabled"); } #endif // __AES__ -#ifdef __AVX__ if(avx) { LogPrint(eLogInfo, "AVX enabled"); } -#endif // __AVX__ #endif // defined(__AES__) || defined(__AVX__) } } diff --git a/libi2pd/Crypto.cpp b/libi2pd/Crypto.cpp index ea2cd675..ff6e91a6 100644 --- a/libi2pd/Crypto.cpp +++ b/libi2pd/Crypto.cpp @@ -631,6 +631,9 @@ namespace crypto static const uint64_t ipads[] = { IPAD, IPAD, IPAD, IPAD }; static const uint64_t opads[] = { OPAD, OPAD, OPAD, OPAD }; +#if defined(__x86_64__) || defined(__i386__) +#pragma GCC target("avx") +#endif void HMACMD5Digest (uint8_t * msg, size_t len, const MACKey& key, uint8_t * digest) // key is 32 bytes // digest is 16 bytes @@ -638,7 +641,6 @@ namespace crypto { uint64_t buf[256]; uint64_t hash[12]; // 96 bytes -#ifdef __AVX__ if(i2p::cpu::avx) { __asm__ @@ -661,7 +663,6 @@ namespace crypto ); } else -#endif { // ikeypad buf[0] = key.GetLL ()[0] ^ IPAD; diff --git a/libi2pd/Identity.cpp b/libi2pd/Identity.cpp index 7784cc90..3f62365b 100644 --- a/libi2pd/Identity.cpp +++ b/libi2pd/Identity.cpp @@ -825,10 +825,12 @@ namespace data return key; } +#if defined(__x86_64__) || defined(__i386__) +#pragma GCC target("avx") +#endif XORMetric operator^(const IdentHash& key1, const IdentHash& key2) { XORMetric m; -#ifdef __AVX__ if(i2p::cpu::avx) { __asm__ @@ -843,7 +845,6 @@ namespace data ); } else -#endif { const uint64_t * hash1 = key1.GetLL (), * hash2 = key2.GetLL (); m.metric_ll[0] = hash1[0] ^ hash2[0];