Skip to content

Make boringssl-src optional #537

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

Merged
merged 2 commits into from
Jun 30, 2021
Merged

Conversation

hug-dev
Copy link
Contributor

@hug-dev hug-dev commented Jun 22, 2021

If the secure feature is disabled, it's not needed to compile the boringssl-src crate.

This assume that the secure feature is using boringssl-src by default which I think is the current behaviour.

A bad aspect of this is that boringssl-src will be compiled even if openssl is chosen but I think that is currently the case anyway?

Fix #536

@BusyJay
Copy link
Member

BusyJay commented Jun 22, 2021

A bad aspect of this is that boringssl-src will be compiled even if openssl is chosen but I think that is currently the case anyway?

No, it will be downloaded but won't be compiled. The optimal way is depend on boringssl-src if openssl feature is not enabled. But there seems to be no way to do so in Cargo.

@hug-dev
Copy link
Contributor Author

hug-dev commented Jun 22, 2021

Seems like on Mac OpenSSL is needed for grpc compilation even if secure feature is not on? Do you have any idea of what went wrong 😬?

@BusyJay
Copy link
Member

BusyJay commented Jun 23, 2021

Seems like on Mac OpenSSL is needed for grpc compilation even if secure feature is not on? Do you have any idea of what went wrong 😬?

gRPC_SSL_PROVIDER should be set to package only when secure feature is configured.

@hug-dev hug-dev force-pushed the boringssl-optional branch 5 times, most recently from fb1c858 to 6bb19f2 Compare June 23, 2021 14:13
@hug-dev
Copy link
Contributor Author

hug-dev commented Jun 23, 2021

Thanks for the help! After many force pushes, all tests are passing 🌟

@@ -43,7 +43,8 @@ jobs:
- run: cargo build --no-default-features --features prost-codec
- run: cd proto && cargo build --no-default-features --features prost-codec
- run: cargo build
- run: cargo test --all
# Some of the bindgen tests generate warnings, see https://github.com/rust-lang/rust-bindgen/issues/1651
- run: RUSTFLAGS="" cargo test --all
Copy link
Member

Choose a reason for hiding this comment

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

How about adding -A deref_nullptr to RUSTFLAGS? So that other warnings can still be checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes good point, will do that 👌

src/channel.rs Outdated
@@ -404,7 +405,7 @@ impl ChannelBuilder {
// On most modern compiler and architect, c_int is the same as i32,
// panic directly to simplify signature.
assert!(
val <= i32::from(libc::INT_MAX) && val >= i32::from(libc::INT_MIN),
val <= libc::INT_MAX && val >= libc::INT_MIN,
Copy link
Member

Choose a reason for hiding this comment

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

I think it's intended to convert as explained at L405.

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 see. On some platforms they might be different and that will error out. Will just allow the clippy lint there then.

Copy link
Member

@BusyJay BusyJay left a comment

Choose a reason for hiding this comment

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

You may also need to change .travis.yml

@hug-dev hug-dev force-pushed the boringssl-optional branch 2 times, most recently from 7badcde to db78845 Compare June 24, 2021 12:05
If the secure feature is disabled, it's not needed to compile the
boringssl-src crate.

Signed-off-by: Hugues de Valon <[email protected]>
@hug-dev hug-dev force-pushed the boringssl-optional branch from db78845 to 4c4420a Compare June 24, 2021 12:45
Copy link
Member

@BusyJay BusyJay left a comment

Choose a reason for hiding this comment

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

Rest LGTM

@@ -100,6 +101,7 @@ jobs:
runs-on: windows-latest
env:
LIBCLANG_PATH: 'C:\Program Files\LLVM\bin'
RUSTFLAGS: ""
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was about to comment about that :D With nothing there, there was an error that -A deref-nullptr was not recognised by rustc, with only --deny=warnings the errors were still showing. Not sure why

Copy link
Member

Choose a reason for hiding this comment

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

I guess maybe l102 overwrites L11.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I thought that as well, that putting an empty string here would empty the RUSTFLAGS defined before. It still failed but that seems to be for another reason?

BusyJay
BusyJay previously approved these changes Jun 25, 2021
@BusyJay
Copy link
Member

BusyJay commented Jun 25, 2021

@hunterlxt PTAL

Comment on lines +176 to +178
if cfg!(feature = "secure") {
config.define("gRPC_SSL_PROVIDER", "package");
}
Copy link
Member

Choose a reason for hiding this comment

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

why not just define the cmake config regardless of the secure feature

Copy link
Member

Choose a reason for hiding this comment

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

@hug-dev can you add a comment here?

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 did that to fix a failing test on Mac OS, after your recommendation.
Would the following comment be ok?

// OpenSSL is needed for gRPC compilation when the secure feature is on.

Copy link
Member

Choose a reason for hiding this comment

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

How about

// `package` should only be set for secure feature, otherwise cmake will always search for ssl library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

hunterlxt
hunterlxt previously approved these changes Jun 30, 2021
@hug-dev hug-dev dismissed stale reviews from hunterlxt and BusyJay via da3486c June 30, 2021 09:16
Copy link
Member

@BusyJay BusyJay left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@hunterlxt hunterlxt left a comment

Choose a reason for hiding this comment

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

LGTM

@BusyJay BusyJay merged commit 3f47c3c into tikv:master Jun 30, 2021
christian-oudard added a commit to mobilecoinofficial/grpc-rs that referenced this pull request Sep 24, 2021
If the secure feature is disabled, it's not needed to compile the
boringssl-src crate.

Fix tikv#536

Signed-off-by: Hugues de Valon <[email protected]>
Signed-off-by: Christian Oudard <[email protected]>
christian-oudard pushed a commit to mobilecoinofficial/grpc-rs that referenced this pull request Oct 19, 2021
If the secure feature is disabled, it's not needed to compile the
boringssl-src crate.

Fix tikv#536

Signed-off-by: Hugues de Valon <[email protected]>
christian-oudard added a commit to mobilecoinofficial/grpc-rs that referenced this pull request Oct 19, 2021
If the secure feature is disabled, it's not needed to compile the
boringssl-src crate.

Fix tikv#536

Signed-off-by: Hugues de Valon <[email protected]>
Signed-off-by: Christian Oudard <[email protected]>
christian-oudard pushed a commit to mobilecoinofficial/grpc-rs that referenced this pull request Oct 20, 2021
If the secure feature is disabled, it's not needed to compile the
boringssl-src crate.

Fix tikv#536

Signed-off-by: Hugues de Valon <[email protected]>
christian-oudard added a commit to mobilecoinofficial/grpc-rs that referenced this pull request Oct 20, 2021
If the secure feature is disabled, it's not needed to compile the
boringssl-src crate.

Fix tikv#536

Signed-off-by: Hugues de Valon <[email protected]>
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.

Remove dependency on boringssl-src if secure is not activated
3 participants