Hey folks! I would like to generate a Rust executable that will run graphviz. I currently generate HTML based on viz.js, which is basically a WASM-ified version of graphviz. I would rather just generate SVG directly by creating my "dot" file and then executing an embedded copy of graphviz. In particular, I don't want to require that the graphviz executable (or ideally even the sources) are found on the system running my rust program.
How do I do it!
cc @Alex Crichton or @fitzgen (he/him)
@nikomatsakis your goal being to basically build a Rust executable that uses wasmtime
to execute a compiled-in wasm blob that runs graphviz?
I guess so
I don't care in particular that it's wasmtime
but that is I guess the most likely candidate
do you have the wasm blob on hand and are familiar with it? or is it a black box of sorts?
I'm probably making life harder than I have to
(presumably there's a lot of fancy JS interopereating with the wasm blob as well)
well, right now I have nothing
Compile graphviz to wasm with wasi using wasi-sdk, then run it via wasmtime
I generate a dot file
I could use this Rust graphviz package, but it wants a graphviz executable, and I don't like that idea
fitzgen (he/him) said:
Compile graphviz to wasm with wasi using wasi-sdk, then run it via wasmtime
this sounds like what I had in mind
are there instructions for how to do that sort of thing?
this is partly an excuse for me to play with wasm, of course
Using the existing wasm blob is probably a no go; it’s probably JS specific, as Alex mentions
https://github.com/WebAssembly/wasi-sdk
can I apt-get that?
Read me has details; pretty much just setting CC and passing a couple flags
Probably not
yeah, ok, it doesn't look too hard
(deleted)
fitzgen (he/him) said:
Probably not
too bad :)
I personally don’t install it to /opt, just a local dir in my home so I can have multiple versions installed in parallel
this is like just on the limit of complexity I am willing to endure
I have to copy and paste shell commands and edit them, but there's only 2, and the edits are trivial :)
ok
This may require patching graphviz, btw. I don’t know if it uses signals but that’s a common thing to have to turn off
And multithreading
ok
I suppose I could use https://crates.io/crates/graphviz-sys
that's so much less cool :)
also I guess that would require the people running cargo build to have the libraries on their system
which is kind of what I want to avoid
/me nods
and me to write unsafe code
checking for gcc... /home/nmatsakis/versioned/skill-tree/graphviz/wasi-sdk-12.0/bin/clang --sysroot='/home/nmatsakis/versioned/skill-tree/graphviz/wasi-sdk-12.0/share/wasi-sysroot
checking whether the C compiler works... no
configure: error: in `/home/nmatsakis/versioned/skill-tree/graphviz/graphviz-2.47.1':
configure: error: C compiler cannot create executables
I suppose that should not be surprising :)
tbh honest none of this is likely to succeed
if you're lucky you can configure graphviz for cross compilation
yeah I think I decided to just give up
if you're lucky it'll actually compile with wasi-sdk
if you're lucky it'll actually produce a meaningful output
but anything can go wrong along the way and it's all "goop of porting a C project" which can get... tricky
yeah I have no real appetite for that :)
anyway I have a workable-ish system with viz.js
Last updated: Nov 22 2024 at 16:03 UTC