Hello,
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,
});
b.installArtifact(exe);
}
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 ?
1 Like
Sze
May 18, 2024, 5:23pm
2
This topic might be related:
Hey there
I’m currently working on a project with dynamic loading of WASM code and native bindings. I used to use WAMR but due to its lack of support for iOS, I decided to give wasm3 a go.
Unfortunately, it’s not really working as expected. My current workflow to build a loadable wasm module is to declare a shared library with Build.addSharedLibrary(...) and I have a very simple zig file with various export and extern functions declared.
The issue now is that the resulting wasm module,…
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
Sze
May 18, 2024, 5:53pm
4
Funny how you and @kredati asked the same question pretty much at the same time!
Hi all! Long time listener, first time caller. Thanks in advance—and still kind of a n00b, so be gentle.
I’ve been fighting with the Zig build system for the past few days and I’ve made some progress, but have hit a wall and am finally asking for help. I fear I’m missing something obvious.
I’m trying to build a wasm module that includes dependencies.
So I try the incantation:
zig build-exe src/web.zig -target wasm32-freestanding -fno-entry -rdynamic
I get error: no module named 'jzignet' av…
3 Likes