Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alpine dockerfile: "cannot produce proc-macro...does not support these crate types"

Total rust noob here. Trying to build a sccache binary for linux x64 with Redis: true. I'm starting with an alpine image:

FROM rust:alpine3.10

WORKDIR /root

RUN apk --no-cache add --update curl
RUN curl -L https://github.com/mozilla/sccache/archive/0.2.11.tar.gz \
        -o sccache.tar.gz
RUN tar xf sccache.tar.gz

RUN cd sccache-0.2.11 &&\
    cargo build --features=all --release 

I get:

error: cannot produce proc-macro for `derive-error v0.0.3` as the target `x86_64-unknown-linux-musl` does not support these crate types

Works fine if I FROM rust, which is based on buster. I could just go with this (and I will), but what is going on here? I'm so out of my element I am not even sure what questions to ask.

Related?: https://github.com/rust-lang/rust/issues/59302

like image 943
DeusXMachina Avatar asked Sep 17 '19 00:09

DeusXMachina


1 Answers

The proc_macro crate relies on a couple of features only available to dynamically-linked executables, and since musl is anything but that, you cannot use proc_macro on musl.

The issue related to this is here, and Alex describes quite well some of the issues and tradeoffs that'd need to be made to make this crate available on full static targets: https://github.com/rust-lang/rust/issues/40174

Just to confirm from the container:

~# docker run -ti rust:alpine3.10 /bin/sh
/ # rustup show
Default host: x86_64-unknown-linux-musl
rustup home:  /usr/local/rustup
like image 152
Sébastien Renauld Avatar answered Nov 08 '22 08:11

Sébastien Renauld