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

Error compilation on Alpine #271

Closed
sleipnir opened this issue Aug 10, 2021 · 6 comments
Closed

Error compilation on Alpine #271

sleipnir opened this issue Aug 10, 2021 · 6 comments

Comments

@sleipnir
Copy link

When I try to compile a docker image with Wasmex in Alpine I get the following error below:

error: cannot produce dylib for `wasmex v0.5.0 (/app/massa_proxy/deps/wasmex/native/wasmex)` as the target `x86_64-unknown-linux-musl` does not support these crate types

== Compilation error in file lib/wasmex/native.ex ==
** (RuntimeError) Rust NIF compile error (rustc exit code 101)
    (rustler 0.22.0) lib/rustler/compiler.ex:36: Rustler.Compiler.compile_crate/2
    lib/wasmex/native.ex:7: (module)
    (stdlib 3.15.2) erl_eval.erl:685: :erl_eval.do_apply/6
could not compile dependency :wasmex, "mix compile" failed. You can recompile this dependency with "mix deps.compile wasmex", update it with "mix deps.update wasmex" or clean it with "mix deps.clean wasmex"
The command '/bin/sh -c cd /app/massa_proxy/apps/massa_proxy     && mix deps.get     && mix release.init     && mix release' returned a non-zero code: 1
make: *** [Makefile:10: build] Error 1

I tried to install the correct target via rustup but the error persists.

RUN rustup toolchain install nightly && rustup update && rustup target add wasm32-unknown-unknown --toolchain nightly
@tessi
Copy link
Owner

tessi commented Aug 11, 2021

Hi @sleipnir 👋 Thanks for reporting this issue. I myself never compiled wasmex in alpine, but would like to give it a try. Do you have an example docker file handy to reproduce this error?

@sleipnir
Copy link
Author

Of course @tessi

https://github.com/eigr/massa/blob/master/Dockerfile

@tessi
Copy link
Owner

tessi commented Aug 11, 2021

I got some progress - it seems that Rust cannot yet work on alpine (musl host toolchain) because of some dynamic linking issues 👉 rust-lang/rust#59302

However, there seems to be a workaround by setting the following environment variable with some rust flags:

RUSTFLAGS="-C target-feature=-crt-static"

When adding this ENV to your Dockerfile:

ENV RUSTUP_HOME=/usr/local/rustup \
    CARGO_HOME=/usr/local/cargo \
    PATH=/usr/local/cargo/bin:$PATH \
    RUST_VERSION=1.54.0 \
    RUSTFLAGS="-C target-feature=-crt-static"

it can successfully build. I didn't try further and haven't run your app (or wasmex in there) as I don't know the specifics of your app or how to use it. But this seems to be a good start. Let me know if this worked out.

@sleipnir
Copy link
Author

Thank you very much for your help.
I managed to build with the flag you sent.
Thank you!

@tessi
Copy link
Owner

tessi commented Aug 11, 2021

Glad to hear. Feel free to open another if there are more roadblocks.

Also, just if you want, tell me how using wasmex worked out for massa. Hearing these kinds of stories (even if not successful) is super interesting for me and keeps me motivated :)

@sleipnir
Copy link
Author

sleipnir commented Aug 11, 2021

Massa is a Sidecar proxy that implements the Cloudstate protocol for Stateful Serveless Functions.
We don't have an official release yet, but we hope to have a release suitable for use soon.
Today we support this protocol on gRPC but we believe that supporting Wasm would be of fundamental importance to us

More in https://eigr.github.io/docs/intro/

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