open-telemetry / opentelemetry-cpp

The OpenTelemetry C++ Client
https://opentelemetry.io/
Apache License 2.0
850 stars 403 forks source link

1.15.0 release build failed to build with protobuf 26.1 #2643

Open chenrui333 opened 5 months ago

chenrui333 commented 5 months ago

👋 trying to build the latest release, but run into some build issue. The error log is as below:

error build log ``` /opt/homebrew/Library/Homebrew/shims/mac/super/clang++ -DPROTOBUF_USE_DLLS -Dopentelemetry_proto_EXPORTS -I/tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/build/generated/third_party/opentelemetry-proto -I/tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/api/include -I/tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/sdk/include -I/tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/sdk -I/tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/ext/include -O3 -DNDEBUG -std=gnu++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -fPIC -Wno-error=deprecated-declarations -Wno-type-limits -Wno-deprecated-declarations -Wno-unused-parameter -MD -MT CMakeFiles/opentelemetry_proto.dir/generated/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.pb.cc.o -MF CMakeFiles/opentelemetry_proto.dir/generated/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.pb.cc.o.d -o CMakeFiles/opentelemetry_proto.dir/generated/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.pb.cc.o -c /tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/build/generated/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.pb.cc In file included from /tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/build/generated/third_party/opentelemetry-proto/opentelemetry/proto/common/v1/common.pb.cc:5: In file included from /tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/build/generated/third_party/opentelemetry-proto/opentelemetry/proto/common/v1/common.pb.h:23: In file included from /opt/homebrew/include/google/protobuf/generated_message_tctable_decl.h:23: In file included from /opt/homebrew/include/google/protobuf/parse_context.h:27: /opt/homebrew/include/google/protobuf/implicit_weak_message.h:44:33: error: no type named 'InternalVisibility' in namespace 'google::protobuf::internal' ImplicitWeakMessage(internal::InternalVisibility, Arena* arena) ~~~~~~~~~~^ In file included from /tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/build/generated/third_party/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.pb.cc:5: In file included from /tmp/opentelemetry-cpp-20240422-40679-8q5ewu/opentelemetry-cpp-1.15.0/build/generated/third_party/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.pb.h:23: In file included from /opt/homebrew/include/google/protobuf/generated_message_tctable_decl.h:23: In file included from /opt/homebrew/include/google/protobuf/parse_context.h:27: /opt/homebrew/include/google/protobuf/implicit_weak_message.h:44:33: error: no type named 'InternalVisibility' in namespace 'google::protobuf::internal' ImplicitWeakMessage(internal::InternalVisibility, Arena* arena) ~~~~~~~~~~^ /opt/homebrew/include/google/protobuf/implicit_weak_message.h:59:9: error: unknown type name 'ClassData' const ClassData* GetClassData() const final { ^ /opt/homebrew/include/google/protobuf/implicit_weak_message.h:74:40: error: non-virtual member function marked 'override' hides virtual member function MessageLite* New(Arena* arena) const override { ^ /opt/homebrew/include/google/protobuf/message_lite.h:83:24: note: hidden overloaded virtual function 'google::protobuf::MessageLite::New' declared here: different number of parameters (0 vs 1) virtual MessageLite* New() const = 0; ^ /opt/homebrew/include/google/protobuf/implicit_weak_message.h:59:9: error: unknown type name 'ClassData' const ClassData* GetClassData() const final { ^ /opt/homebrew/include/google/protobuf/implicit_weak_message.h:74:40: error: non-virtual member function marked 'override' hides virtual member function MessageLite* New(Arena* arena) const override { ^ /opt/homebrew/include/google/protobuf/message_lite.h:83:24: note: hidden overloaded virtual function 'google::protobuf::MessageLite::New' declared here: different number of parameters (0 vs 1) virtual MessageLite* New() const = 0; ^ ```

full build log, https://github.com/Homebrew/homebrew-core/actions/runs/8775690834/job/24083917227?pr=169703 relates to Homebrew/homebrew-core#169703

marcalff commented 5 months ago

See related:

marcalff commented 5 months ago

See related:

* [Test build: protobuf 26.1 #2644](https://github.com/open-telemetry/opentelemetry-cpp/pull/2644)

So, this test build was done to try to reproduce the issue.

The problem is that the build fails to install grpc after protobuf, so that the compiling opentelemetry-cpp with protobuf 26.1 is not even attempted.

In short, the test build is inconclusive, it fails for a different reason.

marcalff commented 5 months ago

Looking at the original error reported, the compiler complains about a protobuf declaration found in protobuf related code ... Nothing related to opentelemetry-cpp.

In particular:

/opt/homebrew/include/google/protobuf/implicit_weak_message.h:44:33: error: no type named 'InternalVisibility' in namespace 'google::protobuf::internal'
  ImplicitWeakMessage(internal::InternalVisibility, Arena* arena)

is an issue with protobuf.

I would suspect there are multiple versions of protobuf installed on the machine used to perform the build.

marcalff commented 5 months ago

Please indicate which version is used for:

and indicate the compiling options used in CMake.

chenrui333 commented 5 months ago

abseil: 20240116.2 protobuf 26.1 grpc 1.62.2

this is the full cmake build

==> cmake -S . -B build -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_RPATH=@loader_path/../lib -DBUILD_TESTING=OFF -DWITH_ELASTICSEARCH=ON -DWITH_EXAMPLES=OFF -DWITH_JAEGER=OFF -DWITH_METRICS_PREVIEW=ON -DWITH_OTLP_GRPC=ON -DWITH_OTLP_HTTP=ON -DWITH_ABSEIL=ON -DWITH_PROMETHEUS=ON -DCMAKE_INSTALL_PREFIX=/opt/homebrew/Cellar/opentelemetry-cpp/1.15.0 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DFETCHCONTENT_FULLY_DISCONNECTED=ON -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk

owent commented 5 months ago

I found the versions of utf8_range in protobuf v26 and gRPC 1.62 are different and the headers with same name will be conflict with each other. I'm trying to create a small patch for gRPC to support this situation.

If there are any further results, I will post them here.

chenrui333 commented 5 months ago

Thanks @owent!

owent commented 5 months ago

I use this patch file for gRPC v1.62.2 and it works now.

diff --git a/third_party/upb/upb/wire/internal/decode.h b/third_party/upb/upb/wire/internal/decode.h
index a058ecb..770c8a2 100644
--- a/third_party/upb/upb/wire/internal/decode.h
+++ b/third_party/upb/upb/wire/internal/decode.h
@@ -17,7 +17,7 @@
 #include "upb/message/internal/message.h"
 #include "upb/wire/decode.h"
 #include "upb/wire/eps_copy_input_stream.h"
-#include "utf8_range.h"
+#include "../utf8_range/utf8_range.h"

 // Must be last.
 #include "upb/port/def.inc"

This works on Windows, Linux with clang and gcc, macOS, Android and iOS.

Another problem is that the files /opt/homebrew/lib/cmake/OpenSSL/* in macOS environment of github action are invalid and will broke find_package(OpenSSL). I use [ -e /opt/homebrew/lib/cmake/OpenSSL ] && rm -rf /opt/homebrew/lib/cmake/OpenSSL to remove them and it then works.

They are all not the problems of otel-cpp.

More details can be found here: https://github.com/owent/cmake-toolset/actions/runs/8877326057

Hope it's helpful.

github-actions[bot] commented 3 months ago

This issue was marked as stale due to lack of activity.