Add ROCKSDB_DISABLE_* environment variables

Summary:
Should fix #3036.
Closes https://github.com/facebook/rocksdb/pull/3042

Differential Revision: D6452921

Pulled By: sagar0

fbshipit-source-id: eaf11e43fee1f8747006530cfc0c7a358f1c2f0f
This commit is contained in:
Adam Novak 2017-12-05 15:05:41 -08:00 committed by Facebook Github Bot
parent 4634c735a8
commit a37d734596

View File

@ -210,107 +210,137 @@ EOF
fi fi
fi fi
# Test whether Snappy library is installed if ! test $ROCKSDB_DISABLE_SNAPPY; then
# http://code.google.com/p/snappy/ # Test whether Snappy library is installed
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # http://code.google.com/p/snappy/
#include <snappy.h> $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() {} #include <snappy.h>
int main() {}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DSNAPPY" COMMON_FLAGS="$COMMON_FLAGS -DSNAPPY"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lsnappy" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lsnappy"
JAVA_LDFLAGS="$JAVA_LDFLAGS -lsnappy" JAVA_LDFLAGS="$JAVA_LDFLAGS -lsnappy"
fi
fi fi
# Test whether gflags library is installed if ! test $ROCKSDB_DISABLE_GFLAGS; then
# http://gflags.github.io/gflags/ # Test whether gflags library is installed
# check if the namespace is gflags # http://gflags.github.io/gflags/
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null << EOF # check if the namespace is gflags
#include <gflags/gflags.h> $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null << EOF
int main() {} #include <gflags/gflags.h>
int main() {}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DGFLAGS=1" COMMON_FLAGS="$COMMON_FLAGS -DGFLAGS=1"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lgflags" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lgflags"
else
# check if namespace is google
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null << EOF
#include <gflags/gflags.h>
using namespace google;
int main() {}
EOF
if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DGFLAGS=google"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lgflags"
fi
fi
fi fi
# Test whether zlib library is installed if ! test $ROCKSDB_DISABLE_ZLIB; then
$CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether zlib library is installed
#include <zlib.h> $CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() {} #include <zlib.h>
int main() {}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DZLIB" COMMON_FLAGS="$COMMON_FLAGS -DZLIB"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lz" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lz"
JAVA_LDFLAGS="$JAVA_LDFLAGS -lz" JAVA_LDFLAGS="$JAVA_LDFLAGS -lz"
fi
fi fi
# Test whether bzip library is installed if ! test $ROCKSDB_DISABLE_BZIP; then
$CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether bzip library is installed
#include <bzlib.h> $CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() {} #include <bzlib.h>
int main() {}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DBZIP2" COMMON_FLAGS="$COMMON_FLAGS -DBZIP2"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lbz2" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lbz2"
JAVA_LDFLAGS="$JAVA_LDFLAGS -lbz2" JAVA_LDFLAGS="$JAVA_LDFLAGS -lbz2"
fi
fi fi
# Test whether lz4 library is installed if ! test $ROCKSDB_DISABLE_LZ4; then
$CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether lz4 library is installed
#include <lz4.h> $CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
#include <lz4hc.h> #include <lz4.h>
int main() {} #include <lz4hc.h>
int main() {}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DLZ4" COMMON_FLAGS="$COMMON_FLAGS -DLZ4"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -llz4" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -llz4"
JAVA_LDFLAGS="$JAVA_LDFLAGS -llz4" JAVA_LDFLAGS="$JAVA_LDFLAGS -llz4"
fi
fi fi
# Test whether zstd library is installed if ! test $ROCKSDB_DISABLE_ZSTD; then
$CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether zstd library is installed
#include <zstd.h> $CXX $CFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() {} #include <zstd.h>
int main() {}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DZSTD" COMMON_FLAGS="$COMMON_FLAGS -DZSTD"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lzstd" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lzstd"
JAVA_LDFLAGS="$JAVA_LDFLAGS -lzstd" JAVA_LDFLAGS="$JAVA_LDFLAGS -lzstd"
fi
fi fi
# Test whether numa is available if ! test $ROCKSDB_DISABLE_NUMA; then
$CXX $CFLAGS -x c++ - -o /dev/null -lnuma 2>/dev/null <<EOF # Test whether numa is available
#include <numa.h> $CXX $CFLAGS -x c++ - -o /dev/null -lnuma 2>/dev/null <<EOF
#include <numaif.h> #include <numa.h>
int main() {} #include <numaif.h>
int main() {}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DNUMA" COMMON_FLAGS="$COMMON_FLAGS -DNUMA"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lnuma" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lnuma"
JAVA_LDFLAGS="$JAVA_LDFLAGS -lnuma" JAVA_LDFLAGS="$JAVA_LDFLAGS -lnuma"
fi
fi fi
# Test whether tbb is available if ! test $ROCKSDB_DISABLE_TBB; then
$CXX $CFLAGS $LDFLAGS -x c++ - -o /dev/null -ltbb 2>/dev/null <<EOF # Test whether tbb is available
#include <tbb/tbb.h> $CXX $CFLAGS $LDFLAGS -x c++ - -o /dev/null -ltbb 2>/dev/null <<EOF
int main() {} #include <tbb/tbb.h>
int main() {}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DTBB" COMMON_FLAGS="$COMMON_FLAGS -DTBB"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -ltbb" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -ltbb"
JAVA_LDFLAGS="$JAVA_LDFLAGS -ltbb" JAVA_LDFLAGS="$JAVA_LDFLAGS -ltbb"
fi
fi fi
# Test whether jemalloc is available if ! test $ROCKSDB_DISABLE_JEMALLOC; then
if echo 'int main() {}' | $CXX $CFLAGS -x c++ - -o /dev/null -ljemalloc \ # Test whether jemalloc is available
2>/dev/null; then if echo 'int main() {}' | $CXX $CFLAGS -x c++ - -o /dev/null -ljemalloc \
# This will enable some preprocessor identifiers in the Makefile 2>/dev/null; then
JEMALLOC=1 # This will enable some preprocessor identifiers in the Makefile
# JEMALLOC can be enabled either using the flag (like here) or by JEMALLOC=1
# providing direct link to the jemalloc library # JEMALLOC can be enabled either using the flag (like here) or by
WITH_JEMALLOC_FLAG=1 # providing direct link to the jemalloc library
else WITH_JEMALLOC_FLAG=1
fi
fi
if ! test $JEMALLOC && ! test $ROCKSDB_DISABLE_TCMALLOC; then
# jemalloc is not available. Let's try tcmalloc # jemalloc is not available. Let's try tcmalloc
if echo 'int main() {}' | $CXX $CFLAGS -x c++ - -o /dev/null \ if echo 'int main() {}' | $CXX $CFLAGS -x c++ - -o /dev/null \
-ltcmalloc 2>/dev/null; then -ltcmalloc 2>/dev/null; then
@ -319,88 +349,100 @@ EOF
fi fi
fi fi
# Test whether malloc_usable_size is available if ! test $ROCKSDB_DISABLE_MALLOC_USABLE_SIZE; then
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether malloc_usable_size is available
#include <malloc.h> $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() { #include <malloc.h>
size_t res = malloc_usable_size(0); int main() {
return 0; size_t res = malloc_usable_size(0);
} return 0;
}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_MALLOC_USABLE_SIZE" COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_MALLOC_USABLE_SIZE"
fi
fi fi
# Test whether PTHREAD_MUTEX_ADAPTIVE_NP mutex type is available if ! test $ROCKSDB_DISABLE_PTHREAD_MUTEX_ADAPTIVE_NP; then
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether PTHREAD_MUTEX_ADAPTIVE_NP mutex type is available
#include <pthread.h> $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() { #include <pthread.h>
int x = PTHREAD_MUTEX_ADAPTIVE_NP; int main() {
return 0; int x = PTHREAD_MUTEX_ADAPTIVE_NP;
} return 0;
}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX" COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX"
fi
fi fi
# Test whether backtrace is available if ! test $ROCKSDB_DISABLE_BACKTRACE; then
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether backtrace is available
#include <execinfo.h>> $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() { #include <execinfo.h>>
void* frames[1];
backtrace_symbols(frames, backtrace(frames, 1));
return 0;
}
EOF
if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_BACKTRACE"
else
# Test whether execinfo library is installed
$CXX $CFLAGS -lexecinfo -x c++ - -o /dev/null 2>/dev/null <<EOF
#include <execinfo.h>
int main() { int main() {
void* frames[1]; void* frames[1];
backtrace_symbols(frames, backtrace(frames, 1)); backtrace_symbols(frames, backtrace(frames, 1));
return 0;
} }
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_BACKTRACE" COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_BACKTRACE"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lexecinfo" else
JAVA_LDFLAGS="$JAVA_LDFLAGS -lexecinfo" # Test whether execinfo library is installed
$CXX $CFLAGS -lexecinfo -x c++ - -o /dev/null 2>/dev/null <<EOF
#include <execinfo.h>
int main() {
void* frames[1];
backtrace_symbols(frames, backtrace(frames, 1));
}
EOF
if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_BACKTRACE"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lexecinfo"
JAVA_LDFLAGS="$JAVA_LDFLAGS -lexecinfo"
fi
fi fi
fi fi
# Test if -pg is supported if ! test $ROCKSDB_DISABLE_PG; then
$CXX $CFLAGS -pg -x c++ - -o /dev/null 2>/dev/null <<EOF # Test if -pg is supported
int main() { $CXX $CFLAGS -pg -x c++ - -o /dev/null 2>/dev/null <<EOF
return 0; int main() {
} return 0;
}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
PROFILING_FLAGS=-pg PROFILING_FLAGS=-pg
fi
fi fi
# Test whether sync_file_range is supported for compatibility with an old glibc if ! test $ROCKSDB_DISABLE_SYNC_FILE_RANGE; then
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether sync_file_range is supported for compatibility with an old glibc
#include <fcntl.h> $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() { #include <fcntl.h>
int fd = open("/dev/null", 0); int main() {
sync_file_range(fd, 0, 1024, SYNC_FILE_RANGE_WRITE); int fd = open("/dev/null", 0);
} sync_file_range(fd, 0, 1024, SYNC_FILE_RANGE_WRITE);
}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_RANGESYNC_PRESENT" COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_RANGESYNC_PRESENT"
fi
fi fi
# Test whether sched_getcpu is supported if ! test $ROCKSDB_DISABLE_SCHED_GETCPU; then
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF # Test whether sched_getcpu is supported
#include <sched.h> $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() { #include <sched.h>
int cpuid = sched_getcpu(); int main() {
} int cpuid = sched_getcpu();
}
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_SCHED_GETCPU_PRESENT" COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_SCHED_GETCPU_PRESENT"
fi
fi fi
fi fi