Revision e5ae1bb46564689e56a38f3509daffa4aca3b29c authored by Daniel Black on 27 June 2018, 19:09:50 UTC, committed by Facebook Github Bot on 27 June 2018, 19:23:07 UTC
Summary:
Various rearrangements of the cch maths failed or replacing = '\0' with
memset failed to convince the compiler it was nul terminated. So took
the perverse option of changing strncpy to strcpy.

Return null if memory couldn't be allocated.

util/status.cc: In static member function ‘static const char* rocksdb::Status::CopyState(const char*)’:
util/status.cc:28:15: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
   std::strncpy(result, state, cch - 1);
   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
util/status.cc:19:18: note: length computed here
       std::strlen(state) + 1; // +1 for the null terminator
       ~~~~~~~~~~~^~~~~~~
cc1plus: all warnings being treated as errors
make: *** [Makefile:645: shared-objects/util/status.o] Error 1

closes #2705
Closes https://github.com/facebook/rocksdb/pull/3870

Differential Revision: D8594114

Pulled By: anand1976

fbshipit-source-id: ab20f3a456a711e4d29144ebe630e4fe3c99ec25
1 parent a16e00b
Raw File
fb_compile_mongo.sh
#!/bin/sh

# fail early
set -e

if test -z $ROCKSDB_PATH; then
  ROCKSDB_PATH=~/rocksdb
fi
source $ROCKSDB_PATH/build_tools/fbcode_config4.8.1.sh

EXTRA_LDFLAGS=""

if test -z $ALLOC; then
  # default
  ALLOC=tcmalloc
elif [[ $ALLOC == "jemalloc" ]]; then
  ALLOC=system
  EXTRA_LDFLAGS+=" -Wl,--whole-archive $JEMALLOC_LIB -Wl,--no-whole-archive"
fi

# we need to force mongo to use static library, not shared
STATIC_LIB_DEP_DIR='build/static_library_dependencies'
test -d $STATIC_LIB_DEP_DIR || mkdir $STATIC_LIB_DEP_DIR
test -h $STATIC_LIB_DEP_DIR/`basename $SNAPPY_LIBS` || ln -s $SNAPPY_LIBS $STATIC_LIB_DEP_DIR
test -h $STATIC_LIB_DEP_DIR/`basename $LZ4_LIBS` || ln -s $LZ4_LIBS $STATIC_LIB_DEP_DIR

EXTRA_LDFLAGS+=" -L $STATIC_LIB_DEP_DIR"

set -x

EXTRA_CMD=""
if ! test -e version.json; then
  # this is Mongo 3.0
  EXTRA_CMD="--rocksdb \
    --variant-dir=linux2/norm
    --cxx=${CXX} \
    --cc=${CC} \
    --use-system-zlib"  # add this line back to normal code path
                        # when https://jira.mongodb.org/browse/SERVER-19123 is resolved
fi

scons \
  LINKFLAGS="$EXTRA_LDFLAGS $EXEC_LDFLAGS $PLATFORM_LDFLAGS" \
  CCFLAGS="$CXXFLAGS -L $STATIC_LIB_DEP_DIR" \
  LIBS="lz4 gcc stdc++" \
  LIBPATH="$ROCKSDB_PATH" \
  CPPPATH="$ROCKSDB_PATH/include" \
  -j32 \
  --allocator=$ALLOC \
  --nostrip \
  --opt=on \
  --disable-minimum-compiler-version-enforcement \
  --use-system-snappy \
  --disable-warnings-as-errors \
  $EXTRA_CMD $*
back to top