Skip to content

Commit c0260ec

Browse files
authored
Document the loader tag the runtime asks for on Linux (pytorch#21990)
Linking the runtime asks the linker for `DT_RUNPATH` rather than the older `DT_RPATH`. That choice is deliberate, because `DT_RPATH` outranks `LD_LIBRARY_PATH` and applies to a dependency's own dependencies, so it would take away a user's ability to point an instrumented or locally built library at their application. The setting is a property of the whole link rather than of a single library, so it also governs the search paths a consuming project adds for itself. That is worth stating, because an application relying on transitive `DT_RPATH` resolution would otherwise find the behaviour changed with no explanation and nothing to do about it. Document both halves and give the opt-out for an application that needs the older tag. Verified by building the documented snippet against an installed wheel: with the interface library listed after the runtime the program carries `DT_RPATH`, and without it the same program carries `DT_RUNPATH`.
1 parent 9017295 commit c0260ec

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎docs/source/using-executorch-cpp.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,24 @@ when the model is loaded.
278278
You should not need `LD_LIBRARY_PATH`. The shipped libraries record where their neighbours live, so
279279
they find each other once the program links against the installed package.
280280

281+
On Linux, linking the runtime asks the linker for `DT_RUNPATH` rather than the older `DT_RPATH`.
282+
That is deliberate: `DT_RPATH` is searched before `LD_LIBRARY_PATH` and applies to a dependency's
283+
own dependencies, so it would stop you pointing an instrumented or locally built library at your
284+
application. `DT_RUNPATH` leaves you that control.
285+
286+
The setting is a property of the whole link rather than of one library, so it applies to the search
287+
paths your own project adds as well. If your application relies on `DT_RPATH` being searched
288+
transitively, ask for it after the runtime:
289+
290+
```cmake
291+
add_library(prefer_rpath INTERFACE)
292+
target_link_options(prefer_rpath INTERFACE "LINKER:--disable-new-dtags")
293+
target_link_libraries(app PRIVATE executorch::runtime prefer_rpath)
294+
```
295+
296+
The order matters. A target's own link options are emitted before those of its dependencies, and the
297+
last of the two settings decides the tag for every entry in the link.
298+
281299
### Running on a GPU with the CUDA package
282300

283301
The CUDA build is a separate package. Releases cover CUDA 12.6, 13.0 and 13.2, so pick the index

0 commit comments

Comments
 (0)