diff --git a/Makefile b/Makefile index 45357ff7e5..4e4f574cc8 100644 --- a/Makefile +++ b/Makefile @@ -824,6 +824,10 @@ else git_date := $(shell git log -1 --date=iso --format="%ad" 2>/dev/null | awk '{print $1 " " $2}' 2>/dev/null) endif +use_rtti := $(USE_RTTI) +portable := $(PORTABLE) +debug_level := $(DEBUG_LEVEL) + SPDB_BUILD_TAG ?= ifneq (${SPDB_RELEASE_BUILD},1) ifeq ($(strip ${SPDB_BUILD_TAG}),) @@ -833,7 +837,7 @@ ifneq (${SPDB_RELEASE_BUILD},1) SPDB_BUILD_TAG := ? endif endif -gen_build_version = sed -e s/@GIT_SHA@/$(git_sha)/ -e s:@GIT_TAG@:"$(git_tag)": -e s/@GIT_MOD@/"$(git_mod)"/ -e s/@BUILD_DATE@/"$(build_date)"/ -e s/@GIT_DATE@/"$(git_date)"/ -e 's!@SPDB_BUILD_TAG@!$(SPDB_BUILD_TAG:!=\!)!' -e s/@ROCKSDB_PLUGIN_BUILTINS@/'$(ROCKSDB_PLUGIN_BUILTINS)'/ -e s/@ROCKSDB_PLUGIN_EXTERNS@/"$(ROCKSDB_PLUGIN_EXTERNS)"/ util/build_version.cc.in +gen_build_version = sed -e s/@GIT_SHA@/$(git_sha)/ -e s:@GIT_TAG@:"$(git_tag)": -e s/@GIT_MOD@/"$(git_mod)"/ -e s/@BUILD_DATE@/"$(build_date)"/ -e s/@GIT_DATE@/"$(git_date)"/ -e 's!@SPDB_BUILD_TAG@!$(SPDB_BUILD_TAG:!=\!)!' -e s/@ROCKSDB_PLUGIN_BUILTINS@/'$(ROCKSDB_PLUGIN_BUILTINS)'/ -e s/@ROCKSDB_PLUGIN_EXTERNS@/"$(ROCKSDB_PLUGIN_EXTERNS)"/ -e s/@DEBUG_LEVEL@/"$(debug_level)"/ -e s/@PORTABLE@/"$(portable)"/ -e s/@USE_RTTI@/"$(use_rtti)"/ util/build_version.cc.in # Record the version of the source that we are compiling. # We keep a record of the git revision in this file. It is then built diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index 69150bd5f1..397d816fa0 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -5190,6 +5190,8 @@ void DumpRocksDBBuildVersion(Logger* log) { if (date != props.end()) { ROCKS_LOG_HEADER(log, "Compile date %s", date->second.c_str()); } + ROCKS_LOG_HEADER(log, "Build properties:%s", + GetRocksDebugPropertiesAsString().c_str()); } SequenceNumber DBImpl::GetEarliestMemTableSequenceNumber(SuperVersion* sv, diff --git a/include/rocksdb/version.h b/include/rocksdb/version.h index b02cb6d7b7..b2444fc033 100644 --- a/include/rocksdb/version.h +++ b/include/rocksdb/version.h @@ -27,6 +27,10 @@ namespace ROCKSDB_NAMESPACE { // was created. const std::unordered_map& GetRocksBuildProperties(); +// Returns a set of debug properties such as PORTABLE, DEBUG_LEVEL +// and USE_RTTI indicating how was created. +const std::unordered_map& GetRocksDebugProperties(); + // Returns the current version of RocksDB as a string (e.g. "6.16.0"). // If with_patch is true, the patch is included (6.16.x). // Otherwise, only major and minor version is included (6.16) @@ -40,4 +44,15 @@ std::string GetRocksVersionAsString(bool with_patch = true); // GetRocksVersionString) is printed. std::string GetRocksBuildInfoAsString(const std::string& program, bool verbose = false); +//// Gets the set of build properties (@see GetRocksBuildProperties) into a +// string. Properties are returned one-per-line, with the first line being: +// " from RocksDB . +// If verbose is true, the full set of properties is +// printed. If verbose is false, only the version information (@see +// GetRocksVersionString) is printed. +std::string GetRocksBuildFlagsAsString(); +//// Gets the set of build debug properties (@see GetRocksDebugProperties()) +// into a string. +// Properties are returned on after another(if defined) in a single line. +std::string GetRocksDebugPropertiesAsString(); } // namespace ROCKSDB_NAMESPACE diff --git a/util/build_version.cc.in b/util/build_version.cc.in index f89d3af11c..2e03800006 100644 --- a/util/build_version.cc.in +++ b/util/build_version.cc.in @@ -25,6 +25,15 @@ static const std::string speedb_build_date = "speedb_build_date:@BUILD_DATE@"; #define SPDB_BUILD_TAG "@SPDB_BUILD_TAG@" static const std::string speedb_build_tag = "speedb_build_tag:" SPDB_BUILD_TAG; +#define USE_RTTI "@USE_RTTI@" +static const std::string use_rtti = "use_rtti:" USE_RTTI; + +#define DEBUG_LEVEL "@DEBUG_LEVEL@" +static const std::string debug_level = "debug_level:" DEBUG_LEVEL; + +#define PORTABLE "@PORTABLE@" +static const std::string portable = "portable:" PORTABLE; + extern "C" { @ROCKSDB_PLUGIN_EXTERNS@ } // extern "C" @@ -45,22 +54,34 @@ static void AddProperty(std::unordered_map *props, con } } } - -static std::unordered_map* LoadPropertiesSet() { - auto * properties = new std::unordered_map(); - AddProperty(properties, speedb_build_git_sha); - AddProperty(properties, speedb_build_git_tag); - AddProperty(properties, speedb_build_date); - if (SPDB_BUILD_TAG[0] == '@') { - AddProperty(properties, "?"); + +static std::unordered_map* LoadPropertiesSet(std::string p) { + if(p == "properties"){ + auto * properties = new std::unordered_map(); + AddProperty(properties, speedb_build_git_sha); + AddProperty(properties, speedb_build_git_tag); + AddProperty(properties, speedb_build_date); + if (SPDB_BUILD_TAG[0] == '@') { + AddProperty(properties, "?"); + } else { + AddProperty(properties, speedb_build_tag); + } + return properties; } else { - AddProperty(properties, speedb_build_tag); + auto * debug_properties = new std::unordered_map(); + AddProperty(debug_properties, use_rtti); + AddProperty(debug_properties, debug_level); + AddProperty(debug_properties, portable); + return debug_properties; } - return properties; } const std::unordered_map& GetRocksBuildProperties() { - static std::unique_ptr> props(LoadPropertiesSet()); + static std::unique_ptr> props(LoadPropertiesSet("properties")); + return *props; +} +const std::unordered_map& GetRocksDebugProperties() { + static std::unique_ptr> props(LoadPropertiesSet("debug_properties")); return *props; } @@ -100,6 +121,19 @@ std::string GetRocksBuildInfoAsString(const std::string& program, bool verbose) info.append(": "); info.append(it.second); } + info.append("\n Build properties:"); + info.append(GetRocksDebugPropertiesAsString()); + } + return info; +} + +std::string GetRocksDebugPropertiesAsString() { + std::string info; + for (const auto& it : GetRocksDebugProperties()) { + info.append(" "); + info.append(it.first); + info.append("="); + info.append(it.second); } return info; }