#wasm32-freestanding build issues

1 messages · Page 1 of 1 (latest)

azure sandal
#

Is std.ArrayList not supported on this target?

Here is my code:

const allocator = std.heap.wasm_allocator;
var structs = std.ArrayList(MyStruct).init(allocator);
try structs.append(.{
   .name = decl.name,
   .size = size,
   .fields = &struct_fields,
});
xxx@Theos-MacBook-Pro ~/i/webgpu-zig (main)> zig build-lib src/generate.zig -target wasm32-freestanding -freference-trace
/Users/xxx/tools/zig/lib/std/os.zig:149:24: error: struct 'os.system__struct_3279' has no member named 'fd_t'
pub const fd_t = system.fd_t;
                 ~~~~~~^~~~~
/Users/xxx/tools/zig/lib/std/os.zig:70:13: note: struct declared here
    else => struct {},

When I remove the std.ArrayList, it compiles OK, any idea?

Thanks 🙏

#

I'm not using any file descriptors so I'm very confused

#

Maybe the std is broken and try to use the OS stdout somehow?
(which is unavailable for wasm32-freestanding)

#

wasm_freestanding_start: /Users/xxx/tools/zig/lib/std/start.zig:203:31

looks like it comes from this part of code

#

Ok fixed the issue, in wasm32-freestanding, I can't use UnionError

#

my function needs to return void

#

I guess this is the right behaviour because it may be undefined to use errors in the C ABI, but this should be documented.

#

Happy to contribute but not sure where this should go

fair solar
#

its because when main returns an error union zig will print the error if one is returned, not anything to do with the C abi

#

i honestly find it a little weird that freestanding has a default entry point like that at all