mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Use CMake wholearchive group (#156393)
Use CMake wholearchive group to simplify code. It may also support more OSes. Pull Request resolved: https://github.com/pytorch/pytorch/pull/156393 Approved by: https://github.com/ezyang
This commit is contained in:
@ -1157,15 +1157,7 @@ if(USE_XPU)
|
||||
if(USE_C10D_XCCL)
|
||||
target_compile_definitions(torch_xpu PUBLIC USE_C10D_XCCL)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# Windows
|
||||
target_link_options(torch_xpu PRIVATE
|
||||
"-WHOLEARCHIVE:$<TARGET_FILE:torch_xpu_ops>")
|
||||
else()
|
||||
# Linux
|
||||
target_link_options(torch_xpu PRIVATE
|
||||
"-Wl,--whole-archive,$<TARGET_FILE:torch_xpu_ops>,--no-whole-archive")
|
||||
endif()
|
||||
target_link_libraries(torch_xpu PRIVATE $<LINK_LIBRARY:WHOLE_ARCHIVE,torch_xpu_ops>)
|
||||
|
||||
# Set cached ${ATen_XPU_INCLUDE_DIRS} to torch
|
||||
include_directories(SYSTEM ${ATen_XPU_INCLUDE_DIRS})
|
||||
|
@ -163,20 +163,7 @@ macro(caffe2_interface_library SRC DST)
|
||||
# link command for the specific SRC library.
|
||||
if(${__src_target_type} STREQUAL "STATIC_LIBRARY")
|
||||
# In the case of static library, we will need to add whole-static flags.
|
||||
if(APPLE)
|
||||
target_link_libraries(
|
||||
${DST} INTERFACE -Wl,-force_load,\"$<TARGET_FILE:${SRC}>\")
|
||||
elseif(MSVC)
|
||||
# In MSVC, we will add whole archive in default.
|
||||
target_link_libraries(
|
||||
${DST} INTERFACE "$<TARGET_FILE:${SRC}>")
|
||||
target_link_options(
|
||||
${DST} INTERFACE "-WHOLEARCHIVE:$<TARGET_FILE:${SRC}>")
|
||||
else()
|
||||
# Assume everything else is like gcc
|
||||
target_link_libraries(${DST} INTERFACE
|
||||
"-Wl,--whole-archive,\"$<TARGET_FILE:${SRC}>\" -Wl,--no-whole-archive")
|
||||
endif()
|
||||
target_link_libraries(${DST} INTERFACE $<LINK_LIBRARY:WHOLE_ARCHIVE,${SRC}>)
|
||||
# Link all interface link libraries of the src target as well.
|
||||
# For static library, we need to explicitly depend on all the libraries
|
||||
# that are the dependent library of the source library. Note that we cannot
|
||||
|
Reference in New Issue
Block a user