rust-cross / rust-musl-cross

Docker images for compiling static Rust binaries using musl-cross
MIT License
620 stars 68 forks source link

Compilation failed: thread 'rustc' panicked at 'Failed to get crate data for crate179' #37

Closed xJonathanLEI closed 3 years ago

xJonathanLEI commented 3 years ago

Platform

Linux 65fe86937035 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux`

Description

I'm trying to cross-compile a Rust application that depends on ethers-rs with the help of rust-musl-cross. However, compilation fails and after some debugging, I found ethers-rs to be the one causing the error.

I'm not opening this issue on ethers-rs as that library can be compiled outside rust-musl-cross without issues.

Steps to Reproduce

Create a Dockerfile anywhere with the following content:

FROM messense/rust-musl-cross:x86_64-musl

RUN git clone https://github.com/gakonst/ethers-rs && \
    cd ethers-rs && \
    cargo build

Run:

$ docker build .

Expected Result

Compilation succeeds.

Actual Result

Compilation fails with:

   Compiling ethers-contract-abigen v0.2.2 (/home/rust/src/ethers-rs/ethers-contract/ethers-contract-abigen)
   Compiling ethers-providers v0.2.2 (/home/rust/src/ethers-rs/ethers-providers)
   Compiling ethers-contract-derive v0.2.2 (/home/rust/src/ethers-rs/ethers-contract/ethers-contract-derive)
   Compiling ethers-contract v0.2.2 (/home/rust/src/ethers-rs/ethers-contract)
thread 'rustc' panicked at 'Failed to get crate data for crate179', compiler/rustc_metadata/src/creader.rs:136:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.52.1 (9bc8c42bb 2021-05-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C linker=x86_64-unknown-linux-musl-gcc -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `ethers-contract`

To learn more, run the command again with --verbose.
messense commented 3 years ago

Might be an upstream rustc issue, see https://github.com/rust-lang/rust/issues/56935 and https://github.com/rust-lang/rust/issues/85386

xJonathanLEI commented 3 years ago

Thank for the quick reply! Taking a look at the referenced issues now.

xJonathanLEI commented 3 years ago

Strangely enough, adding the following to my Cargo.toml solves the issue.

openssl = { version = "0.10.34", features = ["vendored"] }

Turns out it's related to OpenSSL.