Skip to content

Commit ed0c7ed

Browse files
committed
Update
[ghstack-poisoned]
1 parent 6b2c166 commit ed0c7ed

4 files changed

Lines changed: 24 additions & 23 deletions

File tree

.ci/scripts/test_cpp_sdk_wheel.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ cat > main.cpp <<'CPP'
128128
#include <executorch/extension/flat_tensor/flat_tensor_data_map.h>
129129
#include <executorch/extension/named_data_map/merged_data_map.h>
130130
#include <executorch/extension/module/module.h>
131-
#include <executorch/extension/named_data_map/merged_data_map.h>
132131
#include <executorch/extension/tensor/tensor.h>
133132
#include <executorch/runtime/backend/interface.h>
134133
#include <executorch/runtime/platform/runtime.h>

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,10 +1441,6 @@ if(EXECUTORCH_BUILD_SHARED AND _executorch_kernels)
14411441
target_link_libraries(
14421442
executorch_kernels_shared PRIVATE executorch_shared ${_executorch_kernels}
14431443
)
1444-
# No EXPORT set: the .so is shipped by setup.py (BuiltSharedLib file copy) and
1445-
# found via find_library in executorch-wheel-config.cmake, so it must not also
1446-
# join ExecuTorchTargets (that double-registers the target).
1447-
install(TARGETS executorch_kernels_shared DESTINATION ${CMAKE_INSTALL_LIBDIR})
14481444
endif()
14491445

14501446
install(TARGETS executorch_backends executorch_extensions executorch_kernels

setup.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -542,14 +542,14 @@ def inplace_dir(self, installer: "InstallerBuildExt") -> Path:
542542

543543

544544
class BuiltSharedLib(BuiltFile):
545-
"""Installs a SONAME-versioned shared library plus its symlink chain.
546-
547-
A normal ``BuiltFile`` copies one file. A shared library like
548-
``libexecutorch.so.1.4.0`` also needs the loader-visible SONAME symlink
549-
(``libexecutorch.so.1``) and the developer symlink (``libexecutorch.so``),
550-
or a consumer that links ``-lexecutorch`` fails at runtime because the
551-
SONAME recorded in dependents cannot be found. This recreates that chain in
552-
the wheel, matching a standard ``cmake --install`` layout.
545+
"""Installs a SONAME-versioned shared library.
546+
547+
A normal ``BuiltFile`` copies one file. For a shared library like
548+
``libexecutorch.so.1.4.0`` the wheel ships only the loader-visible SONAME
549+
file (e.g. ``libexecutorch.so.1``), which is what dependents record via
550+
DT_NEEDED. pip does not preserve symlinks, so a dev-name link
551+
(``libexecutorch.so``) would become a second full copy; consumers link
552+
through the CMake package's imported targets (full path), so it is omitted.
553553
"""
554554

555555
def __init__(

tools/cmake/executorch-wheel-config.cmake

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ set(_executorch_sdk_libdir "${_executorch_sdk_root}/lib")
142142
# against libexecutorch.so at load), then force-loaded so its static-init
143143
# registration runs.
144144
set(EXECUTORCH_SDK_FOUND OFF)
145-
find_library(
146-
_executorch_shared_LIBRARY
147-
NAMES executorch libexecutorch.so.1
148-
PATHS "${_executorch_sdk_libdir}"
149-
NO_DEFAULT_PATH
145+
# Discover the versioned SONAME (libexecutorch.so.<major>) rather than
146+
# hardcoding a major, so this keeps working across ABI bumps. The wheel ships
147+
# only the real SONAME file (no dev-name symlink), so find_library(NAMES
148+
# executorch) alone would miss it.
149+
file(GLOB _executorch_shared_candidates
150+
"${_executorch_sdk_libdir}/libexecutorch.so.*"
150151
)
152+
if(_executorch_shared_candidates)
153+
list(GET _executorch_shared_candidates 0 _executorch_shared_LIBRARY)
154+
endif()
151155
if(_executorch_shared_LIBRARY)
152156
set(EXECUTORCH_SDK_FOUND ON)
153157
if(NOT TARGET executorch::runtime)
@@ -184,12 +188,14 @@ if(_executorch_shared_LIBRARY)
184188
# links executorch::kernels for a full CPU operator set (optimized + portable
185189
# fallback). Defined only when the kernels .so is present. Loaded purely for
186190
# its op-registration static initializers, so force it to stay linked.
187-
find_library(
188-
_executorch_kernels_LIBRARY
189-
NAMES executorch_kernels libexecutorch_kernels.so.1
190-
PATHS "${_executorch_sdk_libdir}"
191-
NO_DEFAULT_PATH
191+
# Discover the versioned SONAME rather than hardcoding a major (see the
192+
# runtime lookup above).
193+
file(GLOB _executorch_kernels_candidates
194+
"${_executorch_sdk_libdir}/libexecutorch_kernels.so.*"
192195
)
196+
if(_executorch_kernels_candidates)
197+
list(GET _executorch_kernels_candidates 0 _executorch_kernels_LIBRARY)
198+
endif()
193199
if(_executorch_kernels_LIBRARY AND NOT TARGET executorch::kernels)
194200
add_library(executorch::kernels SHARED IMPORTED)
195201
set_target_properties(

0 commit comments

Comments
 (0)