From 7f7609a73c648457cc99342625c51257775c0154 Mon Sep 17 00:00:00 2001 From: morningman Date: Sun, 16 Aug 2026 21:53:03 +0800 Subject: [PATCH] [fix](build) stop building libhdfspp on macOS On macOS the libhdfspp tree now stops after the x-platform object libraries libhdfs pulls out of it. Linux and Windows are unchanged. libhdfspp.dylib does not link there. It is compiled against Homebrew LLVM's libc++ headers, configured with no Apple availability annotations, so std::exception_ptr's post-macOS-14 entry points are emitted whatever -mmacosx-version-min says, while -lc++ still resolves against the SDK's system libc++. Against a macOS 14 SDK that leaves __cxa_init_primary_exception and std::exception_ptr::__from_native_exception_pointer undefined, and the failing dylib takes the whole make down with it - libhdfs.a included. Doris never links libhdfspp (be/CMakeLists.txt sets BUILD_LIBHDFSPP OFF), so teaching the link line about Homebrew's libc++ would only put a Homebrew LLVM runtime dependency into a redistributed archive. The guard sits after the include directories and compile flags are set, so the x-platform objects that survive compile exactly as before. The NO_SASL guard added in #407 stays - SASL had libhdfspp as its only consumer - but its comment is rewritten, since the link failure it described can no longer happen. Co-Authored-By: Claude Opus 5 (1M context) --- .../hadoop-hdfs-native-client/src/CMakeLists.txt | 11 +++++------ .../src/main/native/libhdfspp/CMakeLists.txt | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt index 18718890bb9..933fa01dba8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt @@ -204,12 +204,11 @@ check_cxx_source_compiles( }" THREAD_LOCAL_SUPPORTED) if (APPLE) - # libhdfspp's shared library links the static libsasl2 found under the Doris thirdparty - # prefix, whose GSSAPI plugin leaves gss_* undefined. Linux' ld tolerates undefined - # symbols in a .so; macOS' ld does not, so the dylib fails to link and takes the whole - # make down with it - libhdfs.a included. SASL is used by libhdfspp alone, which Doris - # never links (be/CMakeLists.txt sets BUILD_LIBHDFSPP OFF), so turn it off through the - # escape hatch libhdfspp/CMakeLists.txt documents. + # macOS stops after the x-platform object libraries libhdfs needs and never builds + # libhdfspp itself - see main/native/libhdfspp/CMakeLists.txt for why. SASL has no other + # consumer, so skip looking for it through the escape hatch that file documents; the + # static libsasl2 under the Doris thirdparty prefix would not link here anyway, its + # GSSAPI plugin leaves gss_* undefined and macOS' ld, unlike Linux', rejects that. set(NO_SASL 1) endif() if (THREAD_LOCAL_SUPPORTED) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt index ebbc898ac13..4738afbc682 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt @@ -259,6 +259,21 @@ include_directories( SYSTEM ${PROTOBUF_INCLUDE_DIRS} ) +# Doris never links libhdfspp - be/CMakeLists.txt sets BUILD_LIBHDFSPP OFF - and on macOS the +# library cannot be linked at all. It is compiled against Homebrew LLVM's libc++ headers, which +# are configured without Apple's availability annotations, so std::exception_ptr's post-macOS-14 +# entry points (__cxa_init_primary_exception, exception_ptr::__from_native_exception_pointer) are +# emitted whatever -mmacosx-version-min says, while -lc++ still resolves against the SDK's system +# libc++. Against a macOS 14 SDK those two symbols are missing, libhdfspp.dylib fails to link, +# and it takes the whole make down with it - libhdfs.a included. +# +# libhdfs does need the x-platform object libraries out of this tree, so build those and stop +# there. Every compile setting they depend on is already in place above this point. +if(APPLE) + add_subdirectory(lib/x-platform) + return() +endif() + add_subdirectory(third_party/uriparser2) add_subdirectory(lib) if(NOT HDFSPP_LIBRARY_ONLY)