Skip to content

feat: libwaku dll for status go #3460

Merged
darshankabariya merged 12 commits intomasterfrom
libwaku_dll
Jun 25, 2025
Merged

feat: libwaku dll for status go #3460
darshankabariya merged 12 commits intomasterfrom
libwaku_dll

Conversation

@darshankabariya
Copy link
Copy Markdown
Contributor

@darshankabariya darshankabariya commented Jun 19, 2025

Added support for building dynamic libraries (*.dll) on Windows systems.

Now, both libwaku.dll and wakunode2.exe can be generated using ./script/build_windows.sh.

Also added CI checks to verify the successful build of libwaku.dll.
@gabrielmer

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 19, 2025

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:3460

Built from 26fdbbf

Copy link
Copy Markdown
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for it!
Nevertheless, I think we need to double-check it :)
When trying to build on Ubuntu, I'm getting the following:

12:10:28 {libwaku_dll} ~/workspace/status/nwaku$ 
$  [Nimbus env]$ make libwaku -j8

Warning: to ensure you are building in a supported repo state, please always run "make update" after "git pull"
(it looks like you've forgotten to do this).
This also applies whenever you switch to a new branch or commit, e.g.: whenever you run "git checkout ...".

bash: -c: line 1: syntax error near unexpected token `Linux,Windows'
bash: -c: line 1: `ifeq (Linux,Windows)'
make: *** [Makefile:406: libwaku] Error 2

Cheers

execute_command "make wakunode2 LOG_LEVEL=DEBUG V=1 -j8"
execute_command "make wakunode2 LOG_LEVEL=DEBUG V=1 -j"

echo "9. -.-.-.- Building libwaku -.-.-.- "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "9. -.-.-.- Building libwaku -.-.-.- "
echo "10. -.-.-.- Building libwaku -.-.-.- "

exec "nim c" & " --out:build/" & name &
".so --threads:on --app:lib --opt:size --noMain --mm:refc --header -d:metrics --nimMainPrefix:libwaku --skipParentCfg:on -d:discv5_protocol_id=d5waku " &
extra_params & " " & srcDir & name & ".nim"
when defined(windows):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the unix-based OSs are forgotten somehow

waku.nimble Outdated
--warning:Deprecated:off \
--warning:UnusedImport:on \
-d:chronicles_log_level=TRACE """,
"""-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it vertical :)
Easier to read and easier to see diffs on each line in future PRs
Also applicable to the next change

Copy link
Copy Markdown
Contributor Author

@darshankabariya darshankabariya Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for comment @Ivansete-status, I’ve addressed all your comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m getting a unrealistic error with vertical param, I can’t debug yet, but I’m working on it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • @darshankabariya Isn't that because of the multiline string literal by """ - triple quote?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was a spacing issue. I’ve fixed it using string concatenation.

@darshankabariya darshankabariya marked this pull request as draft June 19, 2025 11:19
@darshankabariya darshankabariya marked this pull request as ready for review June 19, 2025 19:59
Makefile Outdated
Comment on lines +410 to +408
else ifeq ($(detected_OS),Windows)
echo -e $(BUILD_MSG) "build/$@.dll" && $(ENV_SCRIPT) nim libwakuDLL $(NIM_PARAMS) waku.nims
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather make separation by target platfom in one place of possible.
For me it sounds that shouldn't be different command in the makefile to build dyn lib in different platforms.
I would move it to nimble better.
But maybe it is just my taste :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I wasn’t sure it would work without OS checks since we need to echo .dll or .so. But your idea helped — we can drop libwakuDLL, libwakuDynamic can handle both libs.

waku.nimble Outdated
Comment on lines +76 to +78
elif `type` == "dll":
exec "nim c" & " --out:build/" & name &
".dll --nimcache:build/nimcache --threads:on --app:lib --opt:size --noMain --mm:refc --header -d:metrics --nimMainPrefix:libwaku -d:discv5_protocol_id=d5waku " &
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nimscript has support for properly add extension to target filename:
toDll and toExe
https://github.com/nim-lang/Nim/blob/f7145dd26efeeeb6eeae6fff649db244d81b212d/lib/system/nimscript.nim#L147

Using these can simplify nimble code imho.
But beware toDll will result lib+name+ext... so maybe we need to replicate it for our purpose.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @NagyZoltanPeter — I’ve addressed this suggestion.

@darshankabariya darshankabariya force-pushed the libwaku_dll branch 2 times, most recently from 916e2eb to 6c8630a Compare June 20, 2025 15:53
Comment on lines +73 to +81
var lib_name = toDll("libwaku")
when defined(windows):
exec "nim c" & " --out:build/" & lib_name &
".so --threads:on --app:lib --opt:size --noMain --mm:refc --header -d:metrics --nimMainPrefix:libwaku --skipParentCfg:off -d:discv5_protocol_id=d5waku " &
extra_params & " " & srcDir & name & ".nim"
else:
exec "nim c" & " --out:build/" & lib_name &
".so --threads:on --app:lib --opt:size --noMain --mm:refc --header -d:metrics --nimMainPrefix:libwaku --skipParentCfg:on -d:discv5_protocol_id=d5waku " &
extra_params & " " & srcDir & name & ".nim"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warn: Isn't toDll("libwaku") will return liblibwaku.so or liblibwaku.dll?
Well also if we still need to branch by platform due to --skipParentCfg... I'm questioning my original reasoning here. But it's hard to recognise at first sight. Btw, why is this distinction?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out the distinction with --skipParentCfg. On Windows, building the binary without external requirements is a bit tricky. Once we fully integrate windows support into the make command, we can revisit and properly address this. For now, I’ve removed --skipParentCfg specifically for the Windows build. cc (@NagyZoltanPeter)

Copy link
Copy Markdown
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!! Awesome!

Copy link
Copy Markdown
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks so much!

@darshankabariya darshankabariya merged commit 8a905a5 into master Jun 25, 2025
8 of 9 checks passed
@darshankabariya darshankabariya deleted the libwaku_dll branch June 25, 2025 19:33
Ivansete-status pushed a commit that referenced this pull request Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants