Skip to content
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
2 changes: 1 addition & 1 deletion .ci/scripts/wheel/test_cpp_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ def test_no_absolute_runtime_paths() -> None:

# Link every component this wheel offers, and report which ones those are so the test
# can check the result. Guarded individually because the set depends on the wheel.
foreach(_component threadpool kernels_optimized kernels_quantized)
foreach(_component threadpool kernels_optimized kernels_quantized etdump)
if(TARGET executorch::${_component})
target_link_libraries(component_consumer PRIVATE executorch::${_component})
# Report the library file, not just the target name: the two differ, and the test
Expand Down
25 changes: 24 additions & 1 deletion devtools/etdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,19 @@ add_custom_command(
COMMENT "Generating etdump headers"
)

# The profiler is reachable from both the Python extension and a standalone C++
# application, and each one linking it statically would keep its own tracing
# state. Build it shared for the wheel, where both are loaded into one process,
# and keep it static everywhere else so no other build changes.
if(EXECUTORCH_BUILD_SHARED)
set(_etdump_library_type SHARED)
else()
set(_etdump_library_type STATIC)
endif()

add_library(
etdump
${_etdump_library_type}
${_schema_outputs}
${CMAKE_CURRENT_SOURCE_DIR}/etdump_flatcc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/emitter.cpp
Expand All @@ -49,7 +60,10 @@ add_library(
${CMAKE_CURRENT_SOURCE_DIR}/data_sinks/file_data_sink.cpp
${CMAKE_CURRENT_SOURCE_DIR}/data_sinks/file_data_sink.h
)
target_link_libraries(etdump PUBLIC flatccrt)
# Private, not public: the flatbuffer runtime is an implementation detail and
# the wheel does not ship it, so exposing it would make the shipped header
# unlinkable.
target_link_libraries(etdump PRIVATE flatccrt)
# As with bundled_program, avoid the whole-archive of the `executorch` target so
# the primitive operator registrations are not duplicated alongside the copy
# already inside libexecutorch.so.
Expand All @@ -58,6 +72,15 @@ if(EXECUTORCH_BUILD_SHARED)
else()
target_link_libraries(etdump PRIVATE executorch)
endif()
if(EXECUTORCH_BUILD_SHARED)
set_target_properties(
etdump
PROPERTIES OUTPUT_NAME executorch_etdump
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
)
endif()

target_include_directories(
etdump
PUBLIC ${DEVTOOLS_INCLUDE_DIR}
Expand Down
21 changes: 21 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ def run(self):
"extension/named_data_map/",
"extension/tensor/",
"extension/threadpool/",
"devtools/etdump/",
]:
src_list = Path(include_dir).rglob("*.h")
for src in src_list:
Expand Down Expand Up @@ -1287,6 +1288,26 @@ def run(self): # noqa C901
dst=f"executorch/lib/libexecutorch.so.{get_runtime_soname_major()}",
dependent_cmake_flags=["EXECUTORCH_BUILD_SHARED"],
),
# Install the profiler next to it. Keeping it separate lets a C++
# application link it without pulling in the Python extension, which
# is where it was only reachable before.
BuiltFile(
src_dir="%CMAKE_CACHE_DIR%/devtools/etdump/",
src_name=(
f"libexecutorch_etdump.so.{get_runtime_soname_major()}.*"
),
dst=(
"executorch/lib/libexecutorch_etdump.so."
f"{get_runtime_soname_major()}"
),
# The target only exists when the developer tools are built, so
# packaging has to require that too or a shared build without them
# looks for a file that was never built.
dependent_cmake_flags=[
"EXECUTORCH_BUILD_SHARED",
"EXECUTORCH_BUILD_DEVTOOLS",
],
),
# Install the shared thread pool next to it. It is a separate
# library so that a process has one pool rather than one per
# component that uses it.
Expand Down
4 changes: 4 additions & 0 deletions tools/cmake/executorch-wheel-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ executorch_define_component(kernels_optimized executorch_kernels_optimized)
# runs them on plain CPU. A model delegated to XNNPACK does not need this,
# because that delegate claims the quantize and dequantize operators itself.
executorch_define_component(kernels_quantized executorch_kernels_quantized)
# The profiler. A C++ application could not record timing data from an installed
# package before, because the implementation shipped only inside the Python
# extension.
executorch_define_component(etdump executorch_etdump)

# A consumer that links the thread pool has to see the same switch a source
# build sets, or the parallel helpers in the runtime headers compile their
Expand Down
Loading