Static link rocksdb with Nimbus. (#2084)

* Static link rocksdb into Nimbus.

* Link in additional compression libraries.

* Support static linking for MacOS.

* Add flag to support disabling rocksdb static linking.

* Static linking is disabled by default. Build nimbus with static linking using: make nimbus_rocksdb_static

* Update nim-rocksdb to latest.
This commit is contained in:
web3-developer 2024-03-28 09:55:12 +08:00 committed by GitHub
parent 058f412bbc
commit 0c0141817c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 1 deletions

View File

@ -115,6 +115,7 @@ VERIF_PROXY_OUT_PATH ?= build/libverifproxy/
libnimbus.so \
libnimbus.a \
libbacktrace \
rocksdb \
dist-amd64 \
dist-arm64 \
dist-arm \
@ -225,6 +226,11 @@ nimbus: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim c $(NIM_PARAMS) -d:chronicles_log_level=TRACE -o:build/$@ "nimbus/$@.nim"
nimbus_rocksdb_static: | build deps rocksdb_static_deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim c $(NIM_PARAMS) -d:enable_rocksdb_static_linking -d:chronicles_log_level=TRACE \
-o:build/$@ "nimbus/nimbus.nim"
# symlink
nimbus.nims:
ln -s nimbus.nimble $@
@ -233,6 +239,10 @@ nimbus.nims:
libbacktrace:
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
# nim-rocksdb static dependencies
rocksdb_static_deps:
+ vendor/nim-rocksdb/scripts/build_static_deps.sh
# builds and runs the nimbus test suite
test: | build deps
$(ENV_SCRIPT) nim test_rocksdb $(NIM_PARAMS) nimbus.nims

View File

@ -159,3 +159,21 @@ if defined(windows) and defined(i386):
# nim-kzg shipping their own blst, nimbus-eth1 too.
# disable nim-kzg's blst
switch("define", "kzgExternalBlst")
# RocksDB static linking is disabled by default
when defined(enable_rocksdb_static_linking):
when defined(windows):
{.fatal: "RocksDB static linking is not supported on Windows".}
switch("define", "rocksdb_static_linking")
# use the C++ linker profile because it's a C++ library
when defined(macosx):
switch("clang.linkerexe", "clang++")
else:
switch("gcc.linkerexe", "g++")
switch("dynlibOverride", "rocksdb")
switch("dynlibOverride", "lz4")
switch("dynlibOverride", "zstd")

2
vendor/nim-rocksdb vendored

@ -1 +1 @@
Subproject commit fc2ba4a836b6b47ae1b17d1c45801c7e06585e19
Subproject commit 90027f187515d760ae4119032ecdcc82368827a5