-
Notifications
You must be signed in to change notification settings - Fork 59
Allow OpenSSL vendoring to be disabled #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks fine to me, but how would you build without vendored OpenSSL? Is it as simple as:
cargo build --no-default-features --features openssl
And if you for example wanted to build SNP and vendored openssl:
cargo build --no-default-features --features snp,openssl?vendored
Is that correct?
|
First of all, this is the relevant cargo syntax. However, the second example would not look like
but Finally, in the event of including sev as a dependency of another crate, simply disabling openssl vendoring would look like [dependencies]
sev = { version = "6.2.1", default-features = false, features = ["openssl"] }However, enabling only snp and vendored openssl would look like [dependencies]
sev = { version = "6.2.1", default-features = false, features = ["snp", "openssl"] }
openssl = { version = "*", features = ["vendored"] }This example relies upon Rust's feature unification, to add the vendored feature back into openssl in a transitive manner. |
Perhaps I'm misunderstanding, but the text states: You can add a ? as in "package-name?/feature-name" which will only enable the given feature if something else enables the optional dependency. Otherwise it takes a union of the features of each crate. Since we didn't explicitly specify the [dependencies]
sev = { version = "6.2.1", default-features = false, features = ["snp", "openssl?/vendored"] }
openssl = { version = "*", features = ["vendored"] }Right? You specify |
That is correct, but my understanding is that the syntax is only applicable within the "[features]" section of the Cargo.toml, as it pertains to (conditionally) activate a feature of a direct dependency Thus you would not be able to use it within the dependencies section [dependencies]
sev = { version = "6.2.1", default-features = false, features = ["snp", "openssl?/vendored"] }
openssl = { version = "*", features = ["vendored"] }as the crate "sev" does not declare a "openssl?/vendored" feature, and you would not be activating the "openssl" feature of the "sev" crate either. The field "features" of a dependency may only reference features declared within the "[features]" section of the dependency itself. In our case, we may only use And to be able to enable the "vendored" feature of the "openssl" dependency of the "sev" dependency, we must rely upon the feature unification, by ourselves declaring an openssl dependency with the vendored feature, thus Hopefully this makes sense |
The feature unification doc specifies: When a dependency is used by multiple packages, Cargo will use the union of all features enabled on that dependency when building it. So to the previous example: [dependencies]
sev = { version = "6.2.1", default-features = false, features = ["snp", "openssl"] }
openssl = { version = "*", features = ["vendored"] }Since the This is how I am understanding it. |
Am I misunderstanding something ? Lines 38 to 40 in 8914fd3
|
|
Anyway, to put those discussions to rest regarding the proper syntax on the dependency declaration, here are the cargo outputs using the |
that is correct, the features of the openssl crate in use would be the union of the two, thus include the vendored as well |
Right, that's not what we want. If we specify Edit: I think I've misunderstood. You're saying that as long as |
|
@DGonzalezVillal PTAL. |
huh ? The "vendored" feature of the openssl crate includes the openssl source code and builds it locally to link to the rust code; not using the "vendored" feature of openssl is what leads to using the dynamic shared object openssl library. Was the intent behind this commit 7a80d99 to not build the openssl dependency for SEV and use the shared object instead ? If so, it had the opposite effect, as can be seen in the git blame of the cargo.lock file, which includes the openssl-src crate starting from that commit : https://github.com/virtee/sev/blame/7a80d9982495ae941b36430fecaa7b7ad680e55f/Cargo.lock#L1077-L1085 |
the other way around, as long as "vendored" is specified, OpenSSL will be built for the crate, which I understood was the original intent behind vendoring OpenSSL in the first place with 7a80d99 |
|
That's where my confusion was, thanks for clearing it up. LGTM. |
The merge-base changed after approval.
420626f to
7d61658
Compare
Enable OpenSSL vendoring to be disabled, while enabling it by default Signed-off-by: Filipe Fortunato <f.filipe.30.03@gmail.com>
5341b61 to
25132d1
Compare
|
I've rebased the PR, could it be reviewed ? |
DGonzalezVillal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to read about it, but it looks good to me.
I like that we are keeping the vendored build as the default feature
|
@tylerfanelli we need your approval again to merge |
We're working with SEV on a platform that is not supported by vendored Openssl (Yocto with OpenEmbedded, not supported by the crate openssl-src, and we spent a couple hours trying to hack together a workaround for vendored OpenSSL to no avail). We've been able to make do with version 6.0.0 for a while, but we're in need to update to 6.2.1 due to e96d605.
This change preserves the intent of OpenSSL being vendored by default if enabled, but leaves the possibility for dependents to disable OpenSSL vendoring.