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

airborne pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new fd05761931d [fix](build) Fix --whole-archive linker error on macOS 
(#61291)
fd05761931d is described below

commit fd05761931dd3c12c650924212794f0bd6e6f7e9
Author: Jack <[email protected]>
AuthorDate: Tue Mar 17 15:18:19 2026 +0800

    [fix](build) Fix --whole-archive linker error on macOS (#61291)
    
    ### What problem does this PR solve?
    
    Issue Number: N/A
    
    Related PR: #61285
    
    Problem Summary:
    
    macOS `ld64` does not support GNU ld's `--whole-archive` /
    `--no-whole-archive` linker options, causing link failure when building
    BE on macOS:
    
    ```
    ld: unknown options: --whole-archive --no-whole-archive
    ```
    
    This PR uses macOS-native `-force_load` with CMake's
    `$<TARGET_FILE:lib>` generator expression on Apple platforms instead.
    Fixes both `doris_be` (paimon factory registry libs) and `doris_be_test`
    (vector_search_test) link targets.
---
 be/CMakeLists.txt      | 15 +++++++++++----
 be/test/CMakeLists.txt |  9 +++++++--
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 907c916fdc8..e4d9f08eccf 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -663,10 +663,17 @@ set(DORIS_DEPENDENCIES ${DORIS_DEPENDENCIES} 
clucene-contribs-lib)
 
 if (ENABLE_PAIMON_CPP)
     if (PAIMON_FACTORY_REGISTRY_LIBS)
-        set(DORIS_DEPENDENCIES ${DORIS_DEPENDENCIES}
-            -Wl,--whole-archive
-            ${PAIMON_FACTORY_REGISTRY_LIBS}
-            -Wl,--no-whole-archive)
+        if (APPLE)
+            foreach(lib ${PAIMON_FACTORY_REGISTRY_LIBS})
+                set(DORIS_DEPENDENCIES ${DORIS_DEPENDENCIES}
+                    -Wl,-force_load,$<TARGET_FILE:${lib}>)
+            endforeach()
+        else()
+            set(DORIS_DEPENDENCIES ${DORIS_DEPENDENCIES}
+                -Wl,--whole-archive
+                ${PAIMON_FACTORY_REGISTRY_LIBS}
+                -Wl,--no-whole-archive)
+        endif()
     endif()
 
     # paimon-cpp internal dependencies (renamed with _paimon suffix)
diff --git a/be/test/CMakeLists.txt b/be/test/CMakeLists.txt
index 0d8ce57d8a5..b44e5de64a6 100644
--- a/be/test/CMakeLists.txt
+++ b/be/test/CMakeLists.txt
@@ -110,8 +110,13 @@ add_subdirectory(storage/index/ann)
 
 add_executable(doris_be_test ${UT_FILES})
 
-target_link_libraries(doris_be_test ${TEST_LINK_LIBS} 
-    -Wl,--whole-archive vector_search_test -Wl,--no-whole-archive)
+if (APPLE)
+    target_link_libraries(doris_be_test ${TEST_LINK_LIBS}
+        -Wl,-force_load,$<TARGET_FILE:vector_search_test>)
+else()
+    target_link_libraries(doris_be_test ${TEST_LINK_LIBS}
+        -Wl,--whole-archive vector_search_test -Wl,--no-whole-archive)
+endif()
 set_target_properties(doris_be_test PROPERTIES COMPILE_FLAGS 
"-fno-access-control")
 target_compile_options(doris_be_test PRIVATE -include gtest/gtest.h 
-Wno-shadow -Wno-shadow-field)
 


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

Reply via email to