From e694d177186ee7932d3f6ea47128d1b40c5f991e Mon Sep 17 00:00:00 2001
From: pablo
Date: Sun, 22 Feb 2026 08:54:45 +0200
Subject: [PATCH] fix: building liblogoschat
- build liblogoschat and required liblibchat
- update libchat and nim-ffi to latest
---
Makefile | 9 +++++++++
logos_chat.nimble | 14 +++++++++++++-
src/chat/client.nim | 2 +-
vendor/libchat | 2 +-
vendor/nim-ffi | 2 +-
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index db259d3..f2e614c 100644
--- a/Makefile
+++ b/Makefile
@@ -130,6 +130,15 @@ liblogoschat: | build-waku-librln build-waku-nat build-libchat logos_chat.nims
$(ENV_SCRIPT) nim liblogoschat $(NIM_PARAMS) --path:src logos_chat.nims && \
echo -e "\n\x1B[92mLibrary built successfully:\x1B[39m" && \
echo " $(shell pwd)/$(LIBLOGOSCHAT)"
+ifeq ($(shell uname -s),Darwin)
+ @cp vendor/libchat/target/release/liblibchat.dylib build/
+ @# Fix install names so the dylibs are relocatable (no absolute paths)
+ @install_name_tool -id @rpath/liblibchat.dylib build/liblibchat.dylib
+ @echo " $(shell pwd)/build/liblibchat.dylib"
+else ifeq ($(shell uname -s),Linux)
+ @cp vendor/libchat/target/release/liblibchat.so build/
+ @echo " $(shell pwd)/build/liblibchat.so"
+endif
endif
diff --git a/logos_chat.nimble b/logos_chat.nimble
index bcf896c..beda05c 100644
--- a/logos_chat.nimble
+++ b/logos_chat.nimble
@@ -77,5 +77,17 @@ task pingpong, "Build the Pingpong example":
buildBinary name, "examples/", "-d:chronicles_log_level='INFO' -d:chronicles_disabled_topics='waku node' "
task liblogoschat, "Build the Logos-Chat shared library (C bindings)":
+ # Dynamically link liblibchat (Rust) on both platforms.
+ # Clients must distribute liblibchat.so/.dylib alongside liblogoschat.so/.dylib.
+ # Cannot static link because of duplicate symbols: both liblibchat.a and librln embed Rust's std
+ var linkFlags = ""
+ when defined(linux):
+ staticLinkFlags = " -d:CONVERSATIONS_LIB:liblibchat.so" &
+ " --passL:-Wl,-rpath,'$$ORIGIN'"
+ elif defined(macosx):
+ linkFlags = " -d:CONVERSATIONS_LIB:@rpath/liblibchat.dylib" &
+ " --passL:-Wl,-rpath,@loader_path"
+
buildLibrary "logoschat", "library/",
- "-d:chronicles_log_level='INFO' -d:chronicles_enabled=on --path:src --path:vendor/nim-ffi"
+ "-d:chronicles_log_level='INFO' -d:chronicles_enabled=on --path:src --path:vendor/nim-ffi" &
+ linkFlags
diff --git a/src/chat/client.nim b/src/chat/client.nim
index 3717311..aeafeed 100644
--- a/src/chat/client.nim
+++ b/src/chat/client.nim
@@ -81,7 +81,7 @@ proc newClient*(ds: WakuClient, ident: Identity): ChatClient {.raises: [IOError,
var q = QueueRef(queue: newAsyncQueue[ChatPayload](10))
var c = ChatClient(
- libchatCtx: newConversationsContext(),
+ libchatCtx: newConversationsContext(ident.getName()),
ds: ds,
id: ident.getName(),
inboundQueue: q,
diff --git a/vendor/libchat b/vendor/libchat
index a9ca4ff..960bb19 160000
--- a/vendor/libchat
+++ b/vendor/libchat
@@ -1 +1 @@
-Subproject commit a9ca4ffb7de90ea4cd269350c189c19fb78a2589
+Subproject commit 960bb195a13657a09fa2df66262b3b2ced738f30
diff --git a/vendor/nim-ffi b/vendor/nim-ffi
index c2c03f1..bb8a3e7 160000
--- a/vendor/nim-ffi
+++ b/vendor/nim-ffi
@@ -1 +1 @@
-Subproject commit c2c03f1f0f300ec3aab8b733fe97575f452f6133
+Subproject commit bb8a3e7e221c36effd528605a6eb8ecd0f8b22dd