From 05b46239bac7457fc61c07b1ea9ecf293635e873 Mon Sep 17 00:00:00 2001 From: gabrielmer <101006718+gabrielmer@users.noreply.github.com> Date: Mon, 3 Mar 2025 11:22:48 +0200 Subject: [PATCH] fix: using nimMainPrefix in libwaku (#3311) --- library/libwaku.nim | 6 ++++-- waku.nimble | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/library/libwaku.nim b/library/libwaku.nim index a2290a60c..258ac27b2 100644 --- a/library/libwaku.nim +++ b/library/libwaku.nim @@ -107,7 +107,7 @@ proc onTopicHealthChange(ctx: ptr WakuContext): TopicHealthChangeHandler = # Every Nim library must have this function called - the name is derived from # the `--nimMainPrefix` command line option -proc NimMain() {.importc.} +proc libwakuNimMain() {.importc.} # To control when the library has been initialized var initialized: Atomic[bool] @@ -122,7 +122,9 @@ if defined(android): proc initializeLibrary() {.exported.} = if not initialized.exchange(true): - NimMain() # Every Nim library needs to call `NimMain` once exactly + ## Every Nim library needs to call `NimMain` once exactly, to initialize the Nim runtime. + ## Being `` the value given in the optional compilation flag --nimMainPrefix:yourprefix + libwakuNimMain() when declared(setupForeignThreadGc): setupForeignThreadGc() when declared(nimGC_setStackBottom): diff --git a/waku.nimble b/waku.nimble index 14c374982..6cf804098 100644 --- a/waku.nimble +++ b/waku.nimble @@ -65,11 +65,11 @@ proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") = extra_params &= " " & paramStr(i) if `type` == "static": exec "nim c" & " --out:build/" & name & - ".a --threads:on --app:staticlib --opt:size --noMain --mm:refc --header --undef:metrics --skipParentCfg:on " & + ".a --threads:on --app:staticlib --opt:size --noMain --mm:refc --header --undef:metrics --nimMainPrefix:libwaku --skipParentCfg:on " & extra_params & " " & srcDir & name & ".nim" else: exec "nim c" & " --out:build/" & name & - ".so --threads:on --app:lib --opt:size --noMain --mm:refc --header --undef:metrics --skipParentCfg:on " & + ".so --threads:on --app:lib --opt:size --noMain --mm:refc --header --undef:metrics --nimMainPrefix:libwaku --skipParentCfg:on " & extra_params & " " & srcDir & name & ".nim" proc buildMobileAndroid(srcDir = ".", params = "") =