You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6fd28cf
Browse filesBrowse the repository at this point in the historyBrowse files
Don't link libdl when cross-compiling (pytorch#20522)
### Summary
The top-level CMakeLists.txt links libdl into executorch_core when
EXECUTORCH_USE_DL is on (the default):
find_library(DL_LIBRARY_EXISTS NAMES dl)
if(DL_LIBRARY_EXISTS): target_link_libraries(executorch_core PRIVATE dl)
When cross-compiling for a bare-metal target (arm-none-eabi, esp,
zephyr), find_library still resolves the *host* libdl, so -ldl is linked
into executorch_core and propagates through the exported target
interface, failing the bare-metal executor-runner link ("cannot find
-ldl"). dladdr() (the only reason for the link) is compiled out on those
targets anyway (it's gated by the ET_USE_LIBDL macro, which the CMake
build never defines).
Two layers:
- Guard the link with `NOT CMAKE_CROSSCOMPILING` in CMakeLists.txt, so
any cross-compiled target is covered even without a preset.
- Set EXECUTORCH_USE_DL OFF explicitly in the arm_baremetal /
esp_baremetal / zephyr presets, documenting the intent for those
bare-metal builds.
### Test plan
Confirmed against the cortex-m FVP runner: with -ldl removed the
arm_executor_runner links and runs on Corstone-300.
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments