clickhouse-cpp
clickhouse-cpp copied to clipboard
Current setup with absl is dangerous
The way this library currently uses absl
can mess up a lot of things. In my opinion it should be reconsidered or at least (as a temporary workaround measure) a switch must be added to CMakeLists.txt to switch off int128 support (and any absl dependency coming with it).
Scenario 1:
- User decides to use link with both clickhouse-cpp and absl from
master
branch and in their project - int128.cc is compiled twice - once as part of clickhouse build, once as part of absl build.
- Build likely fails because the same functions will be exported twice from different translation units
Scenario 2:
- User decides to use link with both clickhouse-cpp and absl from
lts_*
branch and in their project. Let's assume neither of those are installed in the system, but are rather plugged into the project viaFetchContent
/ExternalProject
in CMake. - lts_ branch puts all code into something like
absl::lts_20210324::
inline namespace. So from linker point of view all absl symbols will be there, even though from compiler point of view they will be visible inabsl::
. -
columns/numeric.cpp
will then use absl from contrib. - Any user code that directly or indirectly includes
columns/numeric.h
will probably use the other absl. - This will lead to mysterious linker failures because now declaration from
columns/numeric.h
and definition incolumns/numeric.cpp
are ABI-incompatible.
My understanding is that scenario 2 will only occur if the user attempts to actually use Int128 columns. Scenario 1 may occur if the the project uses int128 somewhere else, even if it doesn't need Int128 columns. There is a way to convert scenario 1 to scenario 2 by enabling inline namespace (and giving it unique name) inside absl/base/options.h
. The disadvantage is that scenario 2 will likely produce more incomprehensible diagnostic messages from the linker.
Hi @Dlougach ! Thanks for pointing this out, it is less likely that this issue will get any attention soon. So you are welcome to submit a PR or a proposal on how to fix it.
Hello @Enmk !
Would you be kind enough to approve my MR or at least allow the CI to run in order to see if there is any issue :-)
Sure, no problem, please sign the CLA and address the issues mentioned in the comments.