Closed zonyitoo closed 3 years ago
Even with:
[dependencies.openssl]
version = "*"
features = ["vendored"]
This still fails
Thank you for the bug report! This looks like the same error as https://github.com/sfackler/rust-openssl/issues/1198.
I think this might be a problem in libsodium-ffi
. It looks like the error occurs when building build.rs
(see the line with build_script_build-dc5e125d276a0928.build_script_build.bnih0bei-cgu.0.rcgu.o
, etc.).
This might be a host vs. target problem. The "host" is the Ubuntu image that provides the Rust toolchain, and the "target" is the musl-libc
environment.
build.rs
is compiled in the host environment, and it looks like it's trying to link against OpenSSL in the host environment, at compile-time. This is super tricky when cross-compiling, and it usually requires careful setting and reading of environment variables. If everything isn't set up carefully, then you might wind up trying to link against the target OpenSSL instead of the host OpenSSL, and everything with fail noisily.
Unfortunately, these issues can be frustrating to fix.
I'm experiencing the same issue trying to compile a project that depends on diesel. Is there a quick fix for this?
Unfortunately, no, there are no easy fixes for adding new C libraries. Somebody will have to take a look at libsodium-ffi
and figure out what needs to be tweaked, and submit PRs. I can leave this issue open for now, but I won't have time to work on this myself. My apologies. :-(
Seeing what seems to be the same problem when using openssl in a build script.
fn main() {
native_tls::Identity::from_pkcs12(b"", "").unwrap();
}
In a build script fails, but the same code in a crate works just fine.
@Marwes If you have a problem with openssl
, please file a separate issue. This bug is for libsodium-ffi
, which we do not currently support, and which I have no plans to work on myself (unless I need it someday).
My understanding is this:
build.rs
script is not built as a static binary, but it will still use musl and a static version of OpenSSL. Which will fail.Since we have no way to configure how build.rs
is built (build and link flags for example), we're stuck. And build.rs
must have its dependencies limited as much as possible to avoid native C/C++ libs such as openssl.
Am I getting this right?
@promethe42 I'm not actually sure what the underlying problem is, but that seems like a reasonable hypothesis.
In general, rust-musl-builder aims to support a small number of essential C libraries. To do this, it needs to configure everything for cross-compilation and static linking. This can be a complicated and frustrating process, because:
I choose to take on this work for PostgreSQL and OpenSSL and their supporting libraries, because they're extremely common dependencies (and because I need them personally). For less common C libraries, and libraries that I don't use myself, I simply don't have enough time to investigate and write the necessary PRs against other people's code.
Please note that I have recently updated rust-musl-builder
to support sqlx
. In order to do this, I had to set things up so that we can build openssl
as both a shared host library and static target library in the same build. This may improve the situation with libsodium-ffi
.
See https://github.com/sfackler/rust-openssl/issues/1337 for more details.
I have migrated my build script to build with other docker mirrors. So I am not quite sure about whether this issue have been fixed. It is ok to be closed, btw.
What did you try to do?
Build my project (
libsodium-ffi
) that depends onopenssl v0.10.26
.What happened?
Does
./test-image
work?Don't know,
./test-image
blocks onUpdating crates.io index
(Network issue).