Compare commits

...

3 Commits

Author SHA1 Message Date
f5bfabc03e Mark cpuinfo as a build-interface library for c10 2025-11-11 17:44:13 +00:00
e90d748093 Update c10/CMakeLists.txt 2025-11-07 15:30:07 -08:00
715ba4203c Build cpuinfo into c10 shared library
This change links the entirety of libcpuinfo into libc10, and removes
libtorch_cpu's direct dependency on libcpuinfo.

This fixes a bug on where on some systems CMake reorders static and
shared libraries in linker invocations, which results in the same object
defined in both libc10 and libtorch_cpu. Since libtorch_cpu already
depends on libc10, it makes sense to make libcpuinfo part of libc10's
interface.
2025-11-07 15:17:21 +00:00
3 changed files with 3 additions and 7 deletions

View File

@ -642,10 +642,6 @@ if(USE_MKLDNN_ACL)
list(APPEND ATen_CPU_DEPENDENCY_LIBS ${ACL_LIBRARIES})
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x|ppc64le)$")
list(APPEND ATen_CPU_DEPENDENCY_LIBS cpuinfo)
endif()
if(NOT EMSCRIPTEN AND NOT INTERN_BUILD_MOBILE)
if(NOT MSVC)
# Bump up optimization level for sleef to -O1, since at -O0 the compiler

View File

@ -106,8 +106,9 @@ if(NOT BUILD_LIBTORCHLESS)
message(STATUS "don't use NUMA")
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "s390x" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
target_link_libraries(c10 PRIVATE cpuinfo)
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x|ppc64le)$")
target_link_libraries(c10 INTERFACE "$<BUILD_INTERFACE:cpuinfo>")
target_link_libraries(c10 PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,cpuinfo>")
endif()
find_package(Backtrace)

View File

@ -476,7 +476,6 @@ if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x|ppc64le)$")
# them into a shared library for Caffe2, so they need PIC.
set_property(TARGET cpuinfo PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
endif()