rocksdb: build tools

fix linux static binary
This commit is contained in:
HuangYi 2022-12-16 15:30:51 +08:00
parent c7c950be89
commit 7ceea77604
No known key found for this signature in database
GPG key ID: 58776091521E8B17

View file

@ -31,6 +31,11 @@ stdenv.mkDerivation rec {
buildInputs = lib.optional enableJemalloc jemalloc;
outputs = [
"out"
"tools"
];
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=deprecated-copy -Wno-error=pessimizing-move"
+ lib.optionalString stdenv.cc.isClang "-Wno-error=unused-private-field -faligned-allocation";
@ -41,6 +46,7 @@ stdenv.mkDerivation rec {
"-DWITH_BENCHMARK_TOOLS=0"
"-DWITH_TESTS=1"
"-DWITH_TOOLS=0"
"-DWITH_CORE_TOOLS=1"
"-DWITH_BZ2=1"
"-DWITH_LZ4=1"
"-DWITH_SNAPPY=1"
@ -57,6 +63,15 @@ stdenv.mkDerivation rec {
# otherwise "cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]"
hardeningDisable = lib.optional stdenv.hostPlatform.isWindows "format";
preInstall = ''
mkdir -p $tools/bin
cp tools/{ldb,sst_dump} $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.
postFixup = ''
if [ -f "$out"/lib/pkgconfig/rocksdb.pc ]; then