Closed nazar-pc closed 1 year ago
Those are not required when building a vendored copy.
Hm, very strange, because in my project as soon as I remove pkg-config
and libssl-dev
from container image openssl-sys
fails to compile.
Here is the Dockerfile, I tested it on x86-64: https://github.com/subspace/subspace/blob/f6d4f83cb67a32725f76b3799b8751635cb537b6/Dockerfile-node#L24-L25
Just changing those lines to not contain packages will cause build to fail.
OpenSSL is clearly vendored as can be seen in lock file: https://github.com/subspace/subspace/blob/f6d4f83cb67a32725f76b3799b8751635cb537b6/Cargo.lock#L6135
The lockfile encodes all possible dependencies, not just those that have been activated. The string "vendored" does not appear anywhere in that repo, so it's not clear to me how you are trying to enable it: https://github.com/search?q=repo%3Asubspace%2Fsubspace%20vendored&type=code.
GitHub search is only working on main
branch. The change was introduced in mentioned commit alongside the only dependency that pulls openssl
: https://github.com/subspace/subspace/commit/f6d4f83cb67a32725f76b3799b8751635cb537b6#diff-830551c68585b75b79d749f80858f28c9e5232eff45c393c5a509c7aab139ab5R28
If you need it for prost, it is most likely a build dependency, not a runtime dependency.
Not for prost, dependency tree here is fc-db > sqlx > sqlx-core > native-tls > openssl
, which is why I added vendored openssl dependency alongside fc-db
, such that cargo will unify features and make openssl compiled as vendored.
Interestingly, vendored
feature does have positive impact on cross-compilation, I no longer need to install aarch64-specific libssl-dev
and explain where it is, but native build does not compile.
What is the full output of the failing build
Output is as follows:
It did download openssl-src
, meaning vendor
flag did take effect, yet it somehow is still trying to build non-vendored version :man_shrugging:
So far I was not able to reproduce it with trivial example, still looking into it.
How confident are you that openssl is not a build dependency in addition to a runtime dependency?
Here is minimal Cargo.toml
:
[package]
name = "tmp"
version = "0.1.0"
edition = "2021"
[dependencies]
sqlx-macros = { features = ["_tls-native-tls"], version = "0.7.0-alpha.3" }
openssl = { version = "0.10.55", features = ["vendored"] }
And Dockerfile
to build it:
FROM ubuntu:20.04
WORKDIR /code
RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
curl \
clang \
make \
perl && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
COPY Cargo.toml /code/Cargo.toml
COPY src /code/src
RUN /root/.cargo/bin/cargo build
The issue seems to be from the fact that some of sqlx-macros
's dependencies require openssl
, but sqlx-macros
itself is a proc-macro, so apparently feature unification doesn't affect it :interrobang:
Features don't unify across build and runtime dependencies. If you want a vendored openssl in the build context you'll need to enable that too.
Well, that was super strange, but it worked indeed. I didn't expect proc-macro to have their own "group" for feature unification, but on the other hand I do see why it would be the case.
Thanks for your patience, moving/adding it to build-dependencies
helped.
I'm building library in Ubuntu 20.04 container and expected that neither pkg-config nor system library are required in case OpenSSL is vendored.
Apparently this is not the case and was quite unexpected. It would have been nice to remove those requirements.