-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cc,wasi: ship WASI libc and autobuild it when needed #8837
Merged
Merged
Conversation
This file contains 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
kubkon
added
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
standard library
This issue involves writing Zig code for the standard library.
arch-wasm
32-bit and 64-bit WebAssembly
os-wasi
zig cc
Zig as a drop-in C compiler feature
labels
May 19, 2021
Closed
Looks like some headers are missing:
|
Weird. What's |
@jedisct1 I can't repro your issue on some dummy examples including the official Wasmtime's capability example. I was wondering though, might it be that clearing Zig's global cache |
Rename include dir to match the convention: from `wasm32-wasi` to `wasm-wasi-musl` Add building stubs which will be used to build and cache WASI libc sysroot.
This matches the behaviour of other languages and leaves us the ability to create actual static Wasm archives with ``` zig build-lib -static some.zig ``` which can then be combined with other Wasm object files and linked into either a Wasm lib or executable using `wasm-ld`. Update langref to reflect the fact we now ship WASI libc.
❤️ wasm related improvements. thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
arch-wasm
32-bit and 64-bit WebAssembly
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
os-wasi
standard library
This issue involves writing Zig code for the standard library.
zig cc
Zig as a drop-in C compiler feature
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 #8489
Tl;dr
Zig now ships with
wasi-libc
and hence we can now easily cross-compile C to WASI with Zig! No more need to do this yourself by compilingwasi-libc
and/orwasi-sdk
. Just download Zig, and you're sorted:More detailed description of changes to Zig
cc @andrewrk @fengb @jedisct1 @Luukdegram @ifreund as I'd love to learn your opinion about these changes!
wasi-libc
is a weird being since it bundles up modified versions of a few libraries including cloudlibc, musl, dmalloc, etc. Because of the fact the libs are non-stock, I've not tried to find similarities with standard musl we already bundle with Zig. However, I have significantly slimmed down thewasi-libc
sources we bundle with Zig compared to the ones hosted by the WebAssembly CG. Some numbers:Taken disk space:
lib/libc/wasi
sources: 12Mlib/libc/include/wasm-wasi-musl
headers: 992KI've added a few changes to how we name Wasm artifacts to match the convention used in
wasi-libc
, and so, static archives are now named exactly as on any POSIX-compliant OSlibName.a
,object files are left as they were sowhile the rest is left intact, so objectsname.o.wasm
, and finally, dynamic libraries are namedlibName.wasm
but I'm happy to revert this last change to what it wasname.wasm
.name.o.wasm
, Wasm library modulesname.wasm
, and executablesname.wasm
.I had to add some additional logic to
link/Wasm.zig
to actually link in the compiledcrt
s andwasi-libc
but I based it largely on the logic used inlink/Elf.zig
. One thing that is still missing is ability to create reactors and commands: we actually compile the necessarycrt
s but I've not yet worked out what commands the user should specify to generate a reactor say instead of a standard binary.EDIT - 20/05/2021:
Compilation.zig
by virtue of the fact that we now allow for creation of static Wasm archives. However, to make the changes backwards compatible, plus it simply makes more sense, I've ensured that when the user builds a Wasm library, they create an actually Wasm module hence the build process involves invokingwasm-ld
rather thanar
. This can of course be overwritten by specifying an appropriate flag when building the lib such as: