Skip to content

Add build.zig to qjs-wasi project#8

Open
kubkon wants to merge 4 commits intosaghul:masterfrom
kubkon:zig
Open

Add build.zig to qjs-wasi project#8
kubkon wants to merge 4 commits intosaghul:masterfrom
kubkon:zig

Conversation

@kubkon
Copy link
Copy Markdown

@kubkon kubkon commented Jun 7, 2021

This change integrates the project with Zig as a replacement build system to CMake. With this change, you can use Zig to easily cross-compile qjs to WASI:

zig build

Note that you need latest nightly Zig so that you have access to emulated WASI libc subcomponents such as process clocks and signals.


Depends on ziglang/zig#8992

Plus I need work out why I'm getting a miscompilation (potentially, mislinking) in Debug/ReleaseSafe and not in ReleaseFast (failed assert converted into UB most likely). See comment below.

This change integrates the project with Zig as a replacement build
system to CMake. With this change, you can use Zig to easily
cross-compile qjs to WASI:

```
zig build -Dtarget=wasm32-wasi -Drelease-fast
```

Note that you need latest nightly Zig so that you have access to
emulated WASI libc subcomponents such as process clocks and signals.
@kubkon
Copy link
Copy Markdown
Author

kubkon commented Jun 7, 2021

FYI @Hywan and @syrusakbary; thought this might be of interest ;-)

@Hywan
Copy link
Copy Markdown

Hywan commented Jun 7, 2021

Interesting, thanks for the ping!

@kubkon
Copy link
Copy Markdown
Author

kubkon commented Jun 8, 2021

OK, so the runtime SIGILLs when targeting native (in my case, x86_64-linux-gnu) and traps in WASI runtime, in build modes with safety checks on in Zig are the result of clang's UBSAN which is on by default for non-ReleaseFast modes in Zig. I have now added a flag that turns it off by default (-fno-sanitize=undefined), however, these are actual dangerous bugs and should be fixed ;-)

More on the UBSAN errors manifesting when switching to Zig as C compiler in Zig's FAQ.

@kubkon kubkon marked this pull request as ready for review June 8, 2021 05:40
@kubkon
Copy link
Copy Markdown
Author

kubkon commented Jun 16, 2021

Ping @saghul :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants