Skip to content

-lc on wasm32-wasi-musl without pub fn main and with -fno-entry causes linker failure about not including proper main symbol #22570

@MichaelBelousov

Description

@MichaelBelousov

Zig Version

0.14.0-dev.2851+b074fb7dd

Steps to Reproduce and Observed Behavior

This also occurs in 0.13.0 I just noticed.

  1. create file main.zig:
export fn func() u32 {
    return 5;
}
  1. build with command:
zig build-exe --export=func -fno-entry -lc -target wasm32-wasi-musl main.zig
  1. I received the following output:
b22ac386e1/libc.a(/home/mike/.cache/zig/o/bdbc5e1f927e7d98a8e9ea2611c26b68/__main_void.o): undefined symbol: main

Expected Behavior

for an error about not including a pub fn main to surface instead of a linker error.

And it should just compile with -fno-entry passed

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasm32-bit and 64-bit WebAssemblybugObserved behavior contradicts documented or intended behaviorlinkingos-wasiWebAssembly System Interface

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions