Commit 47107fb4 authored by Jaikrishnan Menon's avatar Jaikrishnan Menon

CMake: Avoid exporting symbols from static archives that the

NGraph DSO links to privately

With this change, the unit tests need to link against LLVM and Clang
directly since NGraph no longer exports those symbols.
parent 046a85c0
...@@ -128,6 +128,12 @@ endif() ...@@ -128,6 +128,12 @@ endif()
add_library(ngraph SHARED ${SRC}) add_library(ngraph SHARED ${SRC})
# NGraph links against one or more libraries (ex. LLVM) but we don't want to
# export these symbols as part of the DSO. This is a GNU ld (and derivatives) specific
# option so making this portable is still an open issue. As a note for the future,
# this is not an issue on Windows and LLVM's lld does support --exclude-libs.
set_target_properties(ngraph PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL")
# Colon separated string for specified runtime plugin loading, this is made explicit s.t. if a # Colon separated string for specified runtime plugin loading, this is made explicit s.t. if a
# plugin is specified at compile time but the corresponding library could not be resolved at run- # plugin is specified at compile time but the corresponding library could not be resolved at run-
# time, an error will be generated. # time, an error will be generated.
...@@ -153,7 +159,7 @@ message(STATUS "LIBRARY_OUTPUT_DIRECTORY set to: ${COMMON_LIBRARY_OUTPUT_DIRECTO ...@@ -153,7 +159,7 @@ message(STATUS "LIBRARY_OUTPUT_DIRECTORY set to: ${COMMON_LIBRARY_OUTPUT_DIRECTO
target_include_directories(ngraph PUBLIC "${NGRAPH_INCLUDE_PATH}") target_include_directories(ngraph PUBLIC "${NGRAPH_INCLUDE_PATH}")
if(NGRAPH_CPU_ENABLE AND LLVM_LINK_LIBS) if(NGRAPH_CPU_ENABLE AND LLVM_LINK_LIBS)
target_link_libraries(ngraph LINK_PRIVATE ${LLVM_LINK_LIBS}) target_link_libraries(ngraph PRIVATE ${LLVM_LINK_LIBS})
endif() endif()
if (APPLE) if (APPLE)
...@@ -163,7 +169,7 @@ if (APPLE) ...@@ -163,7 +169,7 @@ if (APPLE)
endif() endif()
if(NGRAPH_CPU_ENABLE AND MKLDNN_LIB_DIR) if(NGRAPH_CPU_ENABLE AND MKLDNN_LIB_DIR)
target_link_libraries(ngraph LINK_PRIVATE mkldnn) target_link_libraries(ngraph PRIVATE mkldnn)
endif() endif()
......
...@@ -62,6 +62,7 @@ endif() ...@@ -62,6 +62,7 @@ endif()
if(LLVM_INCLUDE_DIR) if(LLVM_INCLUDE_DIR)
include_directories(SYSTEM ${LLVM_INCLUDE_DIR}) include_directories(SYSTEM ${LLVM_INCLUDE_DIR})
link_directories(${LLVM_LIB_DIR})
set(SRC ${SRC} codegen.cpp) set(SRC ${SRC} codegen.cpp)
set(BACKEND_NAMES ${BACKEND_NAMES} "CPU") set(BACKEND_NAMES ${BACKEND_NAMES} "CPU")
endif() endif()
...@@ -82,6 +83,11 @@ if(MKLDNN_INCLUDE_DIR) ...@@ -82,6 +83,11 @@ if(MKLDNN_INCLUDE_DIR)
add_dependencies(unit-test ext_mkldnn) add_dependencies(unit-test ext_mkldnn)
endif() endif()
if(LLVM_INCLUDE_DIR)
target_link_libraries(unit-test ${LLVM_LINK_LIBS})
add_dependencies(unit-test ext_llvm)
endif()
target_link_libraries(unit-test ngraph libgtest pthread) target_link_libraries(unit-test ngraph libgtest pthread)
target_link_libraries(unit-test ${CMAKE_DL_LIBS}) target_link_libraries(unit-test ${CMAKE_DL_LIBS})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment