Comments (8)
We compile and test Ada core to WebAssembly - https://github.com/ada-url/ada/tree/main/tests/wasm. I think it is possible to compile Ada Rust package to WASM, but if you encountered a specific issue, we'll be happy to help.
from rust.
cc @Boshen cc @Brooooooklyn
from rust.
Quick first attempt:
Compile to wasm error output
rust main ❯ rustup target add wasm32-unknown-unknown
info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
info: installing component 'rust-std' for 'wasm32-unknown-unknown'
rust main ❯ cargo build --target wasm32-unknown-unknown
Downloaded proc-macro2 v1.0.58
Downloaded syn v2.0.16
Downloaded link_args v0.6.0
Downloaded 3 crates (291.3 KB) in 2.11s
Compiling proc-macro2 v1.0.58
Compiling libc v0.2.144
Compiling unicode-ident v1.0.8
Compiling quote v1.0.27
Compiling link_args v0.6.0
Compiling thiserror v1.0.40
Compiling jobserver v0.1.26
Compiling cc v1.0.79
Compiling syn v2.0.16
Compiling ada-url v1.0.3 (/Users/boshen/github/rust)
Compiling thiserror-impl v1.0.40
The following warnings were emitted during compilation:
warning: In file included from ./deps/ada.cpp:3:
warning: ./deps/ada.h:20:10: fatal error: 'string' file not found
warning: #include <string>
warning: ^~~~~~~~
warning: 1 error generated.
error: failed to run custom build command for `ada-url v1.0.3 (/Users/boshen/github/rust)`
Caused by:
process didn't exit successfully: `/Users/boshen/github/rust/target/debug/build/ada-url-bba85f8f0ceb130d/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-changed=deps/ada.cpp
cargo:rerun-if-changed=deps/ada.h
cargo:rerun-if-changed=deps/ada_c.h
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("0")
HOST = Some("aarch64-apple-darwin")
cargo:rerun-if-env-changed=CXXFLAGS_wasm32-unknown-unknown
CXXFLAGS_wasm32-unknown-unknown = None
cargo:rerun-if-env-changed=CXXFLAGS_wasm32_unknown_unknown
CXXFLAGS_wasm32_unknown_unknown = None
cargo:rerun-if-env-changed=TARGET_CXXFLAGS
TARGET_CXXFLAGS = None
cargo:rerun-if-env-changed=CXXFLAGS
CXXFLAGS = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
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" "-I" "./deps/ada.h" "-I" "./deps/ada_c.h" "-Wall" "-Wextra" "-std=c++17" "-o" "/Users/boshen/github/rust/target/wasm32-unknown-unknown/debug/build/ada-url-26ed0d01891e2d46/out/./deps/ada.o" "-c" "./deps/ada.cpp"
cargo:warning=In file included from ./deps/ada.cpp:3:
cargo:warning=./deps/ada.h:20:10: fatal error: 'string' file not found
cargo:warning=#include <string>
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" "-I" "./deps/ada.h" "-I" "./deps/ada_c.h" "-Wall" "-Wextra" "-std=c++17" "-o" "/Users/boshen/github/rust/target/wasm32-unknown-unknown/debug/build/ada-url-26ed0d01891e2d46/out/./deps/ada.o" "-c" "./deps/ada.cpp" with args "clang++" did not execute successfully (status code exit status: 1).
from rust.
@Boshen Make sure your build settings include a reference to the C++ standard library.
from rust.
@anonrig Can you try the commands on your machine, I'm not familiar with the settings.
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown
from rust.
I had asked about this on the unofficial rust discord channel before posting here. It seems that including header files at least gets it to compile.
https://discord.com/channels/273534239310479360/1123415399770374164
from rust.
From I know, the C++ can't be compiled into wasm32-unknown-unknown
target
from rust.
Sorry for the delayed response, I was on vacation.
I'll go ahead and close this. Thank you for all of your help!
from rust.
Related Issues (14)
- Removing a single FFI call improves performance by 12% HOT 1
- Add serde serialize & deserialize support
- Can't compile project with ada-url HOT 8
- Why do `set_` functions return `bool`? Documentation is needed
- Feature `libcpp` doesn't compile HOT 6
- Test script fails on macOS
- Add benchmark workflow
- No API to retrieve the schema type
- Add benchmarks for `ada_url::idna`
- fails to build on debian sid HOT 3
- Profile-Guided Optimization (PGO) benchmark result HOT 1
- Does Url::origin leak? HOT 5
- ada_free_owned_string parameter should be passed by value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.