emk / rust-musl-builder

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.
Apache License 2.0
1.54k stars 193 forks source link

Support mongoc-sys #107

Closed aywengo closed 2 years ago

aywengo commented 3 years ago

What did you try to do?

I tried to include mongoc-sys to dependencies.

[dependencies]
...
openssl-sys = "0.9"
openssl = { version = "0.10", features = ["vendored"] }
...
mongoc-sys = "1.8.0"

What happened?

The build is failed with the following:

error: failed to run custom build command for `mongoc-sys v1.8.0`

Caused by:
  process didn't exit successfully: `/home/rust/src/target/release/build/mongoc-sys-f542d36e44c5f0ce/build-script-build` (exit code: 101)
  --- stdout
...
checking whether to use system crypto profile... no
  checking for SSL... yes
  checking openssl/bio.h usability... no
  checking openssl/bio.h presence... no
  checking for openssl/bio.h... no
  checking openssl/ssl.h usability... no
  checking openssl/ssl.h presence... no
  checking for openssl/ssl.h... no
  checking openssl/err.h usability... no
  checking openssl/err.h presence... no
  checking for openssl/err.h... no
  checking openssl/crypto.h usability... no
  checking openssl/crypto.h presence... no
  checking for openssl/crypto.h... no

  --- stderr
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
100   649  100   649    0     0   1787      0 --:--:-- --:--:-- --:--:--  1782
100 7170k  100 7170k    0     0  2575k      0  0:00:02  0:00:02 --:--:-- 4657k
  configure: error: You must install the OpenSSL development headers to enable OpenSSL support.
  thread 'main' panicked at 'assertion failed: command.status().expect("Could not run configure").success()', /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/mongoc-sys-1.8.0/build.rs:62:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

What did you hope to happen? Successful build.

emk commented 3 years ago

If you want to build your own C libraries, you're going to have to make sure that cross-compilation is configured correctly, including finding the correct copy of OpenSSL.

In general, updating rust-musl-builder to support cross-compiling a new C library is a fairly significant effort, and it generally requires a solid afternoon of work (and sometimes bug reports to the upstream C and Rust authors). As a general rule, I don't have enough time to do this for libraries that I don't use. I wish I could help you more here, but I'm unlikely to ever find the time to investigate mongoc-sys.

emk commented 3 years ago

If somebody else wants to figure out how to make this work, I will be happy to review a PR. But I am unlikely to work on it myself for the foreseeable future.