Conversation
* introduce wasm32-freestanding-musl .h files to fix conflicts with stddef.h and errno.h * fix an issue with zig build system regarding installation of webassembly libraries * add implementations to zig's libc: - strcmp - strncmp - strerror - strlen See #514
|
|
||
| #ifndef __cplusplus | ||
| #if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t) | ||
| typedef int wchar_t; |
There was a problem hiding this comment.
I think musl expects us to pass -fno-signed-wchar to the compiler @richfelker could you confirm?
There was a problem hiding this comment.
Rich's profile says "I don't really use or prefer to use github." - I think we should respect that preference by asking questions in #musl IRC channel
| return std.mem.len(u8, s); | ||
| } | ||
|
|
||
| extern fn strncmp(_l: [*]const u8, _r: [*]const u8, _n: usize) c_int { |
There was a problem hiding this comment.
Could implement as:
return switch(std.mem.compare(u8, s1[0..n], s2[0..n])) {
.LessThan: -1,
.Equal: 0,
.GreaterThan: 1
}There was a problem hiding this comment.
that will be an out of bounds index if n is bigger than strlen(s1) or strlen(s2)
| } | ||
|
|
||
| test "strncmp" { | ||
| std.testing.expect(strncmp(c"a", c"b", 1) == -1); |
There was a problem hiding this comment.
use expectEqual for better errors :)
| "include/x86_64-linux-musl/bits/stat.h" | ||
| "include/x86_64-linux-musl/bits/syscall.h" | ||
| "include/x86_64-linux-musl/bits/user.h" | ||
| "include/wasm32-freestanding-musl/bits/alltypes.h" |
There was a problem hiding this comment.
Should we have created libc/musl/arch/wasm32/bits/alltypes.h.in instead?
There was a problem hiding this comment.
I'm not sure why we even have those .in files; it might be a mistake.
There was a problem hiding this comment.
Want to make an issue to follow that up?
|
Landed in 01a4897 |
|
This was apparently blocking Lua for WebAssembly. WASM is picking up mainstream use as a scripting platform for games, and Lua is likely the most popular scripting language used in gamedev. If anyone is interested in picking up the ‘using zig to build lua for webassembly’ thread, a lot of game developers would pay close attention. |
conflicts with stddef.h and errno.h
webassembly libraries
See #514