Skip to content

Commit 36b48b1

Browse files
committed
Try to work around dependency-tracking issues by using CMake builtin support for WHOLE_ARCHIVE
1 parent 7b8f153 commit 36b48b1

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

libcxx/cmake/Modules/HandleLibCXXABI.cmake

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@ function(_import_private_headers target include_dirs headers)
5858
target_include_directories(${target} INTERFACE "${LIBCXX_BINARY_DIR}/private-abi-headers/${target}")
5959
endfunction()
6060

61-
# This function adds linker flags to a <target> appropriate for merging the object
62-
# files of another static <library> into whoever links against <target>.
63-
function(_merge_static_library target library)
64-
if (APPLE)
65-
target_link_options(${target} INTERFACE "-Wl,-force_load" "${library}")
66-
else()
67-
target_link_options(${target} INTERFACE "-Wl,--whole-archive" "-Wl,-Bstatic" "${library}" "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
68-
endif()
69-
endfunction()
70-
7161
# This function creates a library target for linking against an external ABI library.
7262
#
7363
# <target>: The name of the target to create
@@ -96,7 +86,7 @@ function(_import_external_abi_library target name type merged)
9686

9787
add_library(${target} INTERFACE)
9888
if (${merged})
99-
_merge_static_library(${target} "$<TARGET_PROPERTY:${target}-imported,IMPORTED_LOCATION>")
89+
target_link_libraries(${target} INTERFACE "$<LINK_LIBRARY:WHOLE_ARCHIVE,${target}-imported>")
10090
else()
10191
target_link_libraries(${target} INTERFACE ${target}-imported)
10292
endif()
@@ -174,9 +164,7 @@ function(setup_abi_library abi_target linked_into input)
174164
set(merge_target "cxxabi_shared_for_merging")
175165
endif()
176166
add_library(${abi_target} INTERFACE)
177-
_merge_static_library(${abi_target}
178-
"$<TARGET_PROPERTY:${merge_target},LIBRARY_OUTPUT_DIRECTORY>/${CMAKE_STATIC_LIBRARY_PREFIX}$<TARGET_PROPERTY:${merge_target},OUTPUT_NAME>${CMAKE_STATIC_LIBRARY_SUFFIX}")
179-
target_link_libraries(${abi_target} INTERFACE cxxabi-headers)
167+
target_link_libraries(${abi_target} INTERFACE "$<LINK_LIBRARY:WHOLE_ARCHIVE,${merge_target}>")
180168
add_dependencies(${abi_target} ${merge_target})
181169
else()
182170
string(TOLOWER "${search_type}" type)

0 commit comments

Comments
 (0)