Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused include-order change addresses the reported header mismatch without an identified issue.
0 open findings
What changed in this PR
This PR adjusts CMake header search order so builds use headers from the selected protobuf installation.
Changes:
- Places generated headers first, followed by the selected protobuf headers and then general dependency headers.
| File | Description |
|---|---|
| CMakeLists.txt | Updates brpc_common_config include order. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Thanks, moving protobuf ahead of the generic dependency prefixes looks right. Two small things before merging:
|
68a556d to
187327f
Compare
|
Thank you! @darion-yaphet |
187327f to
500c13a
Compare
|
Prepending the selected Protobuf include directory is a reasonable, scoped fix. It assumes that the directory belongs to a consistent dependency installation. Include ordering alone cannot guarantee correctness when shared prefixes contain conflicting versions of multiple libraries; that requires control over the build environment and dependency graph. Keeping generated and in-tree brpc headers ahead of installed copies remains worthwhile, but I would treat that as a separate, limited concern rather than require this PR to solve general multi-version coexistence. Since #3618 has merged, please rebase and adapt the change to the module-owned targets. A regression check with conflicting Protobuf headers in a generic prefix would help verify the intended behavior. |
wwbmmm
left a comment
There was a problem hiding this comment.
[replied by brpc-oncall robot] The butil-level ordering change is reasonable, but it only protects butil's own config so the brpc module and test targets can still pick up Protobuf headers from a generic prefix, the added regression check never runs in CI, and one unrelated test source was added.
|
Thanks for the updates. The include-order fix looks reasonable, and the latest revision covers the module and test configuration targets. One suggestion: More importantly, checking I'd prefer keeping the explicit ordering fix and using a focused regression test with conflicting Protobuf installations to verify the actual compiler behavior, rather than introducing a custom assertion function into the regular CMake configuration. This would keep the implementation simpler while providing stronger regression coverage for the original issue. |

What problem does this PR solve?
Issue Number: resolve
Problem Summary:
CMake may select one Protobuf installation while a generic include prefix
(for example
/usr/local/include) is searched first. If that prefix containsheaders from a different Protobuf version, brpc can compile against headers
that do not match the selected Protobuf libraries.
This PR makes the selected Protobuf include directories take precedence for
the module-owned build targets.
What is changed and the side effects?
Changed:
Protobuf_INCLUDE_DIRStobutil_build_configbefore generic dependencyinclude directories.
directory.
directories precede generic include directories.
Side effects:
consistently use the Protobuf installation selected by
find_package.still need to be managed by the build environment.
Breaking backward compatibility:
None.