Skip to content

Commit

Permalink
Build static extension_module lib for iOS demo apps (pytorch#2038)
Browse files Browse the repository at this point in the history
Summary:
Building the demo apps on iOS is broken after pytorch#2022 because it switches the `extension_module` library from a static to a shared one.  AFAIK, the latter requires code signing and it's failing on CI with the following error `Signing for "extension_module" requires a development team`

I'm not quite sure what would be the best way to address this, but keeping the library as a static one for iOS build seems like an easy workaround.

Pull Request resolved: pytorch#2038

Reviewed By: larryliu0820

Differential Revision: D54047521

Pulled By: huydhn

fbshipit-source-id: e752f29bb1fefd355525a40d586f89659119a625
  • Loading branch information
huydhn authored and facebook-github-bot committed Feb 22, 2024
1 parent f707590 commit 4853727
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/app-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- build/build_apple_frameworks.sh
- build/test_ios_ci.sh
- examples/demo-apps/**
- extension/module/**
workflow_dispatch:

concurrency:
Expand Down
5 changes: 4 additions & 1 deletion build/executorch-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ foreach(lib ${lib_list})
message("${lib} library is not found.
If needed rebuild with the proper options in CMakeLists.txt")
else()
if("${lib}" STREQUAL "extension_module")
if("${lib}" STREQUAL "extension_module" AND (NOT CMAKE_TOOLCHAIN_IOS))
add_library(${lib} SHARED IMPORTED)
else()
# Building a share library on iOS requires code signing, so it's
# easier to keep all libs as static when CMAKE_TOOLCHAIN_IOS is
# used
add_library(${lib} STATIC IMPORTED)
endif()
set_target_properties(
Expand Down
7 changes: 6 additions & 1 deletion extension/module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ if(NOT EXECUTORCH_ROOT)
endif()

list(TRANSFORM _extension_module__srcs PREPEND "${EXECUTORCH_ROOT}/")
add_library(extension_module SHARED ${_extension_module__srcs})
if(CMAKE_TOOLCHAIN_IOS)
# Building a share library on iOS requires code signing
add_library(extension_module STATIC ${_extension_module__srcs})
else()
add_library(extension_module SHARED ${_extension_module__srcs})
endif()
target_link_libraries(extension_module PRIVATE executorch)
target_include_directories(extension_module PUBLIC ${EXECUTORCH_ROOT}/..)
target_compile_options(extension_module PUBLIC -Wno-deprecated-declarations
Expand Down

0 comments on commit 4853727

Please sign in to comment.