File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -979,6 +979,18 @@ endif()
979979set (SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
980980 "Build Swift with a non-default linker" )
981981
982+ include (CheckLinkerFlag)
983+
984+ # Apple's linker complains about duplicate libraries, which CMake likes to do
985+ # to support ELF platforms. To silence that warning, we can use
986+ # -no_warn_duplicate_libraries, but only in versions of the linker that
987+ # support that flag.
988+ if (NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
989+ check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
990+ else ()
991+ set (SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "" )
992+ endif ()
993+
982994#
983995# Enable additional warnings.
984996#
Original file line number Diff line number Diff line change @@ -441,6 +441,12 @@ function(_add_host_variant_link_flags target)
441441 "SHELL:-Xlinker -dead_strip" )
442442 endif ()
443443 endif ()
444+
445+ if (SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
446+ target_link_options (${target} PRIVATE
447+ "SHELL:-Xlinker -no_warn_duplicate_libraries" )
448+ endif ()
449+
444450endfunction ()
445451
446452function (_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
You can’t perform that action at this time.
0 commit comments