From b66dec58ed947d041901f7106c569a5ef69fa68f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 3 Jan 2024 09:24:36 +0100 Subject: [PATCH] macOS: Silence noisy linker warning about duplicate libraries The warning was introduced with XCode 15 and conflicted with some assumptions in the CMake. Even without actual cyclic dependency between targets CMake might decide to pass library multiple times to the linker, to ensure all its users find symbols from it. This behavior is expected to be tweaked in the upcoming CMake version, but until it is released and became widely used by all Blender macOS developers silence the warning. Pull Request: https://projects.blender.org/blender/blender/pulls/116718 --- build_files/cmake/platform/platform_apple.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index fb451e2d978..48be5424187 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -429,10 +429,21 @@ string(APPEND PLATFORM_LINKFLAGS " -Wl,-unexported_symbols_list,'${PLATFORM_SYMBOLS_MAP}'" ) -# Use old, slower linker for now to avoid many linker warnings. if(${XCODE_VERSION} VERSION_GREATER_EQUAL 15.0) if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64") + # Silence "no platform load command found in , assuming: macOS". string(APPEND PLATFORM_LINKFLAGS " -Wl,-ld_classic") + else() + # Silence "ld: warning: ignoring duplicate libraries". + # + # The warning is introduced with Xcode 15 and is triggered when the same library + # is passed to the linker ultiple times. This situation could happen with either + # cyclic libraries, or some transitive dependencies where CMake might decide to + # pass library to the linker multiple times to force it re-scan symbols. It is + # not neeed for Xcode linker to ensure all symbols from library are used and it + # is corrected in CMake 3.29: + # https://gitlab.kitware.com/cmake/cmake/-/issues/25297 + string(APPEND PLATFORM_LINKFLAGS " -Xlinker -no_warn_duplicate_libraries") endif() endif()