-
Notifications
You must be signed in to change notification settings - Fork 989
Build and install shared library for consumers and backends #18560
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
base: main
Are you sure you want to change the base?
Changes from all commits
f20de5e
d34fd67
0cb7fce
444a4c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,3 +1,3 @@ | ||||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||||
| # All rights reserved. | ||||
| # Copyright 2024-2026 Arm Limited and/or its affiliates. | ||||
|
|
@@ -46,7 +46,6 @@ | |||
| # | ||||
|
|
||||
| cmake_minimum_required(VERSION 3.24) | ||||
| project(executorch) | ||||
|
|
||||
| set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) | ||||
|
|
||||
|
|
@@ -87,6 +86,10 @@ | |||
| ) | ||||
| endif() | ||||
|
|
||||
| project(executorch | ||||
| VERSION "${ET_VERSION_MAJOR}.${ET_VERSION_MINOR}.${ET_VERSION_PATCH}" | ||||
| ) | ||||
|
|
||||
| message( | ||||
| STATUS | ||||
| "ExecuTorch version: ${ET_VERSION_MAJOR}.${ET_VERSION_MINOR}.${ET_VERSION_PATCH}" | ||||
|
|
@@ -160,6 +163,10 @@ | |||
| load_build_preset() | ||||
| include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake) | ||||
|
|
||||
| if(EXECUTORCH_BUILD_SHARED) | ||||
| set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||||
| endif() | ||||
|
|
||||
| # Enable ccache if available | ||||
| find_program(CCACHE_PROGRAM ccache) | ||||
| if(CCACHE_PROGRAM) | ||||
|
|
@@ -1158,6 +1165,48 @@ | |||
| list(APPEND _executorch_backends vgf_backend) | ||||
| endif() | ||||
|
|
||||
| # Consolidated shared library: bundles executorch_core plus commonly used | ||||
| # extensions into a single libexecutorch.so. | ||||
| if(EXECUTORCH_BUILD_SHARED) | ||||
| executorch_add_shared_library(executorch_shared) | ||||
| set_target_properties( | ||||
| executorch_shared | ||||
| PROPERTIES OUTPUT_NAME executorch | ||||
| EXPORT_NAME executorch | ||||
|
||||
| EXPORT_NAME executorch |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
|
|
||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
| #include <functional> | ||
| #include <memory> | ||
| #include <optional> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
|
|
||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
| #include <memory> | ||
| #include <stdio.h> | ||
| #include <string> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -106,6 +106,12 @@ install( | |||||
| DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/kernels/portable/ | ||||||
| ) | ||||||
|
|
||||||
| if(EXECUTORCH_BUILD_SHARED) | ||||||
| executorch_add_shared_library( | ||||||
| executorch_portable_ops portable_ops_lib portable_kernels executorch_shared | ||||||
|
||||||
| executorch_portable_ops portable_ops_lib portable_kernels executorch_shared | |
| executorch_portable_ops portable_ops_lib portable_kernels |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -157,3 +157,10 @@ install( | |||||
| PUBLIC_HEADER | ||||||
| DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/kernels/quantized/ | ||||||
| ) | ||||||
|
|
||||||
| if(EXECUTORCH_BUILD_SHARED) | ||||||
| executorch_add_shared_library( | ||||||
| executorch_quantized_ops quantized_ops_lib quantized_kernels | ||||||
| executorch_shared | ||||||
|
||||||
| executorch_shared | |
| $<TARGET_NAME_IF_EXISTS:executorch_shared> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| prefix=@CMAKE_INSTALL_PREFIX@ | ||
| exec_prefix=${prefix} | ||
| libdir=@CMAKE_INSTALL_FULL_LIBDIR@ | ||
| includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ | ||
|
|
||
| Name: ExecuTorch | ||
| Description: On-device AI framework for PyTorch models | ||
| Version: @PROJECT_VERSION@ | ||
| Cflags: -I${includedir} -I${includedir}/executorch/runtime/core/portable_type -I${includedir}/executorch/runtime/core/portable_type/c10 -DC10_USING_CUSTOM_GENERATED_MACROS | ||
| Libs: -L${libdir} -lexecutorch | ||
|
tomeuv marked this conversation as resolved.
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
executorch_sharedis created after the portable/quantized kernel subdirectories are added, but those subdirectories attempt to link againstexecutorch_sharedwhenEXECUTORCH_BUILD_SHAREDis enabled. Because the target doesn’t exist yet at that point, those links won’t bind to the intended target.Consider creating
executorch_sharedearlier (right afterexecutorch/executorch_coreare defined) and then adding the extension/kernel WHOLE_ARCHIVE dependencies later, so subdirectories can safely reference the target.