Build WASM using Zig Build System when ther is no entry point but function to export

I tried to use the Zig build system to compile my code to WebAssembly.
The line of code I used without the zig build system is:

zig build-exe main.zig -target wasm32-wasi -fno-entry ---export=my_awesome_function

This compiles with no problem.
But there is my build.zig file:

const std = @import("std");

const target: std.Target.Query = .{ .cpu_arch = .wasm32, .os_tag = .wasi };

pub fn build(b: *std.Build) void {
    const exe = b.addExecutable(.{
        .name = "my_awesome_webapp",
        .root_source_file = b.path("src/main.zig"),
        .target = b.resolveTargetQuery(target),
        .optimize = .ReleaseFast,


I have the issue that there is no entry point in my code ! It is the reason for why I used the -fno-entrey option. But there is an export function to declare.
And there is no option in the addExecutable function to said to the linker that there is no entry point or function to declare
I found this Zig Documentation but I don’t find how to modify it.
What I have missed ?

This topic might be related:

1 Like

Thank you !
I searched but I don’t find this answer.
As it is said in the post, adding:

exe.rdynamic = true;
exe.entry = .disabled;

solved my problem.

1 Like

Funny how you and @kredati asked the same question pretty much at the same time!