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

Lile .wasm static lib #63

Open
aviplayer opened this issue Aug 7, 2024 · 6 comments
Open

Lile .wasm static lib #63

aviplayer opened this issue Aug 7, 2024 · 6 comments

Comments

@aviplayer
Copy link

I noticed, it is possible to compile to wasm
Compiling mgclient for wasm requires the Emscripten sdk. This is automated in the following steps:

mkdir build && cd build
cmake .. -DWASM=ON
make

Is it possible to do same but create a static lib. By the same I mean without OpenSsl. Per my understanding wasm target means absence OpenSsl

@gitbuda
Copy link
Member

gitbuda commented Aug 11, 2024

I'm not sure. Tried to built mgconsole by statically linking everything under memgraph/mgconsole#56, but failed because statically linking OpenSSL and its deps was hard (I quit at a certain point because of time, not sure if it's even possible)...

Could you explain what's your end goal? Because mgclient depends on OpenSSL to offer encrypted communication, "trivial" solution (in quotes because that's some amount of work) would be to totally get rid of OpenSSL dependency at compile time. At that point, OpenSSL wouldn't be a concern at all.

Long questions short:

  • Do you need encrypted communication at all?
  • If you do, what alternatives do you have in mind?

@aviplayer
Copy link
Author

aviplayer commented Aug 11, 2024

Hi @gitbuda, I want to call it from CloudFlare worker. We are using Rust for this. I checked rsmgclient, which also are bindings for C lib. And this rust client doesn't support wasm target.
I tried to use wasm compiled version, but Cloud Flare blocks thirdparty .wasm.
Then for me is only way to have statically compiled C library and create Rust Bindings by my own.
I see there are projects, calling .wasm from js: https://github.com/memgraph/jsmgclient
Also it is possible to compile directly into .wasm
I tried to build static lib from *.c.o files and from wasm, which have been produced by wasm compilation, but also fails.
Decided to ask for any way to do it.

@gitbuda
Copy link
Member

gitbuda commented Aug 16, 2024

Is server-client encryption needed (I guess yes)?

But in any case, this is helpful, I can also try to make the client code work from the CloudFlare worker in Rust 🦀 🔨 I'll give it a try in the following days 💪

In the meantime, maybe one of the native Neo4j drivers works in the CloudFlare context (Memgraph is almost 100% compatible because of the compatibility with the underlying Bolt protocol, if you make one of these drivers work under CloudFlare, it's 99.99% you will be able to connect to Memgraph 🤔 👀

@gitbuda
Copy link
Member

gitbuda commented Aug 16, 2024

I'm randomly doing some other work on pymgclient (the python client) and HERE we are actually statically linking openssl 👀 -> that should also be possible here 🤔

@gitbuda
Copy link
Member

gitbuda commented Aug 17, 2024

PR to follow memgraph/rsmgclient#56 (nothing yet works)

@gitbuda
Copy link
Member

gitbuda commented Aug 17, 2024

@aviplayer quick update and more questions.

I haven't managed to make much progress under memgraph/rsmgclient#56 because a basic CloudFlare project/template for some reason doesn't work... I'll try to investigate (but not an expert with CF workers + wasm -> it might take time...)

On the other hand, I've managed to statically link OpenSSL under memgraph/rsmgclient#57 (it's just an example, I plan to add a proper compile-time option). So, this might be close to enable "Then for me is only way to have statically compiled C library and create Rust Bindings by my own."?

  • dynamic Screenshot 2024-08-17 at 9 29 03 PM
  • static Screenshot 2024-08-17 at 9 31 27 PM

I suggest we jump on max 30mins call to deep dive into options? If that makes sense, please pick a time under https://calendar.app.google/EPGybdXCiF8Uc86K8. I'm also open for an "on-line" hackathon to make this work 👀💪

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

No branches or pull requests

2 participants