mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Linker version script to hide LLVM symbols (#62906)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/62906 Test Plan: Imported from OSS Reviewed By: navahgar Differential Revision: D30193893 Pulled By: bertmaher fbshipit-source-id: 9b189bfd8d4c52e8dc4296a4bed517ff44994ba0
This commit is contained in:
parent
1b1f1e36b4
commit
3eeaffc7c5
3 changed files with 18 additions and 0 deletions
|
|
@ -797,6 +797,15 @@ if(USE_LLVM AND LLVM_FOUND)
|
|||
support core analysis executionengine instcombine
|
||||
scalaropts transformutils ${LLVM_TARGETS_TO_BUILD} orcjit)
|
||||
target_link_libraries(torch_cpu PRIVATE ${LLVM_LINK_LIBS})
|
||||
if(APPLE)
|
||||
set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/unexported_symbols.lds")
|
||||
set_target_properties(torch_cpu PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
|
||||
set_target_properties(torch_cpu PROPERTIES LINK_FLAGS "-Wl,-unexported_symbols_list,${LINKER_SCRIPT}")
|
||||
elseif(UNIX)
|
||||
set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/version_script.lds")
|
||||
set_target_properties(torch_cpu PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
|
||||
set_target_properties(torch_cpu PROPERTIES LINK_FLAGS "-Wl,--version-script=${LINKER_SCRIPT}")
|
||||
endif()
|
||||
endif(USE_LLVM AND LLVM_FOUND)
|
||||
|
||||
# This is required for older versions of CMake, which don't allow
|
||||
|
|
|
|||
2
caffe2/unexported_symbols.lds
Normal file
2
caffe2/unexported_symbols.lds
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
__ZN4llvm*
|
||||
__ZNK4llvm*
|
||||
7
caffe2/version_script.lds
Normal file
7
caffe2/version_script.lds
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
pytorch {
|
||||
global:
|
||||
*;
|
||||
local:
|
||||
_ZN4llvm*;
|
||||
_ZNK4llvm*;
|
||||
};
|
||||
Loading…
Reference in a new issue