You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tubemq.apache.org by "Yihao Ke (Jira)" <ji...@apache.org> on 2020/10/22 09:52:00 UTC

[jira] [Updated] (TUBEMQ-380) Cpp client link error when gcc optimization is disabled

     [ https://issues.apache.org/jira/browse/TUBEMQ-380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Yihao Ke updated TUBEMQ-380:
----------------------------
    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'

!image-2020-10-22-17-38-01-225.png|width=1119,height=218!

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

!image-2020-10-22-17-41-13-790.png|width=823,height=213!

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 C++11)(until C++17) is odr-used, {color:#FF0000}a definition at namespace scope is still required{color}, but it cannot have an initializer. A definition may be provided even though redundant (since C++17)."

 

Possible fix:
 # Add static const definition in src/client_connection.cc and src/client_service.cc
 # 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

  was:
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'

!image-2020-10-22-17-38-01-225.png|width=1119,height=218!

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

!image-2020-10-22-17-41-13-790.png|width=823,height=213!

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 C++11)(until C++17) is odr-used, {color:#FF0000}a definition at namespace scope is still required{color}, but it cannot have an initializer. A definition may be provided even though redundant (since C++17)."

 

Possible fix:
 # Add static const definition in src/client_connection.cc and src/client_service.cc
 # 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


> Cpp client link error when gcc optimization is disabled
> -------------------------------------------------------
>
>                 Key: TUBEMQ-380
>                 URL: https://issues.apache.org/jira/browse/TUBEMQ-380
>             Project: Apache TubeMQ
>          Issue Type: Bug
>          Components: Client
>    Affects Versions: tubemq-client-cpp
>            Reporter: Yihao Ke
>            Priority: Major
>         Attachments: image-2020-10-22-17-38-01-225.png, image-2020-10-22-17-41-13-790.png
>
>
> 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'
> !image-2020-10-22-17-38-01-225.png|width=1119,height=218!
> This link error can be reproduced in CMake environment when you remove "-O2" in CMAKE_CXX_FLAGS
> !image-2020-10-22-17-41-13-790.png|width=823,height=213!
> 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 C++11)(until C++17) is odr-used, {color:#FF0000}a definition at namespace scope is still required{color}, but it cannot have an initializer. A definition may be provided even though redundant (since C++17)."
>  
> Possible fix:
>  # Add static const definition in src/client_connection.cc and src/client_service.cc
>  # 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



--
This message was sent by Atlassian Jira
(v8.3.4#803005)