Skip to content

Commit a4fe077

Browse files
committed
Merge #10544: Update to LevelDB 1.20
3ee3d04 Add extra LevelDB source to Makefile (MarcoFalke) 2424989 leveldb: enable runtime-detected crc32 instructions (Cory Fields) cf44e4c Squashed 'src/leveldb/' changes from a31c8aa..196962f (Pieter Wuille) Tree-SHA512: 19ade77e3f6265507b3ab7b9aa5150d378aa0751e24ac7a61567b0f720a566cedc6c3d3336da17a3bd2b5d068ee86600d96a15228f78bd20ccf98c8fc9041a91
2 parents 22ec768 + 3ee3d04 commit a4fe077

38 files changed

+1440
-1155
lines changed

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
236236
AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]])
237237
AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]])
238238
AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[CXXFLAGS="$CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]])
239+
240+
# Check for optional instruction set support. Enabling these does _not_ imply that all code will
241+
# be compiled with them, rather that specific objects/libs may use them after checking for runtime
242+
# compatibility.
243+
AX_CHECK_COMPILE_FLAG([-msse4.2],[[enable_sse42=yes; SSE42_CXXFLAGS="-msse4.2"]],,[[$CXXFLAG_WERROR]])
244+
239245
fi
240246
CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
241247

@@ -1114,6 +1120,7 @@ AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
11141120
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
11151121
AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
11161122
AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
1123+
AM_CONDITIONAL([ENABLE_SSE42],[test x$enable_sse42 = xyes])
11171124

11181125
AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
11191126
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
@@ -1146,6 +1153,7 @@ AC_SUBST(HARDENED_CPPFLAGS)
11461153
AC_SUBST(HARDENED_LDFLAGS)
11471154
AC_SUBST(PIC_FLAGS)
11481155
AC_SUBST(PIE_FLAGS)
1156+
AC_SUBST(SSE42_CXXFLAGS)
11491157
AC_SUBST(LIBTOOL_APP_LDFLAGS)
11501158
AC_SUBST(USE_UPNP)
11511159
AC_SUBST(USE_QRCODE)

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ bitcoind_LDADD = \
380380
$(LIBBITCOIN_CONSENSUS) \
381381
$(LIBBITCOIN_CRYPTO) \
382382
$(LIBLEVELDB) \
383+
$(LIBLEVELDB_SSE42) \
383384
$(LIBMEMENV) \
384385
$(LIBSECP256K1)
385386

src/Makefile.bench.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ bench_bench_bitcoin_LDADD = \
3939
$(LIBBITCOIN_CONSENSUS) \
4040
$(LIBBITCOIN_CRYPTO) \
4141
$(LIBLEVELDB) \
42+
$(LIBLEVELDB_SSE42) \
4243
$(LIBMEMENV) \
4344
$(LIBSECP256K1) \
4445
$(LIBUNIVALUE)

src/Makefile.leveldb.include

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
LIBLEVELDB_INT = leveldb/libleveldb.a
66
LIBMEMENV_INT = leveldb/libmemenv.a
7+
LIBLEVELDB_SSE42_INT = leveldb/libleveldb_sse42.a
78

89
EXTRA_LIBRARIES += $(LIBLEVELDB_INT)
910
EXTRA_LIBRARIES += $(LIBMEMENV_INT)
11+
EXTRA_LIBRARIES += $(LIBLEVELDB_SSE42_INT)
1012

1113
LIBLEVELDB += $(LIBLEVELDB_INT)
1214
LIBMEMENV += $(LIBMEMENV_INT)
15+
LIBLEVELDB_SSE42 = $(LIBLEVELDB_SSE42_INT)
1316

1417
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include
1518
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/helpers/memenv
@@ -74,6 +77,7 @@ leveldb_libleveldb_a_SOURCES += leveldb/table/merger.h
7477
leveldb_libleveldb_a_SOURCES += leveldb/table/format.h
7578
leveldb_libleveldb_a_SOURCES += leveldb/table/iterator_wrapper.h
7679
leveldb_libleveldb_a_SOURCES += leveldb/util/crc32c.h
80+
leveldb_libleveldb_a_SOURCES += leveldb/util/env_posix_test_helper.h
7781
leveldb_libleveldb_a_SOURCES += leveldb/util/arena.h
7882
leveldb_libleveldb_a_SOURCES += leveldb/util/random.h
7983
leveldb_libleveldb_a_SOURCES += leveldb/util/posix_logger.h
@@ -135,3 +139,11 @@ leveldb_libmemenv_a_CPPFLAGS = $(leveldb_libleveldb_a_CPPFLAGS)
135139
leveldb_libmemenv_a_CXXFLAGS = $(leveldb_libleveldb_a_CXXFLAGS)
136140
leveldb_libmemenv_a_SOURCES = leveldb/helpers/memenv/memenv.cc
137141
leveldb_libmemenv_a_SOURCES += leveldb/helpers/memenv/memenv.h
142+
143+
leveldb_libleveldb_sse42_a_CPPFLAGS = $(leveldb_libleveldb_a_CPPFLAGS)
144+
leveldb_libleveldb_sse42_a_CXXFLAGS = $(leveldb_libleveldb_a_CXXFLAGS)
145+
if ENABLE_SSE42
146+
leveldb_libleveldb_sse42_a_CPPFLAGS += -DLEVELDB_PLATFORM_POSIX_SSE
147+
leveldb_libleveldb_sse42_a_CXXFLAGS += $(SSE42_CXXFLAGS)
148+
endif
149+
leveldb_libleveldb_sse42_a_SOURCES = leveldb/port/port_posix_sse.cc

src/Makefile.qt.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ endif
407407
if ENABLE_ZMQ
408408
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
409409
endif
410-
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
410+
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \
411411
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
412412
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
413413
qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)

src/Makefile.qttest.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if ENABLE_ZMQ
6060
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
6161
endif
6262
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \
63-
$(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
63+
$(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
6464
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
6565
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
6666
qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)

src/Makefile.test.include

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ endif
9696

9797
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
9898
test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS) $(EVENT_CFLAGS)
99-
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
100-
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS)
99+
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \
100+
$(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS)
101101
test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
102102
if ENABLE_WALLET
103103
test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)

src/leveldb/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ TESTS = \
4444
util/cache_test \
4545
util/coding_test \
4646
util/crc32c_test \
47+
util/env_posix_test \
4748
util/env_test \
4849
util/hash_test
4950

@@ -121,7 +122,7 @@ SHARED_MEMENVLIB = $(SHARED_OUTDIR)/libmemenv.a
121122
else
122123
# Update db.h if you change these.
123124
SHARED_VERSION_MAJOR = 1
124-
SHARED_VERSION_MINOR = 19
125+
SHARED_VERSION_MINOR = 20
125126
SHARED_LIB1 = libleveldb.$(PLATFORM_SHARED_EXT)
126127
SHARED_LIB2 = $(SHARED_LIB1).$(SHARED_VERSION_MAJOR)
127128
SHARED_LIB3 = $(SHARED_LIB1).$(SHARED_VERSION_MAJOR).$(SHARED_VERSION_MINOR)
@@ -337,6 +338,9 @@ $(STATIC_OUTDIR)/db_test:db/db_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS)
337338
$(STATIC_OUTDIR)/dbformat_test:db/dbformat_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS)
338339
$(CXX) $(LDFLAGS) $(CXXFLAGS) db/dbformat_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
339340

341+
$(STATIC_OUTDIR)/env_posix_test:util/env_posix_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS)
342+
$(CXX) $(LDFLAGS) $(CXXFLAGS) util/env_posix_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
343+
340344
$(STATIC_OUTDIR)/env_test:util/env_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS)
341345
$(CXX) $(LDFLAGS) $(CXXFLAGS) util/env_test.cc $(STATIC_LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
342346

@@ -412,3 +416,9 @@ $(SHARED_OUTDIR)/%.o: %.cc
412416

413417
$(SHARED_OUTDIR)/%.o: %.c
414418
$(CC) $(CFLAGS) $(PLATFORM_SHARED_CFLAGS) -c $< -o $@
419+
420+
$(STATIC_OUTDIR)/port/port_posix_sse.o: port/port_posix_sse.cc
421+
$(CXX) $(CXXFLAGS) $(PLATFORM_SSEFLAGS) -c $< -o $@
422+
423+
$(SHARED_OUTDIR)/port/port_posix_sse.o: port/port_posix_sse.cc
424+
$(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(PLATFORM_SSEFLAGS) -c $< -o $@

src/leveldb/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com)
1616
* External activity (file system operations etc.) is relayed through a virtual interface so users can customize the operating system interactions.
1717

1818
# Documentation
19-
[LevelDB library documentation](https://rawgit.com/google/leveldb/master/doc/index.html) is online and bundled with the source code.
19+
[LevelDB library documentation](https://github.com/google/leveldb/blob/master/doc/index.md) is online and bundled with the source code.
2020

2121

2222
# Limitations
@@ -113,29 +113,30 @@ by the one or two disk seeks needed to fetch the data from disk.
113113
Write performance will be mostly unaffected by whether or not the
114114
working set fits in memory.
115115

116-
readrandom : 16.677 micros/op; (approximately 60,000 reads per second)
117-
readseq : 0.476 micros/op; 232.3 MB/s
118-
readreverse : 0.724 micros/op; 152.9 MB/s
116+
readrandom : 16.677 micros/op; (approximately 60,000 reads per second)
117+
readseq : 0.476 micros/op; 232.3 MB/s
118+
readreverse : 0.724 micros/op; 152.9 MB/s
119119

120120
LevelDB compacts its underlying storage data in the background to
121121
improve read performance. The results listed above were done
122122
immediately after a lot of random writes. The results after
123123
compactions (which are usually triggered automatically) are better.
124124

125-
readrandom : 11.602 micros/op; (approximately 85,000 reads per second)
126-
readseq : 0.423 micros/op; 261.8 MB/s
127-
readreverse : 0.663 micros/op; 166.9 MB/s
125+
readrandom : 11.602 micros/op; (approximately 85,000 reads per second)
126+
readseq : 0.423 micros/op; 261.8 MB/s
127+
readreverse : 0.663 micros/op; 166.9 MB/s
128128

129129
Some of the high cost of reads comes from repeated decompression of blocks
130130
read from disk. If we supply enough cache to the leveldb so it can hold the
131131
uncompressed blocks in memory, the read performance improves again:
132132

133-
readrandom : 9.775 micros/op; (approximately 100,000 reads per second before compaction)
134-
readrandom : 5.215 micros/op; (approximately 190,000 reads per second after compaction)
133+
readrandom : 9.775 micros/op; (approximately 100,000 reads per second before compaction)
134+
readrandom : 5.215 micros/op; (approximately 190,000 reads per second after compaction)
135135

136136
## Repository contents
137137

138-
See doc/index.html for more explanation. See doc/impl.html for a brief overview of the implementation.
138+
See [doc/index.md](doc/index.md) for more explanation. See
139+
[doc/impl.md](doc/impl.md) for a brief overview of the implementation.
139140

140141
The public interface is in include/*.h. Callers should not include or
141142
rely on the details of any other header files in this package. Those
@@ -148,7 +149,7 @@ Guide to header files:
148149
* **include/options.h**: Control over the behavior of an entire database,
149150
and also control over the behavior of individual reads and writes.
150151

151-
* **include/comparator.h**: Abstraction for user-specified comparison function.
152+
* **include/comparator.h**: Abstraction for user-specified comparison function.
152153
If you want just bytewise comparison of keys, you can use the default
153154
comparator, but clients can write their own comparator implementations if they
154155
want custom ordering (e.g. to handle different character encodings, etc.)
@@ -165,7 +166,7 @@ length into some other byte array.
165166
* **include/status.h**: Status is returned from many of the public interfaces
166167
and is used to report success and various kinds of errors.
167168

168-
* **include/env.h**:
169+
* **include/env.h**:
169170
Abstraction of the OS environment. A posix implementation of this interface is
170171
in util/env_posix.cc
171172

src/leveldb/build_detect_platform

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ PLATFORM_SHARED_EXT="so"
6363
PLATFORM_SHARED_LDFLAGS="-shared -Wl,-soname -Wl,"
6464
PLATFORM_SHARED_CFLAGS="-fPIC"
6565
PLATFORM_SHARED_VERSIONED=true
66+
PLATFORM_SSEFLAGS=
6667

6768
MEMCMP_FLAG=
6869
if [ "$CXX" = "g++" ]; then
@@ -77,6 +78,7 @@ case "$TARGET_OS" in
7778
COMMON_FLAGS="$MEMCMP_FLAG -lpthread -DOS_LINUX -DCYGWIN"
7879
PLATFORM_LDFLAGS="-lpthread"
7980
PORT_FILE=port/port_posix.cc
81+
PORT_SSE_FILE=port/port_posix_sse.cc
8082
;;
8183
Darwin)
8284
PLATFORM=OS_MACOSX
@@ -85,24 +87,28 @@ case "$TARGET_OS" in
8587
[ -z "$INSTALL_PATH" ] && INSTALL_PATH=`pwd`
8688
PLATFORM_SHARED_LDFLAGS="-dynamiclib -install_name $INSTALL_PATH/"
8789
PORT_FILE=port/port_posix.cc
90+
PORT_SSE_FILE=port/port_posix_sse.cc
8891
;;
8992
Linux)
9093
PLATFORM=OS_LINUX
9194
COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX"
9295
PLATFORM_LDFLAGS="-pthread"
9396
PORT_FILE=port/port_posix.cc
97+
PORT_SSE_FILE=port/port_posix_sse.cc
9498
;;
9599
SunOS)
96100
PLATFORM=OS_SOLARIS
97101
COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_SOLARIS"
98102
PLATFORM_LIBS="-lpthread -lrt"
99103
PORT_FILE=port/port_posix.cc
104+
PORT_SSE_FILE=port/port_posix_sse.cc
100105
;;
101106
FreeBSD)
102107
PLATFORM=OS_FREEBSD
103108
COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_FREEBSD"
104109
PLATFORM_LIBS="-lpthread"
105110
PORT_FILE=port/port_posix.cc
111+
PORT_SSE_FILE=port/port_posix_sse.cc
106112
;;
107113
GNU/kFreeBSD)
108114
PLATFORM=OS_KFREEBSD
@@ -115,31 +121,36 @@ case "$TARGET_OS" in
115121
COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_NETBSD"
116122
PLATFORM_LIBS="-lpthread -lgcc_s"
117123
PORT_FILE=port/port_posix.cc
124+
PORT_SSE_FILE=port/port_posix_sse.cc
118125
;;
119126
OpenBSD)
120127
PLATFORM=OS_OPENBSD
121128
COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_OPENBSD"
122129
PLATFORM_LDFLAGS="-pthread"
123130
PORT_FILE=port/port_posix.cc
131+
PORT_SSE_FILE=port/port_posix_sse.cc
124132
;;
125133
DragonFly)
126134
PLATFORM=OS_DRAGONFLYBSD
127135
COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_DRAGONFLYBSD"
128136
PLATFORM_LIBS="-lpthread"
129137
PORT_FILE=port/port_posix.cc
138+
PORT_SSE_FILE=port/port_posix_sse.cc
130139
;;
131140
OS_ANDROID_CROSSCOMPILE)
132141
PLATFORM=OS_ANDROID
133142
COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_ANDROID -DLEVELDB_PLATFORM_POSIX"
134143
PLATFORM_LDFLAGS="" # All pthread features are in the Android C library
135144
PORT_FILE=port/port_posix.cc
145+
PORT_SSE_FILE=port/port_posix_sse.cc
136146
CROSS_COMPILE=true
137147
;;
138148
HP-UX)
139149
PLATFORM=OS_HPUX
140150
COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_HPUX"
141151
PLATFORM_LDFLAGS="-pthread"
142152
PORT_FILE=port/port_posix.cc
153+
PORT_SSE_FILE=port/port_posix_sse.cc
143154
# man ld: +h internal_name
144155
PLATFORM_SHARED_LDFLAGS="-shared -Wl,+h -Wl,"
145156
;;
@@ -148,6 +159,7 @@ case "$TARGET_OS" in
148159
COMMON_FLAGS="$MEMCMP_FLAG -DOS_MACOSX"
149160
[ -z "$INSTALL_PATH" ] && INSTALL_PATH=`pwd`
150161
PORT_FILE=port/port_posix.cc
162+
PORT_SSE_FILE=port/port_posix_sse.cc
151163
PLATFORM_SHARED_EXT=
152164
PLATFORM_SHARED_LDFLAGS=
153165
PLATFORM_SHARED_CFLAGS=
@@ -182,7 +194,7 @@ set +f # re-enable globbing
182194

183195
# The sources consist of the portable files, plus the platform-specific port
184196
# file.
185-
echo "SOURCES=$PORTABLE_FILES $PORT_FILE" >> $OUTPUT
197+
echo "SOURCES=$PORTABLE_FILES $PORT_FILE $PORT_SSE_FILE" >> $OUTPUT
186198
echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> $OUTPUT
187199

188200
if [ "$CROSS_COMPILE" = "true" ]; then
@@ -213,6 +225,21 @@ EOF
213225
fi
214226

215227
rm -f $CXXOUTPUT 2>/dev/null
228+
229+
# Test if gcc SSE 4.2 is supported
230+
$CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -msse4.2 2>/dev/null <<EOF
231+
int main() {}
232+
EOF
233+
if [ "$?" = 0 ]; then
234+
PLATFORM_SSEFLAGS="-msse4.2"
235+
fi
236+
237+
rm -f $CXXOUTPUT 2>/dev/null
238+
fi
239+
240+
# Use the SSE 4.2 CRC32C intrinsics iff runtime checks indicate compiler supports them.
241+
if [ -n "$PLATFORM_SSEFLAGS" ]; then
242+
PLATFORM_SSEFLAGS="$PLATFORM_SSEFLAGS -DLEVELDB_PLATFORM_POSIX_SSE"
216243
fi
217244

218245
PLATFORM_CCFLAGS="$PLATFORM_CCFLAGS $COMMON_FLAGS"
@@ -225,6 +252,7 @@ echo "PLATFORM_LDFLAGS=$PLATFORM_LDFLAGS" >> $OUTPUT
225252
echo "PLATFORM_LIBS=$PLATFORM_LIBS" >> $OUTPUT
226253
echo "PLATFORM_CCFLAGS=$PLATFORM_CCFLAGS" >> $OUTPUT
227254
echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS" >> $OUTPUT
255+
echo "PLATFORM_SSEFLAGS=$PLATFORM_SSEFLAGS" >> $OUTPUT
228256
echo "PLATFORM_SHARED_CFLAGS=$PLATFORM_SHARED_CFLAGS" >> $OUTPUT
229257
echo "PLATFORM_SHARED_EXT=$PLATFORM_SHARED_EXT" >> $OUTPUT
230258
echo "PLATFORM_SHARED_LDFLAGS=$PLATFORM_SHARED_LDFLAGS" >> $OUTPUT

0 commit comments

Comments
 (0)