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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:

env:
RUST_BACKTRACE: 1
RUSTFLAGS: "--deny=warnings"
# Some of the bindgen tests generate "deref-nullptr" warnings, see https://github.com/rust-lang/rust-bindgen/issues/1651
RUSTFLAGS: "--deny=warnings --allow deref-nullptr"
TEST_BIND: 1

jobs:
Expand Down Expand Up @@ -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?

steps:
- uses: actions/checkout@v2
- run: choco install -y llvm
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ env:
# absl deadlock detection performs poorly on arm, so we build it release
# mode to skip the check. Enabling debug-assertions to get safer test
# results.
- RUSTFLAGS="--deny=warnings -C debug-assertions"
# Some of the bindgen tests generate "deref-nullptr" warnings, see https://github.com/rust-lang/rust-bindgen/issues/1651
- RUSTFLAGS="--deny=warnings -C debug-assertions --allow deref-nullptr"
- TEST_BIND=1

addons:
Expand Down
4 changes: 2 additions & 2 deletions grpc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ libz-sys = { version = "1.1.3", default-features = false, features = ["libc", "s

[features]
default = ["use-bindgen"]
secure = []
secure = ["boringssl-src"]
openssl = ["secure"]
openssl-vendored = ["openssl", "openssl-sys"]
no-omit-frame-pointer = []
Expand All @@ -70,4 +70,4 @@ pkg-config = "0.3"
walkdir = "2.2.9"
# Because of rust-lang/cargo#5237, bindgen should not be upgraded util a minor or major release.
bindgen = { version = "0.57.0", default-features = false, optional = true, features = ["runtime"] }
boringssl-src = "0.3.0"
boringssl-src = { version = "0.3.0", optional = true }
9 changes: 8 additions & 1 deletion grpc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ fn build_grpc(cc: &mut cc::Build, library: &str) {
config.define("gRPC_BUILD_CODEGEN", "false");
// We don't need to build benchmarks.
config.define("gRPC_BENCHMARK_PROVIDER", "none");
config.define("gRPC_SSL_PROVIDER", "package");

// `package` should only be set for secure feature, otherwise cmake will always search for
// ssl library.
if cfg!(feature = "secure") {
config.define("gRPC_SSL_PROVIDER", "package");
}
Comment on lines +178 to +180
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!

#[cfg(feature = "secure")]
if cfg!(feature = "openssl") {
if cfg!(feature = "openssl-vendored") {
config.register_dep("openssl");
Expand Down Expand Up @@ -254,6 +260,7 @@ fn figure_ssl_path(build_dir: &str) {
println!("cargo:rustc-link-lib=crypto");
}

#[cfg(feature = "secure")]
fn build_boringssl(config: &mut CmakeConfig) {
let boringssl_artifact = boringssl_src::Build::new().build();
config.define(
Expand Down
83 changes: 16 additions & 67 deletions health/src/proto/protobuf/health_grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// https://github.com/Manishearth/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
Expand All @@ -15,36 +16,18 @@
#![allow(unused_imports)]
#![allow(unused_results)]

const METHOD_HEALTH_CHECK: ::grpcio::Method<
super::health::HealthCheckRequest,
super::health::HealthCheckResponse,
> = ::grpcio::Method {
const METHOD_HEALTH_CHECK: ::grpcio::Method<super::health::HealthCheckRequest, super::health::HealthCheckResponse> = ::grpcio::Method {
ty: ::grpcio::MethodType::Unary,
name: "/grpc.health.v1.Health/Check",
req_mar: ::grpcio::Marshaller {
ser: ::grpcio::pb_ser,
de: ::grpcio::pb_de,
},
resp_mar: ::grpcio::Marshaller {
ser: ::grpcio::pb_ser,
de: ::grpcio::pb_de,
},
req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
};

const METHOD_HEALTH_WATCH: ::grpcio::Method<
super::health::HealthCheckRequest,
super::health::HealthCheckResponse,
> = ::grpcio::Method {
const METHOD_HEALTH_WATCH: ::grpcio::Method<super::health::HealthCheckRequest, super::health::HealthCheckResponse> = ::grpcio::Method {
ty: ::grpcio::MethodType::ServerStreaming,
name: "/grpc.health.v1.Health/Watch",
req_mar: ::grpcio::Marshaller {
ser: ::grpcio::pb_ser,
de: ::grpcio::pb_de,
},
resp_mar: ::grpcio::Marshaller {
ser: ::grpcio::pb_ser,
de: ::grpcio::pb_de,
},
req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
};

#[derive(Clone)]
Expand All @@ -59,73 +42,39 @@ impl HealthClient {
}
}

pub fn check_opt(
&self,
req: &super::health::HealthCheckRequest,
opt: ::grpcio::CallOption,
) -> ::grpcio::Result<super::health::HealthCheckResponse> {
pub fn check_opt(&self, req: &super::health::HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<super::health::HealthCheckResponse> {
self.client.unary_call(&METHOD_HEALTH_CHECK, req, opt)
}

pub fn check(
&self,
req: &super::health::HealthCheckRequest,
) -> ::grpcio::Result<super::health::HealthCheckResponse> {
pub fn check(&self, req: &super::health::HealthCheckRequest) -> ::grpcio::Result<super::health::HealthCheckResponse> {
self.check_opt(req, ::grpcio::CallOption::default())
}

pub fn check_async_opt(
&self,
req: &super::health::HealthCheckRequest,
opt: ::grpcio::CallOption,
) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::health::HealthCheckResponse>> {
pub fn check_async_opt(&self, req: &super::health::HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::health::HealthCheckResponse>> {
self.client.unary_call_async(&METHOD_HEALTH_CHECK, req, opt)
}

pub fn check_async(
&self,
req: &super::health::HealthCheckRequest,
) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::health::HealthCheckResponse>> {
pub fn check_async(&self, req: &super::health::HealthCheckRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::health::HealthCheckResponse>> {
self.check_async_opt(req, ::grpcio::CallOption::default())
}

pub fn watch_opt(
&self,
req: &super::health::HealthCheckRequest,
opt: ::grpcio::CallOption,
) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver<super::health::HealthCheckResponse>> {
pub fn watch_opt(&self, req: &super::health::HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver<super::health::HealthCheckResponse>> {
self.client.server_streaming(&METHOD_HEALTH_WATCH, req, opt)
}

pub fn watch(
&self,
req: &super::health::HealthCheckRequest,
) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver<super::health::HealthCheckResponse>> {
pub fn watch(&self, req: &super::health::HealthCheckRequest) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver<super::health::HealthCheckResponse>> {
self.watch_opt(req, ::grpcio::CallOption::default())
}
pub fn spawn<F>(&self, f: F)
where
F: ::futures::Future<Output = ()> + Send + 'static,
{
pub fn spawn<F>(&self, f: F) where F: ::futures::Future<Output = ()> + Send + 'static {
self.client.spawn(f)
}
}

pub trait Health {
fn check(
&mut self,
ctx: ::grpcio::RpcContext,
_req: super::health::HealthCheckRequest,
sink: ::grpcio::UnarySink<super::health::HealthCheckResponse>,
) {
fn check(&mut self, ctx: ::grpcio::RpcContext, _req: super::health::HealthCheckRequest, sink: ::grpcio::UnarySink<super::health::HealthCheckResponse>) {
grpcio::unimplemented_call!(ctx, sink)
}
fn watch(
&mut self,
ctx: ::grpcio::RpcContext,
_req: super::health::HealthCheckRequest,
sink: ::grpcio::ServerStreamingSink<super::health::HealthCheckResponse>,
) {
fn watch(&mut self, ctx: ::grpcio::RpcContext, _req: super::health::HealthCheckRequest, sink: ::grpcio::ServerStreamingSink<super::health::HealthCheckResponse>) {
grpcio::unimplemented_call!(ctx, sink)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ impl SinkBase {
// `start_send` is supposed to be called after `poll_ready` returns ready.
assert!(self.batch_f.is_none());

let mut flags = self.buf_flags.clone().unwrap();
let mut flags = self.buf_flags.unwrap();
flags = flags.buffer_hint(buffer_hint);
let write_f = call.call(|c| {
c.call
Expand Down
1 change: 1 addition & 0 deletions src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ impl ChannelBuilder {

/// Build `ChannelArgs` from the current configuration.
#[allow(clippy::useless_conversion)]
#[allow(clippy::cmp_owned)]
pub fn build_args(&self) -> ChannelArgs {
let args = unsafe { grpc_sys::grpcwrap_channel_args_create(self.options.len()) };
for (i, (k, v)) in self.options.iter().enumerate() {
Expand Down