Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LevelDB #1150

Merged
merged 3 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
.code
.idea
# Editors.
*.sw*
.vscode
.clangd
build

*.tar.gz
*.tmp
.DS_Store

# Build directory.
build/
out/
*.exe
*.pdb
src/defi
Expand Down
100 changes: 88 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]])
fi

enable_hwcrc32=no
enable_sse42=no
enable_sse41=no
enable_avx2=no
enable_shani=no
Expand All @@ -348,7 +348,7 @@ AX_CHECK_COMPILE_FLAG([-msse4 -msha],[[SHANI_CXXFLAGS="-msse4 -msha"]],,[[$CXXFL

TEMP_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $SSE42_CXXFLAGS"
AC_MSG_CHECKING(for assembler crc32 support)
AC_MSG_CHECKING(for SSE4.2 intrinsics)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>
#if defined(_MSC_VER)
Expand All @@ -363,7 +363,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
l = _mm_crc32_u64(l, 0);
return l;
]])],
[ AC_MSG_RESULT(yes); enable_hwcrc32=yes],
[ AC_MSG_RESULT(yes); enable_sse42=yes],
[ AC_MSG_RESULT(no)]
)
CXXFLAGS="$TEMP_CXXFLAGS"
Expand Down Expand Up @@ -415,6 +415,28 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
)
CXXFLAGS="$TEMP_CXXFLAGS"

# ARM
AX_CHECK_COMPILE_FLAG([-march=armv8-a+crc+crypto],[[ARM_CRC_CXXFLAGS="-march=armv8-a+crc+crypto"]],,[[$CXXFLAG_WERROR]])

TEMP_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $ARM_CRC_CXXFLAGS"
AC_MSG_CHECKING(for AArch64 CRC32 intrinsics)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <arm_acle.h>
#include <arm_neon.h>
]],[[
#ifdef __aarch64__
__crc32cb(0, 0); __crc32ch(0, 0); __crc32cw(0, 0); __crc32cd(0, 0);
vmull_p64(0, 0);
#else
#error "crc32c library does not support hardware acceleration on 32-bit ARM"
#endif
]])],
[ AC_MSG_RESULT(yes); enable_arm_crc=yes; ],
[ AC_MSG_RESULT(no)]
)
CXXFLAGS="$TEMP_CXXFLAGS"

fi

CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
Expand Down Expand Up @@ -911,6 +933,60 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>
[ AC_MSG_RESULT(no)]
)

AC_MSG_CHECKING(for fdatasync)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]],
[[ fdatasync(0); ]])],
[ AC_MSG_RESULT(yes); HAVE_FDATASYNC=1 ],
[ AC_MSG_RESULT(no); HAVE_FDATASYNC=0 ]
)
AC_DEFINE_UNQUOTED([HAVE_FDATASYNC], [$HAVE_FDATASYNC], [Define to 1 if fdatasync is available.])

AC_MSG_CHECKING(for F_FULLFSYNC)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h>]],
[[ fcntl(0, F_FULLFSYNC, 0); ]])],
[ AC_MSG_RESULT(yes); HAVE_FULLFSYNC=1 ],
[ AC_MSG_RESULT(no); HAVE_FULLFSYNC=0 ]
)

AC_MSG_CHECKING(for O_CLOEXEC)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h>]],
[[ open("", O_CLOEXEC); ]])],
[ AC_MSG_RESULT(yes); HAVE_O_CLOEXEC=1 ],
[ AC_MSG_RESULT(no); HAVE_O_CLOEXEC=0 ]
)
AC_DEFINE_UNQUOTED([HAVE_O_CLOEXEC], [$HAVE_O_CLOEXEC], [Define to 1 if O_CLOEXEC flag is available.])

dnl crc32c platform checks
AC_MSG_CHECKING(for __builtin_prefetch)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
char data = 0;
const char* address = &data;
__builtin_prefetch(address, 0, 0);
]])],
[ AC_MSG_RESULT(yes); HAVE_BUILTIN_PREFETCH=1 ],
[ AC_MSG_RESULT(no); HAVE_BUILTIN_PREFETCH=0 ]
)

AC_MSG_CHECKING(for _mm_prefetch)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xmmintrin.h>]], [[
char data = 0;
const char* address = &data;
_mm_prefetch(address, _MM_HINT_NTA);
]])],
[ AC_MSG_RESULT(yes); HAVE_MM_PREFETCH=1 ],
[ AC_MSG_RESULT(no); HAVE_MM_PREFETCH=0 ]
)

AC_MSG_CHECKING(for strong getauxval support in the system headers)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/auxv.h>
]], [[
getauxval(AT_HWCAP);
]])],
[ AC_MSG_RESULT(yes); HAVE_STRONG_GETAUXVAL=1; AC_DEFINE(HAVE_STRONG_GETAUXVAL, 1, [Define this symbol to build code that uses getauxval)]) ],
[ AC_MSG_RESULT(no); HAVE_STRONG_GETAUXVAL=0 ]
)

# Check for reduced exports
if test x$use_reduce_exports = xyes; then
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],
Expand Down Expand Up @@ -940,14 +1016,6 @@ AC_LINK_IFELSE(
# Define to 1 if std::system or ::wsystem (Windows) is available
AC_DEFINE([HAVE_SYSTEM], [HAVE_STD__SYSTEM || HAVE_WSYSTEM], [std::system or ::wsystem])

LEVELDB_CPPFLAGS=
LIBLEVELDB=
LIBMEMENV=
AM_CONDITIONAL([EMBEDDED_LEVELDB],[true])
AC_SUBST(LEVELDB_CPPFLAGS)
AC_SUBST(LIBLEVELDB)
AC_SUBST(LIBMEMENV)

dnl enable-fuzz should disable all other targets
if test "x$enable_fuzz" = "xyes"; then
AC_MSG_WARN(enable-fuzz will disable all other targets)
Expand Down Expand Up @@ -1410,11 +1478,13 @@ AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes])
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
AM_CONDITIONAL([ENABLE_HWCRC32],[test x$enable_hwcrc32 = xyes])
AM_CONDITIONAL([ENABLE_SSE42],[test x$enable_sse42 = xyes])
AM_CONDITIONAL([ENABLE_SSE41],[test x$enable_sse41 = xyes])
AM_CONDITIONAL([ENABLE_AVX2],[test x$enable_avx2 = xyes])
AM_CONDITIONAL([ENABLE_SHANI],[test x$enable_shani = xyes])
AM_CONDITIONAL([ENABLE_ARM_CRC],[test x$enable_arm_crc = xyes])
AM_CONDITIONAL([USE_ASM],[test x$use_asm = xyes])
AM_CONDITIONAL([WORDS_BIGENDIAN],[test x$ac_cv_c_bigendian = xyes])

AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
Expand Down Expand Up @@ -1473,6 +1543,12 @@ AC_SUBST(EVENT_PTHREADS_LIBS)
AC_SUBST(ZMQ_LIBS)
AC_SUBST(QR_LIBS)
AC_SUBST(HAVE_GMTIME_R)
AC_SUBST(HAVE_FDATASYNC)
AC_SUBST(HAVE_FULLFSYNC)
AC_SUBST(HAVE_O_CLOEXEC)
AC_SUBST(HAVE_BUILTIN_PREFETCH)
AC_SUBST(HAVE_MM_PREFETCH)
AC_SUBST(HAVE_STRONG_GETAUXVAL)
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi test/config.ini])
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
Expand Down
6 changes: 2 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,6 @@ defid_LDADD = \
$(LIBDEFI_CONSENSUS) \
$(LIBDEFI_CRYPTO) \
$(LIBLEVELDB) \
$(LIBLEVELDB_SSE42) \
$(LIBMEMENV) \
$(LIBSECP256K1)

Expand Down Expand Up @@ -752,7 +751,6 @@ defi_wallet_LDADD = \
$(LIBDEFI_CRYPTO) \
$(LIBDEFI_ZMQ) \
$(LIBLEVELDB) \
$(LIBLEVELDB_SSE42) \
$(LIBMEMENV) \
$(LIBSECP256K1) \
$(LIBUNIVALUE)
Expand Down Expand Up @@ -788,6 +786,7 @@ CLEANFILES = $(EXTRA_LIBRARIES)
CLEANFILES += *.gcda *.gcno
CLEANFILES += compat/*.gcda compat/*.gcno
CLEANFILES += consensus/*.gcda consensus/*.gcno
CLEANFILES += crc32c/src/*.gcda crc32c/src/*.gcno
CLEANFILES += crypto/*.gcda crypto/*.gcno
CLEANFILES += policy/*.gcda policy/*.gcno
CLEANFILES += primitives/*.gcda primitives/*.gcno
Expand Down Expand Up @@ -833,9 +832,8 @@ if HARDEN
$(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(PYTHON) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS)
endif

if EMBEDDED_LEVELDB
include Makefile.crc32c.include
include Makefile.leveldb.include
endif

if ENABLE_TESTS
include Makefile.test.include
Expand Down
1 change: 0 additions & 1 deletion src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ bench_bench_defi_LDADD = \
$(LIBDEFI_CRYPTO) \
$(LIBDEFI_SPV) \
$(LIBLEVELDB) \
$(LIBLEVELDB_SSE42) \
$(LIBMEMENV) \
$(LIBSECP256K1) \
$(LIBUNIVALUE) \
Expand Down
74 changes: 74 additions & 0 deletions src/Makefile.crc32c.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright (c) 2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

LIBCRC32C_INT = crc32c/libcrc32c.a
LIBLEVELDB_SSE42_INT = leveldb/libleveldb_sse42.a

EXTRA_LIBRARIES += $(LIBCRC32C_INT)

LIBCRC32C = $(LIBCRC32C_INT)

CRC32C_CPPFLAGS_INT =
CRC32C_CPPFLAGS_INT += -I$(srcdir)/crc32c/include
CRC32C_CPPFLAGS_INT += -DHAVE_BUILTIN_PREFETCH=@HAVE_BUILTIN_PREFETCH@
CRC32C_CPPFLAGS_INT += -DHAVE_MM_PREFETCH=@HAVE_MM_PREFETCH@
CRC32C_CPPFLAGS_INT += -DHAVE_STRONG_GETAUXVAL=@HAVE_STRONG_GETAUXVAL@
CRC32C_CPPFLAGS_INT += -DCRC32C_TESTS_BUILT_WITH_GLOG=0

if ENABLE_SSE42
CRC32C_CPPFLAGS_INT += -DHAVE_SSE42=1
else
CRC32C_CPPFLAGS_INT += -DHAVE_SSE42=0
endif

if ENABLE_ARM_CRC
CRC32C_CPPFLAGS_INT += -DHAVE_ARM64_CRC32C=1
else
CRC32C_CPPFLAGS_INT += -DHAVE_ARM64_CRC32C=0
endif

if WORDS_BIGENDIAN
CRC32C_CPPFLAGS_INT += -DBYTE_ORDER_BIG_ENDIAN=1
else
CRC32C_CPPFLAGS_INT += -DBYTE_ORDER_BIG_ENDIAN=0
endif

crc32c_libcrc32c_a_CPPFLAGS = $(AM_CPPFLAGS) $(CRC32C_CPPFLAGS_INT) $(CRC32C_CPPFLAGS)
crc32c_libcrc32c_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

crc32c_libcrc32c_a_SOURCES =
crc32c_libcrc32c_a_SOURCES += crc32c/include/crc32c/crc32c.h
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_arm64.h
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_arm64_check.h
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_internal.h
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_prefetch.h
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_read_le.h
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_round_up.h
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_sse42_check.h
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_sse42.h

crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c.cc
crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_portable.cc

if ENABLE_SSE42
LIBCRC32C_SSE42_INT = crc32c/libcrc32c_sse42.a
EXTRA_LIBRARIES += $(LIBCRC32C_SSE42_INT)
LIBCRC32C += $(LIBCRC32C_SSE42_INT)

crc32c_libcrc32c_sse42_a_CPPFLAGS = $(crc32c_libcrc32c_a_CPPFLAGS)
crc32c_libcrc32c_sse42_a_CXXFLAGS = $(crc32c_libcrc32c_a_CXXFLAGS) $(SSE42_CXXFLAGS)

crc32c_libcrc32c_sse42_a_SOURCES = crc32c/src/crc32c_sse42.cc
endif

if ENABLE_ARM_CRC
LIBCRC32C_ARM_CRC_INT = crc32c/libcrc32c_arm_crc.a
EXTRA_LIBRARIES += $(LIBCRC32C_ARM_CRC_INT)
LIBCRC32C += $(LIBCRC32C_ARM_CRC_INT)

crc32c_libcrc32c_arm_crc_a_CPPFLAGS = $(crc32c_libcrc32c_a_CPPFLAGS)
crc32c_libcrc32c_arm_crc_a_CXXFLAGS = $(crc32c_libcrc32c_a_CXXFLAGS) $(ARM_CRC_CXXFLAGS)

crc32c_libcrc32c_arm_crc_a_SOURCES = crc32c/src/crc32c_arm64.cc
endif
Loading