Adjust the standards for proto target to align with those of Protocol Buffers.#3800
Adjust the standards for proto target to align with those of Protocol Buffers.#3800owent wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
There was a problem hiding this comment.
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.97% 89.97%
=======================================
Files 225 225
Lines 7168 7168
=======================================
Hits 6449 6449
Misses 719 719 🚀 New features to boost your workflow:
|
3f725c7 to
7cab857
Compare
.github/workflows/ci.yml
Outdated
| - 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.
nit: remove this commented out test?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
What is the ICE? Probably add TODO to track it?
There was a problem hiding this comment.
Logs can be found at https://github.com/open-telemetry/opentelemetry-cpp/actions/runs/20818142168/job/59799024061
When building protobuf v31.1
libupb.vcxproj -> C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\bin\Debug\libupbd.lib
Building Custom Rule C:/Users/runneradmin/AppData/Local/Temp/otel-cpp-third-party-build/external/protobuf/src/protobuf/CMakeLists.txt
any.cc
any_lite.cc
arena.cc
arena_align.cc
arenastring.cc
arenaz_sampler.cc
code_generator.cc
code_generator_lite.cc
plugin.pb.cc
retention.cc
cpp_features.pb.cc
descriptor.cc
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google/protobuf/descriptor_visitor.h(108,1): fatal error C1001: Internal compiler error. [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upb.vcxproj] [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\protobuf-build.vcxproj]
(compiler file 'msc1.cpp', line 1589)
To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com/
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google/protobuf/descriptor_visitor.h(108,1): message : the template instantiation context (the oldest one first) is [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upb.vcxproj]
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google\protobuf\descriptor.cc(8380,13): message : see reference to function template instantiation 'void google::protobuf::internal::VisitDescriptors<google::protobuf::DescriptorBuilder::CheckVisibilityRules::<lambda_eb886289529f14dfd0500371ca9c46d6>>(const google::protobuf::FileDescriptor &,const google::protobuf::FileDescriptorProto &,Visitor)' being compiled [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upb.vcxproj]
with
[
Visitor=google::protobuf::DescriptorBuilder::CheckVisibilityRules::<lambda_eb886289529f14dfd0500371ca9c46d6>
]
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google/protobuf/descriptor_visitor.h(167,58): message : see reference to function template instantiation 'void google::protobuf::internal::VisitImpl<google::protobuf::internal::VisitDescriptors::VisitorImpl>::Visit<const google::protobuf::FileDescriptorProto>(const google::protobuf::FileDescriptor &,const google::protobuf::FileDescriptorProto &)' being compiled [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upb.vcxproj]
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google/protobuf/descriptor_visitor.h(109,5): message : while compiling class template member function 'unknown-type google::protobuf::DescriptorBuilder::CheckVisibilityRules::<lambda_eb886289529f14dfd0500371ca9c46d6>::operator ()(const _T1 &,const _T2 &) const' [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upb.vcxproj]
INTERNAL COMPILER ERROR in 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64\CL.exe'
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Building Custom Rule C:/Users/runneradmin/AppData/Local/Temp/otel-cpp-third-party-build/external/protobuf/src/protobuf/CMakeLists.txt
any.cc
any_lite.cc
arena.cc
arena_align.cc
arenastring.cc
arenaz_sampler.cc
code_generator.cc
code_generator_lite.cc
plugin.pb.cc
retention.cc
cpp_features.pb.cc
descriptor.cc
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google/protobuf/descriptor_visitor.h(108,1): fatal error C1001: Internal compiler error. [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upbdefs.vcxproj] [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\protobuf-build.vcxproj]
(compiler file 'msc1.cpp', line 1589)
To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com/
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google/protobuf/descriptor_visitor.h(108,1): message : the template instantiation context (the oldest one first) is [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upbdefs.vcxproj]
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google\protobuf\descriptor.cc(8380,13): message : see reference to function template instantiation 'void google::protobuf::internal::VisitDescriptors<google::protobuf::DescriptorBuilder::CheckVisibilityRules::<lambda_eb886289529f14dfd0500371ca9c46d6>>(const google::protobuf::FileDescriptor &,const google::protobuf::FileDescriptorProto &,Visitor)' being compiled [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upbdefs.vcxproj]
with
[
Visitor=google::protobuf::DescriptorBuilder::CheckVisibilityRules::<lambda_eb886289529f14dfd0500371ca9c46d6>
]
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google/protobuf/descriptor_visitor.h(167,58): message : see reference to function template instantiation 'void google::protobuf::internal::VisitImpl<google::protobuf::internal::VisitDescriptors::VisitorImpl>::Visit<const google::protobuf::FileDescriptorProto>(const google::protobuf::FileDescriptor &,const google::protobuf::FileDescriptorProto &)' being compiled [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upbdefs.vcxproj]
C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf\src\google/protobuf/descriptor_visitor.h(109,5): message : while compiling class template member function 'unknown-type google::protobuf::DescriptorBuilder::CheckVisibilityRules::<lambda_eb886289529f14dfd0500371ca9c46d6>::operator ()(const _T1 &,const _T2 &) const' [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\protobuf\src\protobuf-build\protoc-gen-upbdefs.vcxproj]
INTERNAL COMPILER ERROR in 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64\CL.exe'
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\CMakeFiles\b85673c8d2c887062bdd371d2afff3e1\protobuf-mkdir.rule;C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\CMakeFiles\b85673c8d2c887062bdd371d2afff3e1\protobuf-download.rule;C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\CMakeFiles\b85673c8d2c887062bdd371d2afff3e1\protobuf-update.rule;C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\CMakeFiles\b85673c8d2c887062bdd371d2afff3e1\protobuf-patch.rule;C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\CMakeFiles\b85673c8d2c887062bdd371d2afff3e1\protobuf-configure.rule;C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\CMakeFiles\b85673c8d2c887062bdd371d2afff3e1\protobuf-build.rule;C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\CMakeFiles\78a33ba8e4d1644ab3e8d5cd79f88cfd\protobuf-build.rule;D:\a\opentelemetry-cpp\opentelemetry-cpp\install\cmake\CMakeLists.txt' exited with code 1. [C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\protobuf-build.vcxproj]
Performing install step for 'curl'
MSBuild version 17.14.23+b0019275e for .NET Framework
1>Checking Build System
Building Custom Rule C:/Users/runneradmin/AppData/Local/Temp/otel-cpp-third-party-build/external/curl/src/curl/lib/CMakeLists.txt
libcurl_object.vcxproj -> C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\curl\src\curl-build\lib\libcurl_object.dir\Debug\libcurl_object.lib
Building Custom Rule C:/Users/runneradmin/AppData/Local/Temp/otel-cpp-third-party-build/external/curl/src/curl/lib/CMakeLists.txt
libcurl_shared.vcxproj -> C:\Users\runneradmin\AppData\Local\Temp\otel-cpp-third-party-build\external\curl\src\curl-build\lib\Debug\libcurl-d.dll
Building Custom Rule C:/Users/runneradmin/AppData/Local/Temp/otel-cpp-third-party-build/external/curl/src/curl/CMakeLists.txt
1>
-- Install configuration: "Debug"
I successfully built and tested Protobuf v31.1 on my system. It works well with the latest versions of both VS 2022 and VS 2026.
TODO comment is added and I squashed commits to clean up the history.
5426ace to
4e79eb3
Compare
Fixes third_party_latest PATH install latest third party libs for windows Fixes copyright and parallel Fixes cmake args Restore windows version try to reproduce link error add --build-shared-libs "ON" Allow install_thirdparty to set BUILD_SHARED_LIBS Make the proto targets follow the CXX_STANDARD using by protobuf Fixes the compatibility for old version of protobuf with C++14 used Fixes DEFINED CMAKE_CXX_STANDARD checking Fixes compiling Fixes spelling Patch protobuf v31 only is enough Fixes cmake var Add TODO
ed30cbb to
6929949
Compare
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.