Skip to content
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

Add prefix feature #127

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

gowthamsk-arm
Copy link
Contributor

The prefix feature adds a psa_crypto_(version) prefix to the library names and all the symbols. By default it is disabled.

Signed-off-by: Gowtham Suresh Kumar [email protected]

The prefix feature adds a psa_crypto_(version) prefix to the
library names and all the symbols. By default it is disabled.

Signed-off-by: Gowtham Suresh Kumar <[email protected]>
@gowthamsk-arm gowthamsk-arm self-assigned this Oct 16, 2023
@gowthamsk-arm gowthamsk-arm changed the title Debug prefix test Add prefix feature Oct 16, 2023
@gowthamsk-arm
Copy link
Contributor Author

With the prefix feature enabled, there are some issues related to cross-compiling. This will be fixed in another PR. Having it as a feature and enabling only when needed would be better.

Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Copy link
Member

@tgonzalezorlandoarm tgonzalezorlandoarm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gowthamsk-arm
Copy link
Contributor Author

What is the general approach to add features:

  1. "no-sym-prefix" enable it by default and users need to explicitly disable
  2. "prefix" disabled by default and users need to explicitly enable prefixing when they want

I'm more inclined towards option 2 as having lots of features enabled by default might not be convenient. Any thoughts?

@@ -35,6 +35,16 @@
#![allow(clippy::multiple_crate_versions)]

fn main() -> std::io::Result<()> {
// If the prefix feature is not enabled then set the "CARGO_PKG_LINKS"
// parameter to mbedcrypto to avoid any duplicate symbols from any other
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be mbedtls instead of mbedcrypto so that we can detect an attempt to combine with mbedtls-sys-auto (https://github.com/fortanix/rust-mbedtls/blob/master/mbedtls-sys/Cargo.toml#L14)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried changing this would affect if there is another crate that links to libmbedcrypto. The user in this case can use the prefix feature to avoid any collisions instead of changing mbedcrypto?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact I've also suggested that mbedtls-sys-auto change its links line: fortanix/rust-mbedtls#289
If both crates changed, then we'd be back to where we started! The links line is a very crude mechanism for detecting collisions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have already raised an issue there, I think we can stick to mbedcrypto for now.

@tgonzalezorlandoarm
Copy link
Member

What is the general approach to add features:

  1. "no-sym-prefix" enable it by default and users need to explicitly disable
  2. "prefix" disabled by default and users need to explicitly enable prefixing when they want

I'm more inclined towards option 2 as having lots of features enabled by default might not be convenient. Any thoughts?

I agree with option 2, I would say that the criteria is not to add any features by "surprise", so if you disable the defaults, you have to explicitly enable each feature that you want enabled. This may result in a longer Cargo.toml line, but it avoid the surprise factor of bringing along a crate that you weren't expecting to bring

@ionut-arm
Copy link
Member

I agree with option 2 as well - as long as we've not had the renaming as a default in the previous release (?). Having more features to enable isn't a problem, especially if they can have drastic effects on how the crate works for dependents.

@gowthamsk-arm
Copy link
Contributor Author

Initially, there was no prefixing, but then v0.11.0 made prefixing as default (without any feature). Now we are making prefix non-default.

@gowthamsk-arm
Copy link
Contributor Author

Provided v0.12.0 release will be a quick release after v0.11.0 should we be concerned about users having issues with it? :)

@ionut-arm
Copy link
Member

ionut-arm commented Oct 16, 2023

Hmm, ok, I guess as long as it's documented somewhere, this should be ok.

EDIT: We can even yank v0.11.0 to prevent these jarring changes, perhaps some would have issues with the library changing underneath them.

@gowthamsk-arm
Copy link
Contributor Author

Makes sense. Will do that:)

@gowthamsk-arm gowthamsk-arm merged commit ea134c2 into parallaxsecond:main Oct 16, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants