Code Monkey home page Code Monkey logo

Comments (8)

anonrig avatar anonrig commented on August 26, 2024

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.

anonrig avatar anonrig commented on August 26, 2024

cc @Boshen cc @Brooooooklyn

from rust.

Boshen avatar Boshen commented on August 26, 2024

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.

lemire avatar lemire commented on August 26, 2024

@Boshen Make sure your build settings include a reference to the C++ standard library.

rust-lang/rust-bindgen#1834

from rust.

Boshen avatar Boshen commented on August 26, 2024

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

chanced avatar chanced commented on August 26, 2024

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.

Brooooooklyn avatar Brooooooklyn commented on August 26, 2024

From I know, the C++ can't be compiled into wasm32-unknown-unknown target

from rust.

chanced avatar chanced commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.