Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build.zig to qjs-wasi project #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

kubkon
Copy link

@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
Author

kubkon commented Jun 7, 2021

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

@Hywan
Copy link

Hywan commented Jun 7, 2021

Interesting, thanks for the ping!

@kubkon
Copy link
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
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