Repository navigation
wasi, libc: cache lib/c as libzigc.a and fix reactor exports (#130) - #136
Merged
Merged
Conversation
cataggar
enabled auto-merge (squash)
November 4, 2026 00:20
- Switch WASI -lc builds from zigc_strat = .zcu to .lib so lib/c is compiled and cached once as libzigc.a instead of compiling 2,157 @exports into every user ZCU. - Place libcxxabi.a, libcxx.a, and libzigc.a after user/ZCU objects in Lld.wasmLink (matching elfLink) while keeping crt1-*.o before user objects. - Declare __main_argc_argv as a weak @extern in lib/c/wasi_sources.zig mainVoidImpl and hide __progname* and optarg on WebAssembly targets so -rdynamic reactor builds do not fail or leak internal globals. - Fix self-hosted Wasm linker (src/link/Wasm*): guard SymbolFlags.isIncluded with !flags.undefined for -rdynamic, skip module_name mismatch checks on already-resolved symbols in Object.zig, preserve shared unresolved WASI imports in Flush.zig, and allow strong ZCU exports to override weak archive symbols. Closes #130 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
lib/caslibzigc.aon WASI (zigc_strat = .lib):src/Compilation.zig, usezigc_strat = .libwhentarget.isWasiLibC()instead of compiling all 2,157@exports inlib/cinto every user ZCU.src/link/Lld.zig(wasmLink), movelibcxxabi.a,libcxx.a, andlibzigc.aafter user/C/ZCU objects (and right beforecompiler_rt), matchingelfLink.lib/c/wasi_sources.zig, change__main_argc_argvinmainVoidImplfrom a strongextern fnto a weak@extern(matchingwasi-libc).lib/c/internal.zigandlib/c/misc.zig, set.visibility = if (builtin.object_format == .wasm) .hidden else .defaulton__progname,__progname_full,program_invocation_short_name,program_invocation_name, andoptargso they do not leak into-rdynamicWasm exports.src/link/Wasm*) archive & weak-symbol fixes:SymbolFlags.isIncluded(is_dynamic and !flags.visibility_hidden)with!flags.undefinedso-rdynamicdoes not mark unreferenced undefined archive imports alive duringprelink().module_name/namemismatches inObject.zigwhengop.value_ptr.resolution == .unresolved.nav_exports/uav_exportsbefore resolving ZCU imports againstobject_function_imports/object_data_importsinFlush.zig, keep shared unresolved imports inf.function_imports/f.data_imports, and give strong ZCU exports precedence over weak archive symbols.Closes #130