diff --git a/TARGETS b/TARGETS index ba6f96c0b5..c0c6fd97fa 100644 --- a/TARGETS +++ b/TARGETS @@ -6,29 +6,9 @@ REPO_PATH = package_name() + "/" ROCKSDB_COMPILER_FLAGS = [ "-fno-builtin-memcmp", - "-DROCKSDB_PLATFORM_POSIX", - "-DROCKSDB_LIB_IO_POSIX", - "-DROCKSDB_FALLOCATE_PRESENT", - "-DROCKSDB_MALLOC_USABLE_SIZE", - "-DROCKSDB_RANGESYNC_PRESENT", - "-DROCKSDB_SCHED_GETCPU_PRESENT", - "-DROCKSDB_SUPPORT_THREAD_LOCAL", - "-DOS_LINUX", - # Flags to enable libs we include - "-DSNAPPY", - "-DZLIB", - "-DBZIP2", - "-DLZ4", - "-DZSTD", - "-DZSTD_STATIC_LINKING_ONLY", - "-DGFLAGS=gflags", - "-DNUMA", - "-DTBB", # Needed to compile in fbcode "-Wno-expansion-to-defined", # Added missing flags from output of build_detect_platform - "-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX", - "-DROCKSDB_BACKTRACE", "-Wnarrowing", "-DROCKSDB_NO_DYNAMIC_EXTENSION", ] @@ -41,11 +21,54 @@ ROCKSDB_EXTERNAL_DEPS = [ ("lz4", None, "lz4"), ("zstd", None), ("tbb", None), - ("numa", None, "numa"), ("googletest", None, "gtest"), ] +ROCKSDB_OS_DEPS = [ + ( + "linux", + ["third-party//numa:numa"], + ), +] + +ROCKSDB_OS_PREPROCESSOR_FLAGS = [ + ( + "linux", + [ + "-DOS_LINUX", + "-DROCKSDB_FALLOCATE_PRESENT", + "-DROCKSDB_MALLOC_USABLE_SIZE", + "-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX", + "-DROCKSDB_RANGESYNC_PRESENT", + "-DROCKSDB_SCHED_GETCPU_PRESENT", + "-DHAVE_SSE42", + "-DNUMA", + ], + ), + ( + "macos", + ["-DOS_MACOSX"], + ), +] + ROCKSDB_PREPROCESSOR_FLAGS = [ + "-DROCKSDB_PLATFORM_POSIX", + "-DROCKSDB_LIB_IO_POSIX", + "-DROCKSDB_SUPPORT_THREAD_LOCAL", + + # Flags to enable libs we include + "-DSNAPPY", + "-DZLIB", + "-DBZIP2", + "-DLZ4", + "-DZSTD", + "-DZSTD_STATIC_LINKING_ONLY", + "-DGFLAGS=gflags", + "-DTBB", + + # Added missing flags from output of build_detect_platform + "-DROCKSDB_BACKTRACE", + # Directories with files for #include "-I" + REPO_PATH + "include/", "-I" + REPO_PATH, @@ -53,7 +76,6 @@ ROCKSDB_PREPROCESSOR_FLAGS = [ ROCKSDB_ARCH_PREPROCESSOR_FLAGS = { "x86_64": [ - "-DHAVE_SSE42", "-DHAVE_PCLMUL", ], } @@ -70,9 +92,15 @@ sanitizer = read_config("fbcode", "sanitizer") # Do not enable jemalloc if sanitizer presents. RocksDB will further detect # whether the binary is linked with jemalloc at runtime. -ROCKSDB_COMPILER_FLAGS += (["-DROCKSDB_JEMALLOC"] if sanitizer == "" else []) +ROCKSDB_OS_PREPROCESSOR_FLAGS += ([( + "linux", + ["-DROCKSDB_JEMALLOC"], +)] if sanitizer == "" else []) -ROCKSDB_EXTERNAL_DEPS += ([("jemalloc", None, "headers")] if sanitizer == "" else []) +ROCKSDB_OS_DEPS += ([( + "linux", + ["third-party//jemalloc:headers"], +)] if sanitizer == "" else []) cpp_library( name = "rocksdb_lib", @@ -308,6 +336,8 @@ cpp_library( auto_headers = AutoHeaders.RECURSIVE_GLOB, arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS, + os_deps = ROCKSDB_OS_DEPS, + os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, deps = [], external_deps = ROCKSDB_EXTERNAL_DEPS, @@ -328,6 +358,8 @@ cpp_library( auto_headers = AutoHeaders.RECURSIVE_GLOB, arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS, + os_deps = ROCKSDB_OS_DEPS, + os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, deps = [":rocksdb_lib"], external_deps = ROCKSDB_EXTERNAL_DEPS, @@ -344,6 +376,8 @@ cpp_library( auto_headers = AutoHeaders.RECURSIVE_GLOB, arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS, + os_deps = ROCKSDB_OS_DEPS, + os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, deps = [":rocksdb_lib"], external_deps = ROCKSDB_EXTERNAL_DEPS, @@ -355,6 +389,8 @@ cpp_library( auto_headers = AutoHeaders.RECURSIVE_GLOB, arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS, + os_deps = ROCKSDB_OS_DEPS, + os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, deps = [":rocksdb_test_lib"], external_deps = ROCKSDB_EXTERNAL_DEPS, @@ -1113,6 +1149,8 @@ ROCKS_TESTS = [ rocksdb_arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS, rocksdb_compiler_flags = ROCKSDB_COMPILER_FLAGS, rocksdb_external_deps = ROCKSDB_EXTERNAL_DEPS, + rocksdb_os_deps = ROCKSDB_OS_DEPS, + rocksdb_os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, rocksdb_preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, test_cc = test_cc, test_name = test_name, diff --git a/defs.bzl b/defs.bzl index f3e8339783..a9f25ebcc4 100644 --- a/defs.bzl +++ b/defs.bzl @@ -8,9 +8,11 @@ def test_binary( test_cc, parallelism, rocksdb_arch_preprocessor_flags, + rocksdb_os_preprocessor_flags, rocksdb_compiler_flags, rocksdb_preprocessor_flags, - rocksdb_external_deps): + rocksdb_external_deps, + rocksdb_os_deps): TEST_RUNNER = native.package_name() + "/buckifier/rocks_test_runner.sh" ttype = "gtest" if parallelism == "parallel" else "simple" @@ -20,9 +22,11 @@ def test_binary( name = test_bin, srcs = [test_cc], arch_preprocessor_flags = rocksdb_arch_preprocessor_flags, + os_preprocessor_flags = rocksdb_os_preprocessor_flags, compiler_flags = rocksdb_compiler_flags, preprocessor_flags = rocksdb_preprocessor_flags, deps = [":rocksdb_test_lib"], + os_deps = rocksdb_os_deps, external_deps = rocksdb_external_deps, )