Skip to content

Commit f250ee2

Browse files
shoumikhinfacebook-github-bot
authored andcommitted
Fix executorch_no_prim_ops_shared linkage. (#4185)
Summary: To be re-exported Differential Revision: D59536657
1 parent 4027c1b commit f250ee2

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

CMakeLists.txt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -485,24 +485,26 @@ if(MAX_KERNEL_NUM)
485485
)
486486
endif()
487487

488-
# shared version
489-
add_library(
490-
executorch_no_prim_ops_shared SHARED ${_executorch_no_prim_ops__srcs}
491-
)
492-
target_link_libraries(executorch_no_prim_ops_shared PRIVATE program_schema)
493-
if(DL_LIBRARY_EXISTS)
494-
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl) # For dladdr()
495-
endif()
496-
target_include_directories(
497-
executorch_no_prim_ops_shared PUBLIC ${_common_include_directories}
498-
)
499-
target_compile_options(
500-
executorch_no_prim_ops_shared PUBLIC ${_common_compile_options}
501-
)
502-
if(MAX_KERNEL_NUM)
503-
target_compile_definitions(
504-
executorch_no_prim_ops_shared PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
488+
if(EXECUTORCH_BUILD_PYBIND)
489+
# shared version
490+
add_library(
491+
executorch_no_prim_ops_shared SHARED ${_executorch_no_prim_ops__srcs}
492+
)
493+
target_link_libraries(executorch_no_prim_ops_shared PRIVATE program_schema)
494+
if(DL_LIBRARY_EXISTS)
495+
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl) # For dladdr()
496+
endif()
497+
target_include_directories(
498+
executorch_no_prim_ops_shared PUBLIC ${_common_include_directories}
499+
)
500+
target_compile_options(
501+
executorch_no_prim_ops_shared PUBLIC ${_common_compile_options}
505502
)
503+
if(MAX_KERNEL_NUM)
504+
target_compile_definitions(
505+
executorch_no_prim_ops_shared PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
506+
)
507+
endif()
506508
endif()
507509

508510
#
@@ -553,7 +555,7 @@ endif()
553555
# Install `executorch` library as well as `executorch-config.cmake` under
554556
# ${CMAKE_INSTALL_PREFIX}/
555557
install(
556-
TARGETS executorch executorch_no_prim_ops executorch_no_prim_ops_shared
558+
TARGETS executorch executorch_no_prim_ops
557559
DESTINATION lib
558560
INCLUDES
559561
DESTINATION ${_common_include_directories}

build/Codegen.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function(gen_custom_ops_aot_lib)
150150
include(${EXECUTORCH_ROOT}/build/Utils.cmake)
151151

152152
target_link_options_shared_lib(${GEN_LIB_NAME})
153-
if(APPLE)
153+
if(EXECUTORCH_BUILD_PYBIND)
154154
target_link_libraries(${GEN_LIB_NAME} PRIVATE executorch_no_prim_ops_shared)
155155
target_link_options(${GEN_LIB_NAME} PRIVATE -undefined dynamic_lookup)
156156
else()

build/executorch-config.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
cmake_minimum_required(VERSION 3.19)
1414

1515
set(_root "${CMAKE_CURRENT_LIST_DIR}/../..")
16-
set(required_lib_list executorch executorch_no_prim_ops
17-
executorch_no_prim_ops_shared portable_kernels
18-
)
16+
set(required_lib_list executorch executorch_no_prim_ops portable_kernels)
1917
foreach(lib ${required_lib_list})
2018
set(lib_var "LIB_${lib}")
2119
add_library(${lib} STATIC IMPORTED)

examples/portable/custom_ops/test_custom_ops.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ test_cmake_custom_op_2() {
103103

104104
EXT=$(get_shared_lib_ext)
105105
echo "Exporting ${model_name}.pte"
106-
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"
106+
${PYTHON_EXECUTABLE} -m "examples.portable.custom_ops.${model_name}" --so_library="cmake-out/examples/portable/custom_ops/libcustom_ops_aot_lib$EXT"
107107
# should save file custom_ops_2.pte
108108

109109
echo 'Running custom_ops_executor_runner'

0 commit comments

Comments
 (0)