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

Unable build to wasm32-unknown-unknown target on macos #93

Open
stickmy opened this issue Oct 10, 2022 · 10 comments
Open

Unable build to wasm32-unknown-unknown target on macos #93

stickmy opened this issue Oct 10, 2022 · 10 comments
Labels
wontfix This will not be worked on

Comments

@stickmy
Copy link

stickmy commented Oct 10, 2022

The following warnings were emitted during compilation:
warning: /workspace/quickjs-binding/target/wasm32-unknown-unknown/debug/build/rquickjs-sys-4f6d692d8e0606a0/out/libregexp.c:24:10: fatal error: 'stdlib.h' file not found
warning: #include <stdlib.h>
warning: ^~~~~~~~~~
warning: 1 error generated.
error: failed to run custom build command for rquickjs-sys v0.1.7
Caused by:
process didn't exit successfully: /workspace/quickjs-binding/target/debug/build/rquickjs-sys-0833c19788412099/build-script-build (exit status: 1)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=CARGO_FEATURE_EXPORTS
cargo:rerun-if-env-changed=CARGO_FEATURE_BINDGEN
cargo:rerun-if-env-changed=CARGO_FEATURE_UPDATE_BINDINGS
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_BYTECODE
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_GC
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_GC_FREE
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_FREE
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_LEAKS
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_MEM
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_OBJECTS
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_ATOMS
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_SHAPES
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_MODULE_RESOLVE
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_PROMISE
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_READ_OBJECT
Appliyng patch patches/check_stack_overflow.patch
patching file quickjs.c
Appliyng patch patches/infinity_handling.patch
patching file quickjs.c
Hunk #1 succeeded at 10235 (offset 44 lines).
Hunk #2 succeeded at 41732 (offset 168 lines).
Hunk #3 succeeded at 47839 (offset 168 lines).
Appliyng patch patches/atomic_new_class_id.patch
patching file quickjs.c
Hunk #1 succeeded at 3371 (offset 18 lines).
Appliyng patch patches/read_module_exports.patch
patching file quickjs.c
Hunk #1 succeeded at 27254 (offset 93 lines).
patching file quickjs.h
Hunk #1 succeeded at 1039 (offset 4 lines).
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-apple-darwin")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running: "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-D_GNU_SOURCE" "-DCONFIG_VERSION="2020-01-19"" "-DCONFIG_BIGNUM" "-DCONFIG_MODULE_EXPORTS" "-o" "/workspace/quickjs-binding/target/wasm32-unknown-unknown/debug/build/rquickjs-sys-4f6d692d8e0606a0/out/libregexp.o" "-c" "/workspace/quickjs-binding/target/wasm32-unknown-unknown/debug/build/rquickjs-sys-4f6d692d8e0606a0/out/libregexp.c"
cargo:warning=/workspace/quickjs-binding/target/wasm32-unknown-unknown/debug/build/rquickjs-sys-4f6d692d8e0606a0/out/libregexp.c:24:10: fatal error: 'stdlib.h' file not found
cargo:warning=#include <stdlib.h>
cargo:warning= ^~~~~~~~~~
cargo:warning=1 error generated.
exit status: 1
--- stderr
error occurred: Command "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-D_GNU_SOURCE" "-DCONFIG_VERSION="2020-01-19"" "-DCONFIG_BIGNUM" "-DCONFIG_MODULE_EXPORTS" "-o" "/workspace/quickjs-binding/target/wasm32-unknown-unknown/debug/build/rquickjs-sys-4f6d692d8e0606a0/out/libregexp.o" "-c" "/workspace/quickjs-binding/target/wasm32-unknown-unknown/debug/build/rquickjs-sys-4f6d692d8e0606a0/out/libregexp.c" with args "clang" did not execute successfully (status code exit status: 1).
warning: build failed, waiting for other jobs to finish...
Process finished with exit code 101

@stickmy stickmy closed this as completed Oct 10, 2022
@stickmy stickmy reopened this Oct 10, 2022
@coderedart
Copy link

There's a long discussion at mlua-rs/mlua#23 . basically, c bindings crates cannot be compiled to wasm. so, the best alternative is to wait for a pure rust impl of JS like Boa or starlight

@stickmy
Copy link
Author

stickmy commented Oct 28, 2022

There's a long discussion at khvzak/mlua#23 . basically, c bindings crates cannot be compiled to wasm. so, the best alternative is to wait for a pure rust impl of JS like Boa or starlight

Yes, also some discussions on Tracking issue for the unstable "wasm" ABI.

The Boa performance than quickjs still has a certain gap.

@coderedart
Copy link

are there any public benchmarks for Boa?

@stickmy
Copy link
Author

stickmy commented Oct 28, 2022

are there any public benchmarks for Boa?

unofficial benchmark boa-dev/boa#1924 (comment)

And the same benchmark for quickjs here https://bellard.org/quickjs/bench.html

@lastmjs
Copy link

lastmjs commented Sep 27, 2023

Sorry, are you saying that rquickjs doesn't work with Wasm at all? I'm using another QuickJS bindings crate and it works with Wasm, though is more immature. I was in the process of switching to rquickjs and just ran into this.

Please help me understand.

@coderedart
Copy link

coderedart commented Sep 27, 2023

@lastmjs

As quickjs is a C library, it won't support compiling to wasm32-unknown-unknown (wuu) target which is what wasm-bindgen (and its users like winit/reqwest etc..) uses.

But, you can probably compile this to wasm32-unknown-emscripten (wue) target, as rust will use emscripten compiler to compile C source to wasm. Most crates (eg: wgpu/glow/glfw/sdl2 etc..) would work fine on this target, but any crates which use wasm-bindgen like winit/reqwest etc.. won't work on emscripten.

Both wue and wuu are browser targets though.

idk what quickjs bindings you were using in the past though. if you were targeting wasm32-wasi with https://docs.rs/quickjs-wasm-rs/2.0.1/quickjs_wasm_rs/ , then that is a non-browser platform. rquickjs (or any crate tbh) should work fine on wasm32-wasi (or atleast should be easy enough to get working).

@lastmjs
Copy link

lastmjs commented Sep 28, 2023

We are in a non-browser wasm32-wasi environment, currently using https://crates.io/crates/quickjs-wasm-rs

Are you staying that rquickjs could be used in place of quickjs-wasm-rs now or in the future?

We have everything working, we just want to swap out bindings for rquickjs.

@coderedart
Copy link

It should be possible to use rquickjs on wasm32-wasi. But it would probably be hard to get it setup for the first time.

you will need to see how quickjs-wasm-rs people build quickjs https://github.com/bytecodealliance/javy/blob/main/crates/quickjs-wasm-sys/build.rs and try to do the same for rquickjs.

@mmoskal
Copy link
Contributor

mmoskal commented Jan 10, 2024

I added WASI support here #245

@DelSkayn
Copy link
Owner

DelSkayn commented Feb 9, 2024

WASI support is now merged, but we won't support wasm-unknown-unknown for the foreseeable future as there is no way to link a libc required for QuickJS.

I'll leave this issue open for if this ever changes but mark it as won't fix for now.

@DelSkayn DelSkayn added the wontfix This will not be worked on label Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants