nixpkgs/pkgs/development/libraries/rocksdb/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

104 lines
3.0 KiB
Nix
Raw Normal View History

2023-02-10 04:08:38 +00:00
{ lib
, stdenv
2020-07-17 18:10:46 +00:00
, fetchFromGitHub
, fetchpatch
, cmake
, ninja
, bzip2
, lz4
, snappy
, zlib
, zstd
2023-02-10 04:08:38 +00:00
, windows
, enableJemalloc ? false
, jemalloc
2019-11-15 23:19:04 +00:00
, enableLite ? false
, enableShared ? !stdenv.hostPlatform.isStatic
, sse42Support ? stdenv.hostPlatform.sse4_2Support
2019-11-15 23:19:04 +00:00
}:
2015-04-21 18:01:44 +00:00
stdenv.mkDerivation rec {
pname = "rocksdb";
2023-03-03 00:34:15 +00:00
version = "7.10.2";
2018-03-11 15:41:57 +00:00
2015-04-21 18:01:44 +00:00
src = fetchFromGitHub {
owner = "facebook";
repo = pname;
2015-11-06 02:20:18 +00:00
rev = "v${version}";
2023-03-03 00:34:15 +00:00
sha256 = "sha256-U2ReSrJwjAXUdRmwixC0DQXht/h/6rV8SOf5e2NozIs=";
2015-04-21 18:01:44 +00:00
};
2018-04-04 01:23:24 +00:00
nativeBuildInputs = [ cmake ninja ];
2020-07-17 18:10:46 +00:00
propagatedBuildInputs = [ bzip2 lz4 snappy zlib zstd ];
2023-02-10 04:08:38 +00:00
buildInputs = lib.optional enableJemalloc jemalloc
++ lib.optional stdenv.hostPlatform.isMinGW windows.mingw_w64_pthreads;
outputs = [
"out"
"tools"
];
env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [
2022-12-23 16:57:29 +00:00
"-Wno-error=deprecated-copy"
"-Wno-error=pessimizing-move"
# Needed with GCC 12
"-Wno-error=format-truncation"
"-Wno-error=maybe-uninitialized"
] ++ lib.optionals stdenv.cc.isClang [
"-Wno-error=unused-private-field"
"-faligned-allocation"
]);
2019-11-04 23:59:23 +00:00
cmakeFlags = [
"-DPORTABLE=1"
"-DWITH_JEMALLOC=${if enableJemalloc then "1" else "0"}"
"-DWITH_JNI=0"
2020-07-17 18:10:46 +00:00
"-DWITH_BENCHMARK_TOOLS=0"
"-DWITH_TESTS=1"
"-DWITH_TOOLS=0"
"-DWITH_CORE_TOOLS=1"
"-DWITH_BZ2=1"
"-DWITH_LZ4=1"
"-DWITH_SNAPPY=1"
"-DWITH_ZLIB=1"
"-DWITH_ZSTD=1"
"-DWITH_GFLAGS=0"
rocksdb: enable USE_RTTI=1 This is required for programs using rocksdb and and typeinfo. Otherwise, linking them fails with errors like this (that's ceph): /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(RocksDBStore.cc.o):(.data.rel.ro._ZTIN12RocksDBStore14RocksWBHandlerE[_ZTIN12RocksDBStore14RocksWBHandlerE]+0x10): undefined reference to `typeinfo for rocksdb::WriteBatch::Handler' /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(RocksDBStore.cc.o):(.data.rel.ro._ZTIN12RocksDBStore19MergeOperatorRouterE[_ZTIN12RocksDBStore19MergeOperatorRouterE]+0x10): undefined reference to `typeinfo for rocksdb::AssociativeMergeOperator' /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(RocksDBStore.cc.o):(.data.rel.ro._ZTIN12RocksDBStore19MergeOperatorLinkerE[_ZTIN12RocksDBStore19MergeOperatorLinkerE]+0x10): undefined reference to `typeinfo for rocksdb::AssociativeMergeOperator' /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(RocksDBStore.cc.o):(.data.rel.ro._ZTI17CephRocksdbLogger[_ZTI17CephRocksdbLogger]+0x10): undefined reference to `typeinfo for rocksdb::Logger' /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(BlueRocksEnv.cc.o):(.data.rel.ro._ZTI12BlueRocksEnv[_ZTI12BlueRocksEnv]+0x10): undefined reference to `typeinfo for rocksdb::EnvWrapper' /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(BlueRocksEnv.cc.o):(.data.rel.ro._ZTI23BlueRocksSequentialFile[_ZTI23BlueRocksSequentialFile]+0x10): undefined reference to `typeinfo for rocksdb::SequentialFile' /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(BlueRocksEnv.cc.o):(.data.rel.ro._ZTI25BlueRocksRandomAccessFile[_ZTI25BlueRocksRandomAccessFile]+0x10): undefined reference to `typeinfo for rocksdb::RandomAccessFile' /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(BlueRocksEnv.cc.o):(.data.rel.ro._ZTI21BlueRocksWritableFile[_ZTI21BlueRocksWritableFile]+0x10): undefined reference to `typeinfo for rocksdb::WritableFile' /nix/store/cg0k49h66nkdqx6ccwnqr0i4q0fnfznc-binutils-2.31.1/bin/ld: ../../lib/libos.a(BlueRocksEnv.cc.o):(.data.rel.ro._ZTI17BlueRocksFileLock[_ZTI17BlueRocksFileLock]+0x10): undefined reference to `typeinfo for rocksdb::FileLock'
2019-11-09 22:32:56 +00:00
"-DUSE_RTTI=1"
2019-11-15 23:19:04 +00:00
"-DROCKSDB_INSTALL_ON_WINDOWS=YES" # harmless elsewhere
(lib.optional sse42Support "-DFORCE_SSE42=1")
(lib.optional enableLite "-DROCKSDB_LITE=1")
2019-11-15 23:19:04 +00:00
"-DFAIL_ON_WARNINGS=${if stdenv.hostPlatform.isMinGW then "NO" else "YES"}"
] ++ lib.optional (!enableShared) "-DROCKSDB_BUILD_SHARED=0";
2015-04-21 18:01:44 +00:00
2019-11-15 23:19:04 +00:00
# otherwise "cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]"
hardeningDisable = lib.optional stdenv.hostPlatform.isWindows "format";
2019-11-15 23:19:04 +00:00
preInstall = ''
mkdir -p $tools/bin
2023-02-10 04:08:38 +00:00
cp tools/{ldb,sst_dump}${stdenv.hostPlatform.extensions.executable} $tools/bin/
'' + lib.optionalString stdenv.isDarwin ''
ls -1 $tools/bin/* | xargs -I{} install_name_tool -change "@rpath/librocksdb.7.dylib" $out/lib/librocksdb.dylib {}
'' + lib.optionalString (stdenv.isLinux && enableShared) ''
ls -1 $tools/bin/* | xargs -I{} patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib {}
'';
# Old version doesn't ship the .pc file, new version puts wrong paths in there.
2022-09-23 07:43:31 +00:00
postFixup = ''
if [ -f "$out"/lib/pkgconfig/rocksdb.pc ]; then
substituteInPlace "$out"/lib/pkgconfig/rocksdb.pc \
--replace '="''${prefix}//' '="/'
fi
2022-09-23 07:43:31 +00:00
'';
meta = with lib; {
homepage = "https://rocksdb.org";
2015-04-21 18:01:44 +00:00
description = "A library that provides an embeddable, persistent key-value store for fast storage";
2021-08-08 11:00:00 +00:00
changelog = "https://github.com/facebook/rocksdb/raw/v${version}/HISTORY.md";
license = licenses.asl20;
2021-08-08 11:00:00 +00:00
platforms = platforms.all;
maintainers = with maintainers; [ adev magenbluten ];
2015-04-21 18:01:44 +00:00
};
}