C++ includes require that the repo lives in a directory named exactly `executorch`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 581
Description
🐛 Describe the bug
The include paths in executorch look like #include <executorch/runtime/executor/method.h>. This means that the .h file needs to live under a subpath named exactly .../executorch/runtime/executor/.
The headers in the repo live in locations like <repo-root>/runtime/executor/method.h. To make the executorch/... include paths work, the build system currently assumes/requires that the repo lives in a directory named exactly executorch, and adds the include path <repo-root>/..: https://github.com/pytorch/executorch/blob/cb25809427ca32324b4b72c8376e0abb3e3d401f/CMakeLists.txt#L326-L327
But if the repo does not live in a directory named exactly executorch, this causes the includes to fail. Or, worse, leads to subtle breakages like https://github.com/pytorch/executorch/issues/6385 when there is a ../executorch directory, but it's not the directory we're building.
Versions
This issue exists in v0.4.0
Solution
The traditional solution for this is to have includes directories under the repo root that become part of the include path when depending on that library/component. E.g., <repo-root>/runtime/executor/includes/executorch/runtime/executor/method.h.
Another solution would be to build a symlink farm, constructing a tree under cmake-out that points to the underlying headers. But this doesn't work on systems without symlinks, like Windows; in those cases, we'd need extra build logic to copy the headers into a tree, and to re-copy them when the contents of the headers change.
Mitigation
Since we depend on the name of the repo, and can't get far if the name is wrong, the build system should assert that the directory is named exactly executorch. This would help save time for users, and could point to this task to track the real fix.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the include-path setup in CMakeLists.txt around lines 326–327 and review issue 6385 plus pull request 6480. Reproduce the build from a checkout whose directory is not named executorch, then determine whether the selected fix makes the executorch/... headers resolve without relying on an unrelated ../executorch directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100