From 655e5b30fad0793db5a2b8356c8036018f1c9b92 Mon Sep 17 00:00:00 2001 From: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Date: Wed, 18 Sep 2024 01:36:11 +0200 Subject: [PATCH 1/3] Switch libnegentropy library build from shared to static linkage --- Dockerfile | 3 --- Makefile | 6 +++--- apps/liteprotocoltester/Dockerfile.liteprotocoltester | 2 -- .../Dockerfile.liteprotocoltester.compile | 1 - docker/binaries/Dockerfile.bn.amd64 | 3 --- vendor/negentropy | 2 +- waku/waku_sync/raw_bindings.nim | 10 ++++------ 7 files changed, 8 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index de62a1810e..181a6a6314 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,9 +46,6 @@ RUN apk add --no-cache libgcc pcre-dev libpq-dev bind-tools # Fix for 'Error loading shared library libpcre.so.3: No such file or directory' RUN ln -s /usr/lib/libpcre.so /usr/lib/libpcre.so.3 -# Fix for 'Error loading shared library libnegentropy.so: No such file or directory' -COPY --from=nim-build /app/libnegentropy.so /usr/lib/ - # Copy to separate location to accomodate different MAKE_TARGET values COPY --from=nim-build /app/build/$MAKE_TARGET /usr/local/bin/ diff --git a/Makefile b/Makefile index df4cba206b..8b1b7be5ca 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ clean: | clean-librln .PHONY: negentropy LIBNEGENTROPY_BUILDDIR := $(CURDIR)/vendor/negentropy/cpp -LIBNEGENTROPY_FILE := libnegentropy.so +LIBNEGENTROPY_FILE := libnegentropy.a deps: | negentropy @@ -183,9 +183,9 @@ $(LIBNEGENTROPY_FILE): cp $(LIBNEGENTROPY_BUILDDIR)/${LIBNEGENTROPY_FILE} ${LIBNEGENTROPY_FILE} negentropy: | $(LIBNEGENTROPY_FILE) - ## Pass libnegentropy to linker. + ## Pass libnegentropy and it's deps to linker. $(eval LIBNEGENTROPY_PATH := $(shell if [ -f "$(LIBNEGENTROPY_FILE)" ]; then echo "$(LIBNEGENTROPY_FILE)"; else echo "./$(LIBNEGENTROPY_FILE)"; fi)) - $(eval NIM_PARAMS += --passL:$(LIBNEGENTROPY_PATH)) + $(eval NIM_PARAMS += --passL:$(LIBNEGENTROPY_PATH) --passL:-lcrypto --passL:-lssl --passL:-lstdc++) negentropy-clean: $(MAKE) -C $(LIBNEGENTROPY_BUILDDIR) clean && \ diff --git a/apps/liteprotocoltester/Dockerfile.liteprotocoltester b/apps/liteprotocoltester/Dockerfile.liteprotocoltester index d6d4e67f39..11e37078d0 100644 --- a/apps/liteprotocoltester/Dockerfile.liteprotocoltester +++ b/apps/liteprotocoltester/Dockerfile.liteprotocoltester @@ -29,8 +29,6 @@ COPY build/liteprotocoltester /usr/bin/ COPY apps/liteprotocoltester/run_tester_node.sh /usr/bin/ - COPY ./libnegentropy.so /usr/lib/ - ENTRYPOINT ["/usr/bin/run_tester_node.sh", "/usr/bin/liteprotocoltester"] diff --git a/apps/liteprotocoltester/Dockerfile.liteprotocoltester.compile b/apps/liteprotocoltester/Dockerfile.liteprotocoltester.compile index d5b45ee2d5..6e3184c9ac 100644 --- a/apps/liteprotocoltester/Dockerfile.liteprotocoltester.compile +++ b/apps/liteprotocoltester/Dockerfile.liteprotocoltester.compile @@ -51,7 +51,6 @@ # Copy migration scripts for DB upgrades COPY --from=nim-build /app/migrations/ /app/migrations/ - COPY --from=nim-build /app/libnegentropy.so /usr/lib/ ENTRYPOINT ["/usr/bin/liteprotocoltester"] diff --git a/docker/binaries/Dockerfile.bn.amd64 b/docker/binaries/Dockerfile.bn.amd64 index d7fbbca667..8b810e3a10 100644 --- a/docker/binaries/Dockerfile.bn.amd64 +++ b/docker/binaries/Dockerfile.bn.amd64 @@ -19,9 +19,6 @@ RUN apt-get update &&\ # Fix for 'Error loading shared library libpcre.so.3: No such file or directory' RUN ln -s /usr/lib/libpcre.so /usr/lib/libpcre.so.3 -# Fix for 'Error loading shared library libnegentropy.so: No such file or directory' -ADD ./libnegentropy.so ./ - # Copy to separate location to accomodate different MAKE_TARGET values ADD ./build/$MAKE_TARGET /usr/local/bin/ diff --git a/vendor/negentropy b/vendor/negentropy index f152076994..47fb555f26 160000 --- a/vendor/negentropy +++ b/vendor/negentropy @@ -1 +1 @@ -Subproject commit f15207699493a129ac94448f930aa3d3fa748886 +Subproject commit 47fb555f26962f81d2c6671e3bca19f3c4b95a69 diff --git a/waku/waku_sync/raw_bindings.nim b/waku/waku_sync/raw_bindings.nim index e96898d961..8bd9bac776 100644 --- a/waku/waku_sync/raw_bindings.nim +++ b/waku/waku_sync/raw_bindings.nim @@ -9,8 +9,6 @@ const negentropyPath = currentSourcePath.rsplit(DirSep, 1)[0] & DirSep & ".." & DirSep & ".." & DirSep & "vendor" & DirSep & "negentropy" & DirSep & "cpp" & DirSep -{.link: negentropyPath & "libnegentropy.so".} - const NEGENTROPY_HEADER = negentropyPath & "negentropy_wrapper.h" logScope: @@ -193,7 +191,7 @@ proc new*(T: type NegentropyStorage): Result[T, string] = #TODO db name and path let storage = storage_init("", "") - #[ TODO: Uncomment once we move to lmdb + #[ TODO: Uncomment once we move to lmdb if storage == nil: return err("storage initialization failed") ]# return ok(storage) @@ -244,7 +242,7 @@ proc new*( ): Result[T, string] = let subrange = subrange_init(storage, startTime, endTime) - #[ TODO: Uncomment once we move to lmdb + #[ TODO: Uncomment once we move to lmdb if storage == nil: return err("storage initialization failed") ]# return ok(subrange) @@ -314,7 +312,7 @@ method delete*(self: NegentropyWithSubRange) = self.inner.free() method initiate*(self: NegentropyWithSubRange): Result[NegentropyPayload, string] = - ## Client inititate a sync session with a server by sending a payload + ## Client inititate a sync session with a server by sending a payload var myResult {.noinit.}: BindingResult = BindingResult() var myResultPtr = addr myResult @@ -409,7 +407,7 @@ method delete*(self: NegentropyWithStorage) = self.inner.free() method initiate*(self: NegentropyWithStorage): Result[NegentropyPayload, string] = - ## Client inititate a sync session with a server by sending a payload + ## Client inititate a sync session with a server by sending a payload var myResult {.noinit.}: BindingResult = BindingResult() var myResultPtr = addr myResult From 2b320dc23c4171feee97cfe51dca8fa5d54cdbd1 Mon Sep 17 00:00:00 2001 From: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Date: Wed, 18 Sep 2024 02:58:48 +0200 Subject: [PATCH 2/3] Update negentropy with -fPIC compile option that is necessary for libwaku build --- vendor/negentropy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/negentropy b/vendor/negentropy index 47fb555f26..8e08aa246b 160000 --- a/vendor/negentropy +++ b/vendor/negentropy @@ -1 +1 @@ -Subproject commit 47fb555f26962f81d2c6671e3bca19f3c4b95a69 +Subproject commit 8e08aa246bb2dbd4e208d5800076c48ea788baa4 From 264b1730340ad7512429a81caa6b3152c5601072 Mon Sep 17 00:00:00 2001 From: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:07:03 +0200 Subject: [PATCH 3/3] Bump waku-org/negentropy to the latest on master to incorporate merged static build of libnegentropy --- vendor/negentropy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/negentropy b/vendor/negentropy index 8e08aa246b..3c2df0b899 160000 --- a/vendor/negentropy +++ b/vendor/negentropy @@ -1 +1 @@ -Subproject commit 8e08aa246bb2dbd4e208d5800076c48ea788baa4 +Subproject commit 3c2df0b899bae1213d27563e44c5a0d610d8aada