Skip to content

Commit 8cb6ed5

Browse files
committed
Fix
1 parent 7da8f17 commit 8cb6ed5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

extension/pybindings/portable_lib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
# wouldn't preserve the static type annotations.
5252
#
5353
# Note that all of these are experimental, and subject to change without notice.
54+
55+
# Set dlopen flags to RTLD_GLOBAL to ensure that the symbols in _portable_lib can
56+
# be found by another shared library (for example, in AOTI where we want to load
57+
# an AOTI compiled .so file with needed symbols defined in _portable_lib).
58+
prev = sys.getdlopenflags()
59+
sys.setdlopenflags(prev | os.RTLD_GLOBAL)
5460
from executorch.extension.pybindings._portable_lib import ( # noqa: F401
5561
# Disable "imported but unused" (F401) checks.
5662
_create_profile_block, # noqa: F401
@@ -73,6 +79,7 @@
7379
MethodMeta, # noqa: F401
7480
Verification, # noqa: F401
7581
)
82+
sys.setdlopenflags(prev)
7683

7784
# Clean up so that `dir(portable_lib)` is the same as `dir(_portable_lib)`
7885
# (apart from some __dunder__ names).

0 commit comments

Comments
 (0)