[Bf-blender-cvs] [554f861ac11] blender-v2.82-release: Build: fix Linux linking errors with some combinations of build options

Brecht Van Lommel noreply at git.blender.org
Fri Jan 17 09:25:58 CET 2020


Commit: 554f861ac11a308e3f00f1cd55d4c9e76015b7ad
Author: Brecht Van Lommel
Date:   Thu Jan 16 12:57:58 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB554f861ac11a308e3f00f1cd55d4c9e76015b7ad

Build: fix Linux linking errors with some combinations of build options

Differential Revision: https://developer.blender.org/D6600

===================================================================

M	build_files/cmake/macros.cmake

===================================================================

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 3b6b4720a7c..3fe9ae90a79 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -416,6 +416,17 @@ function(setup_liblinks
   set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE)
   set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} ${PLATFORM_LINKFLAGS_RELEASE}" PARENT_SCOPE)
 
+  # Work around undefined reference errors when disabling certain libraries.
+  # Finding the right order for all combinations of options is too hard, so
+  # we use --start-group and --end-group so the linker does not discard symbols
+  # too early. This appears to have no significant performance impact.
+  if(UNIX AND NOT APPLE)
+    target_link_libraries(
+      ${target}
+      -Wl,--start-group
+    )
+  endif()
+
   # jemalloc must be early in the list, to be before pthread (see T57998)
   if(WITH_MEM_JEMALLOC)
     target_link_libraries(${target} ${JEMALLOC_LIBRARIES})
@@ -592,6 +603,14 @@ function(setup_liblinks
 
   # target_link_libraries(${target} ${PLATFORM_LINKLIBS} ${CMAKE_DL_LIBS})
   target_link_libraries(${target} ${PLATFORM_LINKLIBS})
+
+  # See comments above regarding --start-group.
+  if(UNIX AND NOT APPLE)
+    target_link_libraries(
+      ${target}
+      -Wl,--end-group
+    )
+  endif()
 endfunction()
 
 macro(TEST_SSE_SUPPORT



More information about the Bf-blender-cvs mailing list