Skip to content
Draft
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
4 changes: 4 additions & 0 deletions .github/workflows/build-android-llm-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r27b
- name: Install root dependencies
run: yarn install --immutable
- name: Install Expo CLI
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-executorch/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../common")
set(LIBS_DIR "${CMAKE_SOURCE_DIR}/../third-party/android/libs")
set(TOKENIZERS_DIR "${CMAKE_SOURCE_DIR}/../third-party/include/executorch/extension/llm/tokenizers/include")
set(TOKENIZERS_DIR "${CMAKE_SOURCE_DIR}/../third-party/include")
set(INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../third-party/include")

# Treat third-party headers as system headers to suppress deprecation warnings
Expand Down
Binary file modified packages/react-native-executorch/android/libs/classes.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,106 @@ set(RN_VERSION_LINK_LIBRARIES

# ------- Executorch -------

# libexecutorch.so is the thin JNI wrapper (JNI_OnLoad + ASR entry points).
# It has a hard NEEDED dependency on libqnn_executorch_backend.so, so both must be bundled.
# All other runtime symbols are statically linked from executorch-static/*.a below.
add_library(executorch SHARED IMPORTED)

set_target_properties(executorch PROPERTIES
IMPORTED_LOCATION "${LIBS_DIR}/executorch/${ANDROID_ABI}/libexecutorch.so")


if(ANDROID_ABI STREQUAL "arm64-v8a")
target_compile_definitions(react-native-executorch PRIVATE ARCH_ARM64)
set(EXECUTORCH_STATIC_DIR "${LIBS_DIR}/executorch-static/${ANDROID_ABI}")

# ------- pthreadpool -------
add_library(pthreadpool SHARED IMPORTED)
# Libs that use static constructors for kernel/backend registration — must use --whole-archive
# so registrations are not stripped by the linker.
set(EXECUTORCH_WHOLE_ARCHIVE_LIBS
"${EXECUTORCH_STATIC_DIR}/liboptimized_native_cpu_ops_lib.a"
"${EXECUTORCH_STATIC_DIR}/libxnnpack_backend.a"
"${EXECUTORCH_STATIC_DIR}/libvulkan_backend.a"
"${EXECUTORCH_STATIC_DIR}/libexecutorch.a"
)

# Libs linked normally — only pull in symbols that are referenced.
# Do NOT include libs whose symbols are already compiled by this project
# (e.g. libextension_llm_runner, libextension_llm_sampler, libportable_kernels
# overlap with common/runner/*.cpp).
set(EXECUTORCH_STATIC_LIBS
"${EXECUTORCH_STATIC_DIR}/libexecutorch_core.a"
"${EXECUTORCH_STATIC_DIR}/libextension_module.a"
"${EXECUTORCH_STATIC_DIR}/libextension_tensor.a"
"${EXECUTORCH_STATIC_DIR}/libextension_threadpool.a"
"${EXECUTORCH_STATIC_DIR}/libextension_data_loader.a"
"${EXECUTORCH_STATIC_DIR}/libextension_runner_util.a"
"${EXECUTORCH_STATIC_DIR}/libtokenizers.a"
"${EXECUTORCH_STATIC_DIR}/libsentencepiece.a"
"${EXECUTORCH_STATIC_DIR}/libportable_kernels.a"
"${EXECUTORCH_STATIC_DIR}/liboptimized_kernels.a"
"${EXECUTORCH_STATIC_DIR}/libXNNPACK.a"
"${EXECUTORCH_STATIC_DIR}/libxnnpack-microkernels-prod.a"
"${EXECUTORCH_STATIC_DIR}/libre2.a"
"${EXECUTORCH_STATIC_DIR}/libcpublas.a"
"${EXECUTORCH_STATIC_DIR}/libeigen_blas.a"
"${EXECUTORCH_STATIC_DIR}/libpthreadpool.a"
"${EXECUTORCH_STATIC_DIR}/libextension_flat_tensor.a"
"${EXECUTORCH_STATIC_DIR}/libextension_named_data_map.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_internal_message.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_internal_globals.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_internal_log_sink_set.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_internal_format.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_internal_check_op.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_internal_conditions.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_internal_nullguard.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_internal_proto.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_globals.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_entry.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_sink.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_initialize.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_log_flags.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_str_format_internal.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_strings.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_strings_internal.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_base.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_raw_logging_internal.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_spinlock_wait.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_synchronization.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_symbolize.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_stacktrace.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_int128.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_time.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_time_zone.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_throw_delegate.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_status.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_statusor.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_malloc_internal.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_raw_hash_set.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_hash.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_kernel_timeout_internal.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_examine_stack.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_strerror.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_city.a"
"${EXECUTORCH_STATIC_DIR}/libabsl_low_level_hash.a"
)

set_target_properties(pthreadpool PROPERTIES
IMPORTED_LOCATION "${LIBS_DIR}/pthreadpool/${ANDROID_ABI}/libpthreadpool.so")
if(ANDROID_ABI STREQUAL "arm64-v8a")
target_compile_definitions(react-native-executorch PRIVATE ARCH_ARM64)

# ------- cpuinfo -------
add_library(cpuinfo SHARED IMPORTED)

set_target_properties(cpuinfo PROPERTIES
IMPORTED_LOCATION "${LIBS_DIR}/cpuinfo/${ANDROID_ABI}/libcpuinfo.so")

# ------- QNN backend -------
add_library(qnn_executorch_backend SHARED IMPORTED)
set_target_properties(qnn_executorch_backend PROPERTIES
IMPORTED_LOCATION "${LIBS_DIR}/executorch/${ANDROID_ABI}/libqnn_executorch_backend.so")

set(EXECUTORCH_LIBS
"pthreadpool"
"cpuinfo"
"qnn_executorch_backend"
)

# kleidiai is ARM-only (Kleidi AI acceleration library)
list(APPEND EXECUTORCH_STATIC_LIBS "${EXECUTORCH_STATIC_DIR}/libkleidiai.a")
endif()

# ------- OpenCV -------
Expand Down Expand Up @@ -103,7 +179,12 @@ target_link_libraries(
${OPENCV_LIBS}
${OPENCV_THIRD_PARTY_LIBS}
${PHONEMIS_LIBS}
-Wl,--whole-archive
${EXECUTORCH_WHOLE_ARCHIVE_LIBS}
-Wl,--no-whole-archive
${EXECUTORCH_STATIC_LIBS}
executorch
${EXECUTORCH_LIBS}
vulkan
z
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class ETInstaller(
init {
try {
System.loadLibrary("executorch")
try {
System.loadLibrary("qnn_executorch_backend")
} catch (e: UnsatisfiedLinkError) {
// QNN backend not available on this device (non-Qualcomm hardware)
}
System.loadLibrary("react-native-executorch")
val jsCallInvokerHolder = reactContext.jsCallInvokerHolder as CallInvokerHolderImpl
mHybridData = initHybrid(reactContext.javaScriptContextHolder!!.get(), jsCallInvokerHolder)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading