-
Notifications
You must be signed in to change notification settings - Fork 254
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
grpc-sys: Use grpc headers found by pkgconfig. #505
base: master
Are you sure you want to change the base?
grpc-sys: Use grpc headers found by pkgconfig. #505
Conversation
|
a419fea
to
3c66e70
Compare
Previously the bundled grpc headers were always used to generate bindings even in the case where pkgconfig was used to locate gRPC to link against. This caused errors at runtime, e.g., SEGFAULT, rather than a compile-time error. To fix this, use the headers found by pkgconfig to generate bindings rather than than the bundled headers if pkgconfig is already being used. Signed-off-by: Steven Sloboda <[email protected]>
3c66e70
to
2c15028
Compare
Can you explain more about the error? The headers should be the same files across platform. |
From the commit message:
This is not a problem that I expect to come up often however it will make things easier for those who dynamically link against a system installation of gRPC that may not match the bundled version exactly. This allows for semver compatible version bumps of gRPC independent of the Does that clear things up? |
grpc-sys/build.rs
Outdated
@@ -344,7 +344,7 @@ fn bindgen_grpc(file_path: &PathBuf) { | |||
// Determine if need to update bindings. Supported platforms do not | |||
// need to be updated by default unless the UPDATE_BIND is specified. | |||
// Other platforms use bindgen to generate the bindings every time. | |||
fn config_binding_path() { | |||
fn config_binding_path(#[allow(unused_variables)] grpc_include_dir: &PathBuf) { |
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.
You can name it _grpc_include_dir
to get around the warning.
@@ -307,7 +307,7 @@ fn bindgen_grpc(file_path: &PathBuf) { | |||
let cfg = config | |||
.header("grpc_wrap.cc") | |||
.clang_arg("-xc++") | |||
.clang_arg("-I./grpc/include") | |||
.clang_arg(format!("-I{}", grpc_include_dir.display())) |
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.
This doesn't seem to be correct. For example, include directory should be "/usr/local/include" instead of "/usr/local/include/grpc".
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.
🤦♂️
Everytime updating the bundled version, there has to be some adaption here or there. So I doubt if it can work correctly. Though I agree compile time error is better than runtime. |
Thanks for the review @BusyJay! I've address the issues you pointed out in a fixup commit for ease of reviewing, will squash once you give the okay. Let me know if there's anything else you want changed. |
Signed-off-by: Steven Sloboda <[email protected]>
099f9a1
to
cc29ee2
Compare
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.
Rest LGTM
Hi @ssloboda do you have time to address the comment and sign off your commits? We may release next version soon, it will be nice to deliver your patch as well. |
Ran into this issue when cross compiling after updating libraries. I had originally fixed and tested this on v0.7.1 but it looks like a PR was just merged so I rebased. Here's the original fix in case you're interested. https://github.com/StarryInternet/grpc-rs/tree/ssloboda/fix-cross-compile-bindgen-v0.7.1
Happy to refactor if needed.