-
Notifications
You must be signed in to change notification settings - Fork 518
Adjust the standards for proto target to align with those of Protocol Buffers. #3800
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR adds CI validation to ensure OpenTelemetry C++ can be built with a different C++ standard than the protobuf dependency it uses, addressing issue #3799 where MSVC linking errors occurred when protobuf was compiled with C++17 but OpenTelemetry was built with C++20.
Key Changes:
- Adds new
cmake.different_std.testCI target for both Linux (GCC) and Windows (MSVC) platforms - Linux GCC test installs dependencies with C++17, then builds OpenTelemetry with C++23
- Windows MSVC test validates similar scenario with C++20 for OpenTelemetry
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| ci/do_ci.sh | Adds new cmake.different_std.test target for Linux/GCC that builds with C++23 STL and enables OTLP file support |
| ci/do_ci.ps1 | Adds new cmake.different_std.test target for Windows/MSVC that builds with C++20 STL, maintainer mode, and OTLP file support |
| .github/workflows/ci.yml | Adds two new CI jobs: one for GCC (installs protobuf with C++17, builds with C++23) and one for MSVC (tests different C++ standards) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3800 +/- ##
==========================================
+ Coverage 89.94% 90.00% +0.06%
==========================================
Files 225 225
Lines 7167 7167
==========================================
+ Hits 6446 6450 +4
+ Misses 721 717 -4 🚀 New features to boost your workflow:
|
9afd979 to
00ca2ea
Compare
Fixes cmake args Restore windows version
add --build-shared-libs "ON"
Fixes the compatibility for old version of protobuf with C++14 used Fixes DEFINED CMAKE_CXX_STANDARD checking
3f725c7 to
7cab857
Compare
| - name: run otprotocol test | ||
| run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.with_async_export.test | ||
|
|
||
| # Test case where protobuf is built with C++17 and OpenTelemetry with C++20 on MSVC will trigger a Internal compiler error |
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.
nit: remove this commented out test?
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 test currently triggers an MSVC bug and causes an internal compiler error. Should we enable it once the MSVC compiler on GitHub runners is updated? I’m leaving it here so we can re-enable it quickly. It’s the only test that reproduces #3799; I can reproduce it locally with VS 2026, but that isn’t usable on gihutb right now. Alternatively, should we remove it and add it back later?
Fixes #3799
Changes
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changesAnalysis
The generated .pb.cc codes
port.h in protobuf:
port.cc in protobuf
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GlobalEmptyString fixed_address_empty_string{};If protobuf is built with C++17 but the generated .pb.cc files are built with C++20, protobuf exports
GlobalEmptyStringDynamicInit fixed_address_empty_string;while .pb.cc expectsGlobalEmptyStringConstexpr fixed_address_empty_string;, causing an unresolved external symbol.On GCC/Clang,
constexprtypically doesn’t require an extra symbol, so this mismatch doesn’t surface; MSVC’s behavior is right becauseconstexpris not a force rule, but it exposes the issue.This didn’t happen before v30 because only the dynamic
GlobalEmptyStringexisted. It was fixed in protobuf v32 by always usingGlobalEmptyStringDynamicIniton MSVC, so the only affected case is MSVC with protobuf v31.