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

grpc-sys: Use grpc headers found by pkgconfig. #505

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ssloboda
Copy link

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.

@ssloboda
Copy link
Author

ssloboda commented Dec 28, 2020

sorry, fixing the CI failures now

@ssloboda ssloboda force-pushed the ssloboda/fix-cross-compile-bindgen branch from a419fea to 3c66e70 Compare December 28, 2020 19:43
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]>
@ssloboda ssloboda force-pushed the ssloboda/fix-cross-compile-bindgen branch from 3c66e70 to 2c15028 Compare December 28, 2020 19:46
@BusyJay
Copy link
Member

BusyJay commented Dec 29, 2020

Can you explain more about the error? The headers should be the same files across platform.

@ssloboda
Copy link
Author

ssloboda commented Dec 29, 2020

From the commit message:

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.

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 grpcio crate.

Does that clear things up?

@@ -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) {
Copy link
Member

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()))
Copy link
Member

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".

Copy link
Author

Choose a reason for hiding this comment

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

🤦‍♂️

@BusyJay
Copy link
Member

BusyJay commented Dec 29, 2020

...that may not match the bundled version exactly.

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.

@ssloboda
Copy link
Author

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.

@ssloboda ssloboda force-pushed the ssloboda/fix-cross-compile-bindgen branch from 099f9a1 to cc29ee2 Compare December 29, 2020 16:57
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

grpc-sys/build.rs Show resolved Hide resolved
@BusyJay
Copy link
Member

BusyJay commented Feb 2, 2021

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.

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.

2 participants