sfackler / rust-openssl

OpenSSL bindings for Rust
1.38k stars 742 forks source link

rust-openssl: Cross compilation issues with prebuilt 'openssl' libs #2255

Open vithalsm opened 3 months ago

vithalsm commented 3 months ago

Hi, Here is my scenario: openssl-3.x - cross crompiled as 'conan' package and published to our internal conan registry. Application: . Wants to use 'rust-openssl' by setting 'dependency' to openssl and openssl-sys (as explained in the README).
. Install pre-built cross compiled openssl-libs via 'build-dependencies' and build.rs. Build script build.rs uses 'conan2-rs' to run 'conan commands' to pull the dependencies (openssl system libs in this case).

However, this method doesn't work, as 'dependencies' are executed prior to 'build-dependencies'.
Hence 'openssl-sys' fails as build script runs later.

So, in such cases, is there any other alternatives?
If there are ways to achieve the same as described above please help with the info.

===================================================== [dependencies] openssl-sys = "0.9" openssl = "0.10"

[build-dependencies] conan2 = {version = "0.1.1"} bindgen= {version = "0.69.4"}

build.rs ==> ... ... use conan2::ConanInstall; ConanInstall::new() .profile(&conan_profile) .build("missing") .run() .parse() .emit(); ... ...

sfackler commented 3 months ago

You would need to orchestrate conan outside of cargo.

vithalsm commented 3 months ago

Thanks @sfackler for the response. Could you please elaborate on "orchestrate conan outside of cargo"?

sfackler commented 3 months ago

If you want to use Conan, you will need to run conan install with the proper generators, etc, and then call cargo build with the environment set up appropriately to point to the conan-installed openssl.

vithalsm commented 3 months ago

Ok. Thought about same, but wasn't sure how easy/difficult it would be to export the paths dynamically.
Same for using sub-crates within a workspace, wherein, using the first crate to do conan job via its build script and second using the stuffs.