Skip to content

[C++] Add support for Protobuf 23.2 on non-Windows #35987

Description

@kou

Describe the enhancement requested

We can't resolve google::protobuf::internal::ThreadSafeArena::thread_cache_ with Protobuf 23.2 on non-Windows:

 /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../release/libarrow.a(util_avx2.cc.o) has no symbols
ld: illegal thread local variable reference to regular symbol __ZN6google8protobuf8internal15ThreadSafeArena13thread_cache_E for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I think that protocolbuffers/protobuf#12983 solves this but it's not released yet.

Workarounds:

  1. Specify PROTOBUF_USE_DLLS explicitly on non-Windows too.
  2. Use bundled (old) Protobuf

Component(s)

C++

Activity

  1. kou commented on Jun 8, 2023

    @kou
    MemberAuthor

    Homebrew is only effected for now.
    So I think that we can choose "2. Use bundled (old) Protobuf" (-DProtobuf_SOURCE=BUNDLED) and it's not a 12.0.1 release blocker.

  2. kou commented on Jun 8, 2023

    @kou
    MemberAuthor
  3. changed the title [-][C++] Add support for Protobuf 23.2.0 on non-Windows[/-] [+][C++] Add support for Protobuf 23.2 on non-Windows[/+] on Jun 8, 2023
  4. h-vetinari commented on Jun 8, 2023

    @h-vetinari
    Contributor

    I opened a very similar issue just ahead of you: #35986 ;-)

  5. h-vetinari commented on Jun 8, 2023

    @h-vetinari
    Contributor

    I think that protocolbuffers/protobuf#12983 solves this but it's not released yet.

    I have a feeling that this might not be backported to the 23.x series because it's effectively an ABI break. Perhaps I'm wrong though. Anyway, in conda-forge, we set PROTOBUF_USE_DLLS also on unix to solve this.

  6. kou commented on Jun 8, 2023

    @kou
    MemberAuthor

    I opened a very similar issue just ahead of you: #35986 ;-)

    I saw it but I think that it's a different problem. :-)

    we set PROTOBUF_USE_DLLS also on unix to solve this.

    I think that it's one of workarounds.

  7. raulcd commented on Jun 8, 2023

    @raulcd
    Member

    Homebrew is only effected for now. So I think that we can choose "2. Use bundled (old) Protobuf" (-DProtobuf_SOURCE=BUNDLED) and it's not a 12.0.1 release blocker.

    I am trying to run the verification tasks for MacOS from my fork:

    archery crossbow submit --job-prefix release-12.0.1-rc1-with-bundled-protobuf --arrow-branch release-12.0.1-rc1-with-bundled-protobuf --arrow-remote "https://github.com/raulcd/arrow" --arrow-version 12.0.1 verify-rc-source-*macos-*
    

    Adding the following patch on top of the release-12.0.1-rc1 branch:

    $ git log -1 -p
    commit 6989adf5de211d72199a6a627ea302338a65eb06 (HEAD -> release-12.0.1-rc1-with-bundled-protobuf, origin/release-12.0.1-rc1-with-bundled-protobuf)
    Author: Raúl Cumplido <[email protected]>
    Date:   Thu Jun 8 12:23:44 2023 +0200
    
        Try bundled protobuf for verification on macOS
    
    diff --git a/dev/release/verify-release-candidate.sh b/dev/release/verify-release-candidate.sh
    index 12e6d9c..080ffa2 100755
    --- a/dev/release/verify-release-candidate.sh
    +++ b/dev/release/verify-release-candidate.sh
    @@ -641,6 +641,7 @@ test_and_install_cpp() {
         -DPARQUET_BUILD_EXAMPLES=ON \
         -DPARQUET_BUILD_EXECUTABLES=ON \
         -DPARQUET_REQUIRE_ENCRYPTION=ON \
    +    -DProtobuf_SOURCE=BUNDLED \
         ${ARROW_CMAKE_OPTIONS:-} \
         ${ARROW_SOURCE_DIR}/cpp
       export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:-${NPROC}}
    

    And I am getting some failures on protobuf:

    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:17:2: error: This file was generated by an older version of protoc which is
    #error This file was generated by an older version of protoc which is
     ^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:18:2: error: incompatible with your Protocol Buffer headers. Please
    #error incompatible with your Protocol Buffer headers. Please
     ^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:19:2: error: regenerate this file with a newer version of protoc.
    #error regenerate this file with a newer version of protoc.
     ^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:147:30: error: no type named 'ConstStringParam' in namespace 'google::protobuf'
        ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FlightDescriptor_DescriptorType* value) {
        ~~~~~~~~~~~~~~~~~~~~~~~~~^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:256:35: error: no type named 'StringPiece' in namespace 'google::protobuf'
      static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
             ~~~~~~~~~~~~~~~~~~~~~~~~~^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:221:5: error: use of undeclared identifier 'GOOGLE_DCHECK'
        GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
        ^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:257:12: error: cannot initialize return object of type 'int' with an lvalue of type 'const char [39]'
        return "arrow.flight.protocol.HandshakeRequest";
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:420:35: error: no type named 'StringPiece' in namespace 'google::protobuf'
      static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
             ~~~~~~~~~~~~~~~~~~~~~~~~~^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:385:5: error: use of undeclared identifier 'GOOGLE_DCHECK'
        GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
        ^
    [ 38%] Building CXX object src/arrow/acero/CMakeFiles/arrow_acero_objlib.dir/accumulation_queue.cc.o
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:421:12: error: cannot initialize return object of type 'int' with an lvalue of type 'const char [40]'
        return "arrow.flight.protocol.HandshakeResponse";
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:584:35: error: no type named 'StringPiece' in namespace 'google::protobuf'
      static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
             ~~~~~~~~~~~~~~~~~~~~~~~~~^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:549:5: error: use of undeclared identifier 'GOOGLE_DCHECK'
        GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
        ^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:585:12: error: cannot initialize return object of type 'int' with an lvalue of type 'const char [32]'
        return "arrow.flight.protocol.BasicAuth";
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:738:35: error: no type named 'StringPiece' in namespace 'google::protobuf'
      static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
             ~~~~~~~~~~~~~~~~~~~~~~~~~^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:717:5: error: use of undeclared identifier 'GOOGLE_DCHECK'
        GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
        ^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:739:12: error: cannot initialize return object of type 'int' with an lvalue of type 'const char [28]'
        return "arrow.flight.protocol.Empty";
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:871:35: error: no type named 'StringPiece' in namespace 'google::protobuf'
      static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
             ~~~~~~~~~~~~~~~~~~~~~~~~~^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:836:5: error: use of undeclared identifier 'GOOGLE_DCHECK'
        GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
        ^
    /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/src/arrow/flight/Flight.pb.h:872:12: error: cannot initialize return object of type 'int' with an lvalue of type 'const char [33]'
        return "arrow.flight.protocol.ActionType";
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    

    Examples:
    https://github.com/ursacomputing/crossbow/actions/runs/5210265087/jobs/9401119933
    https://github.com/ursacomputing/crossbow/actions/runs/5210265256/jobs/9401120122

  8. assignUser commented on Jun 8, 2023

    @assignUser
    Member

    The error above is weird as that file is created in the cmake using protoc https://github.com/apache/arrow/blob/main/cpp/src/arrow/flight/CMakeLists.txt#L80

    Maybe a system version is also found and used?

  9. kou commented on Jun 8, 2023

    @kou
    MemberAuthor

    Maybe a system version is also found and used?

    I think so too. It looks like system Protobuf and bundled Protobuf are mixed. But it's strange... Our build process uses absolute path for protoc:

    https://github.com/ursacomputing/crossbow/actions/runs/5210265087/jobs/9401119933#step:4:322

    -- Found protoc: /var/folders/dl/2sqc_b2s20vfy540jn97pz8h0000gn/T/arrow-HEAD.XXXXX.vQ2csunE/cpp-build/protobuf_ep-install/bin/protoc
    
  10. raulcd commented on Jun 8, 2023

    @raulcd
    Member

    It seems ti was GRPC. It should work if we use:

        -DProtobuf_SOURCE=BUNDLED \
        -DgRPC_SOURCE=BUNDLED \
    

    And remove them from the Brewfile as seen on this testing PR: #35995
    So probably not a blocker for the 12.0.1 release?

  11. kou commented on Jun 9, 2023

    @kou
    MemberAuthor

    I think that -DgRPC_SOURCE=BUNDLED is needless because we always use the same _SOURCE for Protobuf and gRPC:

    if(NOT Protobuf_SOURCE STREQUAL gRPC_SOURCE)
    # ARROW-15495: Protobuf/gRPC must come from the same source
    message(STATUS "Forcing gRPC_SOURCE to Protobuf_SOURCE (${Protobuf_SOURCE})")
    set(gRPC_SOURCE "${Protobuf_SOURCE}")
    endif()

    And remove them from the Brewfile

    I think that this is needed. (Or we run brew uninstall protobuf abseil grpc.)

    FYI: We can specify -DProtobuf_SOURCE=BUNDLED without changing our verification script by ARROW_CMAKE_OPTIONS="-DProtobuf_SOURCE=BUNDLED dev/release/verify-release-candidate.sh ...`.

    So probably not a blocker for the 12.0.1 release?

    I think that this is not a blocker.

  12. js8544 commented on Jun 10, 2023

    @js8544
    Contributor

    Homebrew is only effected for now. So I think that we can choose "2. Use bundled (old) Protobuf" (-DProtobuf_SOURCE=BUNDLED) and it's not a 12.0.1 release blocker.

    Hi @kou, since only Homebrew is affected. Why not simply change protobuf to protobuf@21 in our brewfile?

  13. kou commented on Jun 10, 2023

    @kou
    MemberAuthor

    Oh, I didn't notice it!
    It's not a real fix but it'll work as a workaround for now.
    Could you open a pull request for the workaround?

  14. 1 remaining item

  15. added a commit that references this issue on Jun 11, 2023
  16. added this to the 13.0.0 milestone on Jun 11, 2023
  17. kou commented on Jun 11, 2023

    @kou
    MemberAuthor

    Reopen this because #36029 is a workaround.

  18. reopened this on Jun 11, 2023
  19. added a commit that references this issue on Jun 15, 2023
  20. raulcd commented on Jun 15, 2023

    @raulcd
    Member

    @kou @js8544 from my understanding this fix on homebrew should allow us to unpin the versions of protobuf and grpc, right?
    Homebrew/homebrew-core#133623

  21. js8544 commented on Jun 15, 2023

    @js8544
    Contributor

    @kou @js8544 from my understanding this fix on homebrew should allow us to unpin the versions of protobuf and grpc, right? Homebrew/homebrew-core#133623

    It probably does! I'll open a PR to try this.

  22. js8544 commented on Jun 15, 2023

    @js8544
    Contributor

    @kou @js8544 from my understanding this fix on homebrew should allow us to unpin the versions of protobuf and grpc, right? Homebrew/homebrew-core#133623

    Well, #36013 is still causing errors: https://github.com/apache/arrow/actions/runs/5277136967/jobs/9544769123?pr=36087. I'll try again once #36016 is merged.

  23. added a commit that references this issue on Jun 16, 2023
  24. kou commented on Jun 16, 2023

    @kou
    MemberAuthor

    We don't need something because the problem was happen in upstream and it was fixed in upstream.
    (We may want to reject Protobuf versions that have this problem explicitly.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions