mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	suppress USE_AVX, make it autodetectable on runtime
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
		
							parent
							
								
									7e874eaa7c
								
							
						
					
					
						commit
						07ff165a8f
					
				
					 10 changed files with 17 additions and 41 deletions
				
			
		
							
								
								
									
										1
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,3 @@ ifeq ($(USE_AESNI),1)
 | 
			
		|||
else
 | 
			
		||||
	CXXFLAGS += -msse
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(USE_AVX),1)
 | 
			
		||||
	CXXFLAGS += -mavx
 | 
			
		||||
endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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}")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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__)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue