Uploaded image for project: 'Apache InLong'
  1. Apache InLong
  2. INLONG-380

Cpp client link error when gcc optimization is disabled

    XMLWordPrintableJSON

Details

    Description

      We encountered tube cpp client link error when we migrate build tools from CMake to Bazel.

      The error message is as below:

      client_connection.cc: (.text+0xff0): undefined reference to `tubemq::ClientConnection::kConnnectMaxTimeMs'

      client_service.cc:
      (.text._ZN6tubemq14ConnectionPoolC2ERSt10shared_ptrINS_12ExecutorPoolEE[_ZN6tubemq14ConnectionPoolC5ERSt10shared_ptrINS_12ExecutorPoolEE]+0xbe): undefined reference to `tubemq::ConnectionPool::kRegularTimerSecond'

      This link error can be reproduced in CMake environment when you remove "-O2" in CMAKE_CXX_FLAGS

      According to cpp standard(https://en.cppreference.com/w/cpp/language/static), 

      "If a const non-inline (since C+17) static data member or a constexpr static data member (since C11)(until C17) is odr-used, a definition at namespace scope is still required, but it cannot have an initializer. A definition may be provided even though redundant (since C+17)."

       

      Possible fix:

      1. Add static const variable definition in src/client_connection.cc and src/client_service.cc
      2. Or change static const variable to enum

       

      Further consideration:

      Turn off compiler optimization in CI to make sure the compiler optimization will not shadow the compile error or link error

      Attachments

        1. image-2020-10-22-17-38-01-225.png
          91 kB
          Yihao Ke
        2. image-2020-10-22-17-41-13-790.png
          107 kB
          Yihao Ke

        Activity

          People

            sheepke Yihao Ke
            sheepke Yihao Ke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 4h 50m
                4h 50m