This is an automated email from the ASF dual-hosted git repository.

avamingli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 3917609c704e618ee60dd8f1c4093dc292f342a7
Author: Zhang Mingli <[email protected]>
AuthorDate: Thu May 28 18:38:39 2026 +0800

    macOS: build the standalone libpaxformat reader
    
    paxformat is the standalone PAX file reader meant to be linked by
    external tools. The previous commit 'macOS: PAX cmake portability'
    skipped it on APPLE because it references PG backend functions
    (write_stderr, xlog_check_consistency_hook, ...) that have no
    libpostgres.so to satisfy them on macOS.
    
    Build it after all by deferring those undefined symbols to load time
    with -Wl,-undefined,dynamic_lookup, just like Linux's default ld
    behaviour for shared libraries. The smoke-test executable
    paxformat_test uses the same flag and drops the explicit 'postgres'
    link library (there is no libpostgres.so to link against on macOS).
    
    paxformat is a regular dylib (SHARED) here — not a bundle — because
    the test executable links against it at link time.
---
 contrib/pax_storage/src/cpp/CMakeLists.txt         | 10 ++--------
 contrib/pax_storage/src/cpp/cmake/pax_format.cmake | 22 ++++++++++++++++++++--
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/contrib/pax_storage/src/cpp/CMakeLists.txt 
b/contrib/pax_storage/src/cpp/CMakeLists.txt
index c49473e5d12..0a36374a08d 100644
--- a/contrib/pax_storage/src/cpp/CMakeLists.txt
+++ b/contrib/pax_storage/src/cpp/CMakeLists.txt
@@ -48,13 +48,7 @@ add_custom_target(generate_protobuf DEPENDS ${PROTO_SRCS} 
${PROTO_HDRS})
 link_directories($ENV{GPHOME}/lib)
 
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-## build pax_format.so — standalone reader lib used by external tools.
-## On macOS it would need -undefined dynamic_lookup to resolve PG symbols
-## (write_stderr, xlog_check_consistency_hook, ...). Skip for now; pax.so
-## itself (the in-backend extension) still builds and is enough to run
-## the demo cluster with `USING pax` tables.
-if(NOT APPLE)
-  include(pax_format)
-endif()
+## build pax_format.so — standalone PAX reader used by external tools.
+include(pax_format)
 ## build pax.so
 include(pax)
diff --git a/contrib/pax_storage/src/cpp/cmake/pax_format.cmake 
b/contrib/pax_storage/src/cpp/cmake/pax_format.cmake
index 1c06dacf9d4..de9c640f3f0 100644
--- a/contrib/pax_storage/src/cpp/cmake/pax_format.cmake
+++ b/contrib/pax_storage/src/cpp/cmake/pax_format.cmake
@@ -155,9 +155,18 @@ add_library(paxformat SHARED ${PROTO_SRCS} 
${pax_storage_src} ${pax_clustering_s
 target_include_directories(paxformat PUBLIC ${pax_target_include})
 target_link_directories(paxformat PUBLIC ${pax_target_link_directories})
 target_link_libraries(paxformat PRIVATE ${pax_target_link_libs})
-   
+
 set_target_properties(paxformat PROPERTIES
   OUTPUT_NAME paxformat)
+if(APPLE)
+  # PAX C++ code calls PG backend functions (write_stderr,
+  # xlog_check_consistency_hook, ...). On Linux ld defers unresolved
+  # references in .so; macOS ld rejects them unless told otherwise.
+  # Defer them to load time so paxformat is usable wherever PG symbols
+  # are provided.
+  set_target_properties(paxformat PROPERTIES
+    LINK_FLAGS "-Wl,-undefined,dynamic_lookup")
+endif()
 add_dependencies(paxformat generate_protobuf)
 
 # export headers
@@ -215,4 +224,13 @@ install(TARGETS paxformat
 add_executable(paxformat_test paxformat_test.cc)
 target_include_directories(paxformat_test PUBLIC ${pax_target_include} 
${CMAKE_CURRENT_SOURCE_DIR})
 add_dependencies(paxformat_test paxformat)
-target_link_libraries(paxformat_test PRIVATE paxformat postgres)
+if(APPLE)
+  # No libpostgres.so to link against on macOS; defer PG symbols to
+  # load time. The test still validates that paxformat itself is a
+  # complete dylib.
+  target_link_libraries(paxformat_test PRIVATE paxformat)
+  set_target_properties(paxformat_test PROPERTIES
+    LINK_FLAGS "-Wl,-undefined,dynamic_lookup")
+else()
+  target_link_libraries(paxformat_test PRIVATE paxformat postgres)
+endif()


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to