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 b2896ae
Browse filesBrowse the repository at this point in the historyBrowse files
Ship a pkg-config file for the runtime in the Linux and macOS wheels (pytorch#23169)
The wheel ships the runtime as shared libraries, with headers and a
CMake package. Build systems that read pkg-config instead, such as
Meson, look for `executorch.pc`, and the wheel has none. So those
projects need a full source build just to get that one file.
This adds `lib/pkgconfig/executorch.pc` to the Linux and macOS wheels:
- All paths come from the file's own location, so it works wherever pip
installed the wheel.
- It gives the same compile definitions as the CMake package's runtime.
That includes `ET_EVENT_TRACER_ENABLED` when the libraries are built
with the event tracer, and `ET_USE_THREADPOOL` plus the thread pool
library when the wheel ships the thread pool.
- It adds a runtime search path, so a program finds the libraries
without `LD_LIBRARY_PATH`. On Linux the path is its own `-Wl,-rpath`
argument, so Meson keeps it when it installs the program.
- Like the CMake `runtime` component, it does not include the kernels.
You name those on the link line.
Usage on Linux:
```
export PKG_CONFIG_PATH="$(python -c 'import executorch, pathlib; print(pathlib.Path(executorch.__path__[0]) / "lib" / "pkgconfig")')"
c++ -std=c++17 main.cpp $(pkg-config --cflags --libs executorch) \
-Wl,--push-state,--no-as-needed -lexecutorch_kernels_optimized -Wl,--pop-state -o app
```
On macOS, leave out the `--push-state`, `--no-as-needed` and
`--pop-state` flags. The macOS linker keeps the kernels library anyway,
and it rejects those flags.
Windows is left out because the Windows wheel does not ship the runtime
library.
The C++ usage page gets a pkg-config section with these commands and a
Meson example. A new wheel smoke test builds a program with the flags
pkg-config prints, runs a model, and compares the result with eager
PyTorch. It also checks that the pkg-config file and the CMake package
give the same compile definitions, so the two cannot drift apart. It
gets pkg-config from the `pkgconf` package on PyPI.
Test plan: built the macOS arm64 wheel from this branch and installed it
into a clean environment. The C++ SDK checks pass, including the new
one. The new check fails when the `.pc` file is removed, and it fails
when a compile definition is missing from it. With Meson on macOS and on
Linux x86_64, the documented recipe builds, installs and runs a model,
and the installed program still finds the libraries. A program that
calls `parallel_for` runs on many threads when built from these flags.
The Linux and CUDA wheels are covered by the wheel build jobs on this
PR.
0 commit comments