lld - Can the target provided for TARGET_LINK_LIBRARIES change its library dependencies using set_target_properties? - Stack Ove

I'm building mariadb on ARM64 Windows using LLVM toolset, I had a duplicate symbol error, such as:

I'm building mariadb on ARM64 Windows using LLVM toolset, I had a duplicate symbol error, such as:

lld-link : error : duplicate symbol: my_strtoll10 [xx\server\llvm_arm64_release\sql\server.vcxproj]
  >>> defined at xx\server\strings\my_strtoll10.c:87
  >>>            xx\server\llvm_arm64_release\strings\strings.dir\Release\my_strtoll10.obj
  >>> defined at strings.lib(my_strtoll10.obj)

After some time, I found the reason is that server.dll links my_strtoll10.obj and static strings.lib that include my_strtoll10.obj's implementation:

  ADD_LIBRARY(server SHARED
    $<TARGET_OBJECTS:sql>
    $<TARGET_OBJECTS:mysys>
    $<TARGET_OBJECTS:dbug>
    $<TARGET_OBJECTS:strings> # includes my_strtoll10.obj
    ${VERSIONINFO_RC}
  )
...
  TARGET_LINK_LIBRARIES(server PRIVATE
   ${all_deps} # the `all_deps` contains mysys_ssl.lib, and mysys_ssl.lib links to strings.lib that includes my_strtoll10.obj's implementation.
   sql_builtins
  )

detailed info in CMakeLists.txt:280

I want to remove some link dependencies using following methods:

  foreach(lib ${all_deps})
    message(STATUS "cur lib: ${lib}")
    if (TARGET ${lib})
      get_target_property(lib_deps ${lib} LINK_LIBRARIES)
      if (lib_deps)
        message(STATUS "dependencies of cur ${lib}: ${lib_deps}")
        SET(original_deps_${lib} ${lib_deps})
        list(REMOVE_ITEM lib_deps sql)
        list(REMOVE_ITEM lib_deps mysys)
        list(REMOVE_ITEM lib_deps dbug)
        list(REMOVE_ITEM lib_deps strings)
        message(STATUS "intermediate dependencies of cur ${lib}: ${lib_deps}")
        set_target_properties(${lib} PROPERTIES LINK_LIBRARIES "${lib_deps}")
        get_target_property(lib_deps_inner ${lib} LINK_LIBRARIES)
        message(STATUS "updated dependencies of cur ${lib}: ${lib_deps_inner}")
      endif()
    endif()
  endforeach()

  get_target_property(lib_deps_inner mysys_ssl LINK_LIBRARIES)
  message(STATUS "newest mysys_ssl: ${lib_deps_inner}")

  TARGET_LINK_LIBRARIES(server PRIVATE
  mysys_ssl
  #  ${all_deps}
  #  sql_builtins
  )

  get_target_property(lib_deps_inner server LINK_LIBRARIES)
  message(STATUS "newest server: ${lib_deps_inner}")

But the result was that lld-link would links to strings.lib even if message(STATUS "newest mysys_ssl: ${lib_deps_inner}") outputed newest mysys_ssl: wolfssl, which did not include strings.lib, the result lld-link command was:

lld-link.exe /OUT:"xx\server\llvm_arm64_release\sql\Release\server.dll" < some options> ..\strings\Release\strings.lib

My question is whether TARGET_LINK_LIBRARIES would only check mysys_ssl's dependencies in according to mysys_ssl's CMakeLists.txt, and do not check current mysys_ssl's dependencies. And can someone give me some advice to solve this duplicate symbol problem? thanks.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744134400a4559991.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信