Skip to content

Fix executorch_no_prim_ops_shared linkage. #4185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,24 +485,26 @@ if(MAX_KERNEL_NUM)
)
endif()

# shared version
add_library(
executorch_no_prim_ops_shared SHARED ${_executorch_no_prim_ops__srcs}
)
target_link_libraries(executorch_no_prim_ops_shared PRIVATE program_schema)
if(DL_LIBRARY_EXISTS)
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl) # For dladdr()
endif()
target_include_directories(
executorch_no_prim_ops_shared PUBLIC ${_common_include_directories}
)
target_compile_options(
executorch_no_prim_ops_shared PUBLIC ${_common_compile_options}
)
if(MAX_KERNEL_NUM)
target_compile_definitions(
executorch_no_prim_ops_shared PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
if(EXECUTORCH_BUILD_PYBIND)
# shared version
add_library(
executorch_no_prim_ops_shared SHARED ${_executorch_no_prim_ops__srcs}
)
target_link_libraries(executorch_no_prim_ops_shared PRIVATE program_schema)
if(DL_LIBRARY_EXISTS)
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl) # For dladdr()
endif()
target_include_directories(
executorch_no_prim_ops_shared PUBLIC ${_common_include_directories}
)
target_compile_options(
executorch_no_prim_ops_shared PUBLIC ${_common_compile_options}
)
if(MAX_KERNEL_NUM)
target_compile_definitions(
executorch_no_prim_ops_shared PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
)
endif()
endif()

#
Expand Down Expand Up @@ -553,7 +555,7 @@ endif()
# Install `executorch` library as well as `executorch-config.cmake` under
# ${CMAKE_INSTALL_PREFIX}/
install(
TARGETS executorch executorch_no_prim_ops executorch_no_prim_ops_shared
TARGETS executorch executorch_no_prim_ops
DESTINATION lib
INCLUDES
DESTINATION ${_common_include_directories}
Expand Down
2 changes: 1 addition & 1 deletion build/Codegen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function(gen_custom_ops_aot_lib)
include(${EXECUTORCH_ROOT}/build/Utils.cmake)

target_link_options_shared_lib(${GEN_LIB_NAME})
if(APPLE)
if(EXECUTORCH_BUILD_PYBIND)
target_link_libraries(${GEN_LIB_NAME} PRIVATE executorch_no_prim_ops_shared)
target_link_options(${GEN_LIB_NAME} PRIVATE -undefined dynamic_lookup)
else()
Expand Down
4 changes: 1 addition & 3 deletions build/executorch-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
cmake_minimum_required(VERSION 3.19)

set(_root "${CMAKE_CURRENT_LIST_DIR}/../..")
set(required_lib_list executorch executorch_no_prim_ops
executorch_no_prim_ops_shared portable_kernels
)
set(required_lib_list executorch executorch_no_prim_ops portable_kernels)
foreach(lib ${required_lib_list})
set(lib_var "LIB_${lib}")
add_library(${lib} STATIC IMPORTED)
Expand Down
2 changes: 1 addition & 1 deletion examples/portable/custom_ops/test_custom_ops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ test_cmake_custom_op_2() {

EXT=$(get_shared_lib_ext)
echo "Exporting ${model_name}.pte"
DYLD_LIBRARY_PATH="cmake-out/lib" ${PYTHON_EXECUTABLE} -m "examples.portable.custom_ops.${model_name}" --so_library="cmake-out/examples/portable/custom_ops/libcustom_ops_aot_lib$EXT"
${PYTHON_EXECUTABLE} -m "examples.portable.custom_ops.${model_name}" --so_library="cmake-out/examples/portable/custom_ops/libcustom_ops_aot_lib$EXT"
# should save file custom_ops_2.pte

echo 'Running custom_ops_executor_runner'
Expand Down
Loading