Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Switch libnegentropy library build from shared to static linkage #3041

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 && \
Expand Down
2 changes: 0 additions & 2 deletions apps/liteprotocoltester/Dockerfile.liteprotocoltester
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
3 changes: 0 additions & 3 deletions docker/binaries/Dockerfile.bn.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
2 changes: 1 addition & 1 deletion vendor/negentropy
Submodule negentropy updated 1 files
+20 −9 cpp/Makefile
10 changes: 4 additions & 6 deletions waku/waku_sync/raw_bindings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Loading