Also, enable crc32 even if -msse4.2 wasn't added by us, as long as it works. This allows custom flags (such as -march=native) to work as expected.
Addresses #10670.
utACK
@sipa This addresses 2 things:
I think 2 is what you're asking about? If so, it wouldn't work before because, even though the user has specified -msse4.2 (or -march=native, or whatever it takes to get the intrinsics working), our build wouldn't have the necessary make option set here: https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.leveldb.include#L145, so the necessary define wouldn't be added.
Going to test.
Interesting. On OpenBSD 6.1:
configure:18285: checking whether C++ compiler accepts -msse4.2
configure:18304: eg++ -std=c++11 -c -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter -Werror -msse4.2 conftest.cpp >&5
configure:18304: $? = 0
configure:18313: result: yes
configure:18326: checking for assembler crc32 support
configure:18351: eg++ -std=c++11 -c -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter -msse4.2 conftest.cpp >&5
conftest.cpp: In function 'int main()':
conftest.cpp:34:14: warning: variable 'l' set but not used [-Wunused-but-set-variable]
uint64_t l = 0;
^
configure:18351: $? = 0
configure:18352: result: yes
configure:20040: checking for pk
Then when running gmake:
leveldb/port/port_posix_sse.cc: In function 'uint32_t leveldb::port::AcceleratedCRC32C(uint32_t, const char*, size_t)':
leveldb/port/port_posix_sse.cc:59:15: warning: 'ecx' may be used uninitialized in this function [-Wmaybe-uninitialized]
return (ecx & (1 << 20)) != 0;
^
leveldb/port/port_posix_sse.cc:57:26: note: 'ecx' was declared here
unsigned int eax, ebx, ecx, edx;
^
/tmp//cc5NhjN4.s: Assembler messages:
/tmp//cc5NhjN4.s:95: Error: no such instruction: `crc32b -1(%rbp),%eax'
/tmp//cc5NhjN4.s:121: Error: no such instruction: `crc32q -8(%rbp),%rax'
/tmp//cc5NhjN4.s:148: Error: no such instruction: `crc32b -1(%rbp),%eax'
:312: Error: no such instruction: `crc32l 0(%rbp),%eax'
gmake[2]: *** [Makefile:4923: leveldb/port/leveldb_libleveldb_sse42_a-port_posix_sse.o] Error 1
So somehow it works while running configure, but not while building confused.
@theuni this solves it:
diff --git a/configure.ac b/configure.ac
index 5c3dac648..6b5d891fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -262,9 +262,10 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#endif
]],[[
uint64_t l = 0;
- l = _mm_crc32_u8(0, 0);
- l = _mm_crc32_u32(0, 0);
- l = _mm_crc32_u64(0, 0);
+ l = _mm_crc32_u8(l, 0);
+ l = _mm_crc32_u32(l, 0);
+ l = _mm_crc32_u64(l, 0);
+ return l;
]])],
[ AC_MSG_RESULT(yes); enable_hwcrc32=yes],
[ AC_MSG_RESULT(no)]
Also, enable crc32 even if -msse4.2 wasn't added by us, as long as it works.
This allows custom flags (such as -march=native) to work as expected.
Tested ACK d34d77a