Enable dynamic build and .cwasm generation for core libraries (gnulib, libtirpc, openssl, zlib)#185
Open
vidyalakshmir wants to merge 4 commits intomainfrom
Open
Enable dynamic build and .cwasm generation for core libraries (gnulib, libtirpc, openssl, zlib)#185vidyalakshmir wants to merge 4 commits intomainfrom
vidyalakshmir wants to merge 4 commits intomainfrom
Conversation
rennergade
reviewed
Apr 12, 2026
| echo "[zlib] done → $OVERLAY/usr/lib/wasm32-wasi/libz.a" | ||
|
|
||
| if [[ "$LIND_DYLINK" != "1" ]]; then | ||
| echo "[zlib] done ?~F~R $OVERLAY/usr/lib/wasm32-wasi/libz.a" |
Contributor
Author
There was a problem hiding this comment.
This seem to print properly though. Will recheck.
Contributor
There was a problem hiding this comment.
Possibly fine but might just want to avoid this stuff not sure about portability
rennergade
reviewed
Apr 12, 2026
Contributor
There was a problem hiding this comment.
When LIND_DYLINK=1, it configures with --enable-shared --disable-static but then links the static archive (libgnu.a) into a shared wasm. If configure is building a shared lib, why re-link from the .a? If it's building static to
then convert, the configure flags should stay --enable-static
rennergade
requested changes
Apr 12, 2026
Contributor
rennergade
left a comment
There was a problem hiding this comment.
minor comment and some confusion
This was referenced Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #104
Context
Previously, our build scripts handled the
configureandmakesteps for our core libraries producing static archives required for the static build of applications. However, we needed to convert the resulting static archives into fully optimized, dynamically linked WebAssembly shared objects to run the applications with dynamic library support.This PR introduces the automated steps to link, export, optimize, and precompile the static archives for
gnulib,libtirpc,openssl, andzlibinto dynamic.cwasmlibraries when dynamic linking is enabled.Proposed Changes
LIND_DYLINK="1". Otherwise, it exits cleanly after the standard static build.lind_debug.ointo shared WebAssembly files usingclangwith experimental PIC and shared memory flags.add-export-toolto explicitly export necessary symbols (__wasm_apply_tls_relocs,__wasm_apply_global_relocs, and__stack_pointer) for each library.wasm-opton the generated files to enable bulk memory, threads, epoch injection, and asyncify.lind_compileto compile the optimized WASM files into their final.cwasmformats..cwasmartifacts to the overlay library directory as standard.sofiles.Technical Details
-Wl,--import-memory,-Wl,--export-dynamic, and-Wl,--experimental-pic. Uses--whole-archiveto ensure all symbols from the static archives are included in the shared libraries.[[ ! -f ... ]]) and fail-safes (|| exit 1) after every major tool execution (clang,add-export-tool,wasm-opt,lind_compile) to ensure the build pipeline fails loudly if an intermediate artifact is missing for any of the libraries.To test
These libraries can be tested by running the dynamic build of apps. OpenSSL and zlib can be tested with
curlandgit. libtirpc can be tested withlmbench.Note: gnulib is always statically linked with coreutils and other apps and hence dynamic build of the library is not essential.