fb_compile_mongo.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. # fail early
  4. set -e
  5. if test -z $ROCKSDB_PATH; then
  6. ROCKSDB_PATH=~/rocksdb
  7. fi
  8. source $ROCKSDB_PATH/build_tools/fbcode_config4.8.1.sh
  9. EXTRA_LDFLAGS=""
  10. if test -z $ALLOC; then
  11. # default
  12. ALLOC=tcmalloc
  13. elif [[ $ALLOC == "jemalloc" ]]; then
  14. ALLOC=system
  15. EXTRA_LDFLAGS+=" -Wl,--whole-archive $JEMALLOC_LIB -Wl,--no-whole-archive"
  16. fi
  17. # we need to force mongo to use static library, not shared
  18. STATIC_LIB_DEP_DIR='build/static_library_dependencies'
  19. test -d $STATIC_LIB_DEP_DIR || mkdir $STATIC_LIB_DEP_DIR
  20. test -h $STATIC_LIB_DEP_DIR/`basename $SNAPPY_LIBS` || ln -s $SNAPPY_LIBS $STATIC_LIB_DEP_DIR
  21. test -h $STATIC_LIB_DEP_DIR/`basename $LZ4_LIBS` || ln -s $LZ4_LIBS $STATIC_LIB_DEP_DIR
  22. EXTRA_LDFLAGS+=" -L $STATIC_LIB_DEP_DIR"
  23. set -x
  24. EXTRA_CMD=""
  25. if ! test -e version.json; then
  26. # this is Mongo 3.0
  27. EXTRA_CMD="--rocksdb \
  28. --variant-dir=linux2/norm
  29. --cxx=${CXX} \
  30. --cc=${CC} \
  31. --use-system-zlib" # add this line back to normal code path
  32. # when https://jira.mongodb.org/browse/SERVER-19123 is resolved
  33. fi
  34. scons \
  35. LINKFLAGS="$EXTRA_LDFLAGS $EXEC_LDFLAGS $PLATFORM_LDFLAGS" \
  36. CCFLAGS="$CXXFLAGS -L $STATIC_LIB_DEP_DIR" \
  37. LIBS="lz4 gcc stdc++" \
  38. LIBPATH="$ROCKSDB_PATH" \
  39. CPPPATH="$ROCKSDB_PATH/include" \
  40. -j32 \
  41. --allocator=$ALLOC \
  42. --nostrip \
  43. --opt=on \
  44. --disable-minimum-compiler-version-enforcement \
  45. --use-system-snappy \
  46. --disable-warnings-as-errors \
  47. $EXTRA_CMD $*