Open ThibaultLemaire opened 4 years ago
I didn’t even know there was an OS called NixOS until today :)
Looking at the error it seems that the wasm32-unknown-emacripten triple isn’t recognized by the version of LLVM in use on your system.
Do you actually have that triple installed through rustup?
Yes rustup target list
shows
...
wasm32-unknown-emscripten (installed)
...
The Nix package manager has it's own way of handling package installation and dependencies. I'm using it to create development environments with only the required libraries for building each project.
I'm still trying to figure out the exact dependencies of your example. I know there's at least:
rustup
python
nodejs
unzip
But I'm still unsure if cargo-web
requires emscripten
installed on the system or if it rolls its own, in which case my installing emscriptenfastcomp
is shadowing cargo-web
's clang
and that might explain the target not found.
(I've also tried to add LLVM
and binaryen
to the environment without success)
Can you successfully compile the project without cargo-web
? As with cargo build --target=wasm32-unknown-emscripten
? If so, trying to at least get that working might be easier for me.
AFAIK cargo-web downloads a version of emscripten on its own, but you should be able to override that.
I can’t remember if this project does work with just cargo.
I’m on holiday at the moment and I do not have access to a computer. I’ll have a look at it when I get back home in the first week of January.
You can try to find a way of making cargo-web use your own emscripten and llcm and that would probably solve this issue
After further investigation, I've opened an issue on cargo-web : https://github.com/koute/cargo-web/issues/230
It looks like this issue is not tied to your work and this example project: I can't compile anything with cargo-web and the emscripten target.
Now that’s interestIng. Please keep me posted.
Okay so as mentioned on the linked issue, with the correct version of rust, I can compile against my system emscripten.
Here's what works for me:
❯ cargo --version
cargo 1.39.0 (1c6ec66d5 2019-09-30)
❯ cargo web start --use-system-emscripten
Finished dev [unoptimized + debuginfo] target(s) in 0.70s
If you need to serve any extra files put them in the 'static' directory
in the root of your crate; they will be served alongside your application.
You can also put a 'static' directory in your 'src' directory.
Your application is being served at '/main.js'. It will be automatically
rebuilt if you make any changes in your code.
You can access the web server at `http://[::1]:8000`.
Although now I'm having issues with the result (I'll open a new issue My Firefox doesn't support WebGL anymore since a recent update apparently).
edit: Tried it on an other machine, it's working fine.
On a side note, would you like me to contribute my shell.nix
file? Basically it just brings rustup
and emscripten
into scope and adds $HOME/.cargo/bin
to the path so that the cargo-web
bin is discoverable.
So after figuring out some dependencies, I managed to get the compilation up to this step.
I figured I was missing fastcomp (whatever that is), so I added the
emscriptenfastcomp
package to my environment. Except nowstb_image
fails to build withSo I'm not sure if that's progress or not, and I don't know where to go from there.