Skip to content

Commit

Permalink
chore: Switch libnegentropy library build from shared to static linka…
Browse files Browse the repository at this point in the history
…ge (#3041)

* Switch libnegentropy library build from shared to static linkage

* Update negentropy with -fPIC compile option that is necessary for libwaku build

* Bump waku-org/negentropy to the latest on master to incorporate merged static build of libnegentropy
  • Loading branch information
NagyZoltanPeter authored Sep 18, 2024
1 parent 8f28992 commit 83f25c3
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 19 deletions.
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

0 comments on commit 83f25c3

Please sign in to comment.