Skip to content

Commit 2bd86c1

Browse files
authored
fix(build): Fix a linkage error for thrift (#2125)
Fix a linkage error on MacOS, the error looks like: ``` Undefined symbols for architecture x86_64: "int boost::math::signbit<double>(double)", referenced from: apache::thrift::protocol::TJSONProtocol::writeJSONDouble(double) in libthrift.a(TJSONProtocol.cpp.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) [ 31%] Building CXX object src/block_service/test/CMakeFiles/dsn_block_service_test.dir/hdfs_service_test.cpp.o make[2]: *** [src/base/test/base_test] Error 1 make[1]: *** [src/base/test/CMakeFiles/base_test.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... ``` This error also appears on Linux when I tried to bump boost to 1.86.0. We use a very old version of thrift (0.9.3), it uses `boost::math::signbit()` which can use replaced by `std::signbit()`. This patch makes this change.
1 parent dc2714a commit 2bd86c1

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.licenserc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ header:
7373
- 'thirdparty/fix_rocksdb-cmake-PORTABLE-option.patch'
7474
- 'thirdparty/fix_snappy-Wsign-compare-warning.patch'
7575
- 'thirdparty/fix_s2_build_with_absl_and_gtest.patch'
76-
- 'thirdparty/fix_thrift_for_cpp11.patch'
76+
- 'thirdparty/fix_thrift_build_and_link_errors.patch'
7777
# TODO(yingchun): shell/* files are import from thirdparties, we can move them to thirdparty later.
7878
# Copyright (c) 2016, Adi Shavit
7979
- 'src/shell/argh.h'

thirdparty/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ ExternalProject_Add(thrift
152152
URL ${OSS_URL_PREFIX}/thrift-0.9.3.tar.gz
153153
http://archive.apache.org/dist/thrift/0.9.3/thrift-0.9.3.tar.gz
154154
URL_MD5 88d667a8ae870d5adeca8cb7d6795442
155-
PATCH_COMMAND patch -p1 < ${TP_DIR}/fix_thrift_for_cpp11.patch
155+
PATCH_COMMAND patch -p1 < ${TP_DIR}/fix_thrift_build_and_link_errors.patch
156156
CMAKE_ARGS -DCMAKE_BUILD_TYPE=release
157157
-DWITH_JAVA=OFF
158158
-DWITH_PYTHON=OFF

thirdparty/fix_thrift_for_cpp11.patch renamed to thirdparty/fix_thrift_build_and_link_errors.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,16 @@ index dadaac3..ef32fe1 100644
5151
} // apache::thrift::stdcxx::placeholders
5252
}}} // apache::thrift::stdcxx
5353
#endif
54+
diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
55+
index e4077bc10..00512990a 100644
56+
--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
57+
+++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
58+
@@ -528,7 +528,7 @@ uint32_t TJSONProtocol::writeJSONDouble(double num) {
59+
bool special = false;
60+
switch (boost::math::fpclassify(num)) {
61+
case FP_INFINITE:
62+
- if (boost::math::signbit(num)) {
63+
+ if (std::signbit(num)) {
64+
val = kThriftNegativeInfinity;
65+
} else {
66+
val = kThriftInfinity;

0 commit comments

Comments
 (0)