Skip to content

Some targets install to ${CMAKE_BINARY_DIR}/lib, breaking find_package(executorch) from an install prefix #20709

Description

@corey-cole

🐛 Describe the bug

Four CMakeLists.txt install their targets to DESTINATION ${CMAKE_BINARY_DIR}/lib
(the build directory) instead of ${CMAKE_INSTALL_LIBDIR} like every other
target. As a result, on cmake --install:

  1. the target's static library is not placed into the install prefix, and
  2. the exported ExecuTorchTargets-release.cmake bakes an absolute build-tree
    path
    into IMPORTED_LOCATION_RELEASE.

Any downstream find_package(executorch CONFIG REQUIRED) against the installed
tree then fails at configure time (or the build tree cannot be deleted/relocated),
because the imported target points at a file that isn't in the prefix.

Affected targets / files

File Target
extension/evalue_util/CMakeLists.txt extension_evalue_util
devtools/etdump/CMakeLists.txt etdump
devtools/bundled_program/CMakeLists.txt bundled_program
third-party/CMakeLists.txt flatccrt

All 55 other installed targets in the tree already use ${CMAKE_INSTALL_LIBDIR}.

Reproduction

Configure + build + install with a prefix distinct from the build dir:

cmake -B /tmp/et-build -S <executorch> -G Ninja --preset linux \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/tmp/et-install \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DEXECUTORCH_ENABLE_LOGGING=ON \
  -DEXECUTORCH_BUILD_XNNPACK=ON \
  -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
  -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
  -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON
cmake --build /tmp/et-build -j"$(nproc)"
cmake --install /tmp/et-build --prefix /tmp/et-install

Then observe the leak and the missing library:

# absolute build-tree path baked into the exported config:
grep -n 'et-build' /tmp/et-install/lib/cmake/ExecuTorch/ExecuTorchTargets-release.cmake
#   IMPORTED_LOCATION_RELEASE "/tmp/et-build/lib/libextension_evalue_util.a"

# ...and the archive is absent from the install prefix:
ls /tmp/et-install/lib/libextension_evalue_util.a   # No such file or directory

Finally, a trivial consumer fails at find_package time:

cmake_minimum_required(VERSION 3.24)
project(probe LANGUAGES CXX)
find_package(executorch CONFIG REQUIRED)   # <-- fails here
add_library(probe SHARED probe.cpp)
target_link_libraries(probe PRIVATE executorch)
CMake Error at .../ExecuTorchTargets.cmake:569 (message):
  The imported target "extension_evalue_util" references the file
     "/tmp/et-build/lib/libextension_evalue_util.a"
  but this file does not exist.

Expected vs. actual

  • Expected: installed targets land in <prefix>/lib and the exported config
    references them via ${_IMPORT_PREFIX}/lib/..., so the install tree is
    relocatable and find_package works from any location.
  • Actual: the four targets above install into the build dir and their imported
    locations are absolute build-tree paths.

Versions

Collecting environment information...
PyTorch version: 2.12.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04.4 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version: Could not collect
CMake version: version 3.31.10
Libc version: glibc-2.39

Python version: 3.12.3 (main, Mar 23 2026, 19:04:32) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.17.0-35-generic-x86_64-with-glibc2.39
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: GenuineIntel
Model name: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
CPU family: 6
Model: 140
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Stepping: 1
CPU(s) scaling MHz: 21%
CPU max MHz: 4800.0000
CPU min MHz: 400.0000
BogoMIPS: 5990.40
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear ibt flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 192 KiB (4 instances)
L1i cache: 128 KiB (4 instances)
L2 cache: 5 MiB (4 instances)
L3 cache: 12 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-7
Vulnerability Gather data sampling: Vulnerable
Vulnerability Ghostwrite: Not affected
Vulnerability Indirect target selection: Mitigation; Aligned branch/return thunks
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Old microcode: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds: Not affected
Vulnerability Tsa: Not affected
Vulnerability Tsx async abort: Not affected
Vulnerability Vmscape: Not affected

Versions of relevant libraries:
[pip3] executorch==1.3.1+e2f18eb
[pip3] numpy==2.5.0
[pip3] pytorch_tokenizers==1.3.0
[pip3] torch==2.12.0+cpu
[pip3] torchao==0.17.0+git02105d4
[pip3] torchaudio==2.11.0+cpu
[pip3] torchdata==0.11.0+cpu
[pip3] torchsr==1.0.4
[pip3] torchtune==0.0.0
[pip3] torchvision==0.27.0+cpu
[conda] Could not collect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions