Skip to content

zig cc --target=wasm32-freestanding-musl cannot use musl #16652

@antocuni

Description

@antocuni

Zig Version

0.11.0-dev.4406+d370005d3

Steps to Reproduce and Observed Behavior

I tried to compile this simple C program with zig cc:

#include <stdlib.h>
int main(){
    void *buf = malloc(1024);
}

This is the output I get:

$ zig cc --target=wasm32-freestanding-musl -g main.c
main.c:3:10: fatal error: 'stdlib.h' file not found
#include <stdlib.h>
         ^~~~~~~~~~
1 error generated.

Expected Behavior

This is a good question, I admit I didn't know what to expect and I was mostly experimenting.
My gut feeling is that some of the libc functions are impossible to provide in a wasm32-freestanding environment, because they need imports, e.g. for I/O.

But other functions such as malloc, free, strcpy, etc., they should probably work?

I have the impression that wasm32-freestanding-musl is a valid target for zig but not for zig cc?

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasm32-bit and 64-bit WebAssemblyenhancementSolving this issue will likely involve adding new logic or components to the codebase.libcIssues related to libzigc and Zig's vendored libc code.use caseDescribes a real use case that is difficult or impossible, but does not propose a solution.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions