Skip to content

Commit 2da895b

Browse files
authored
Simplify Out-Of-Process JIT case (#940)
* [jit] Self-contain the OOP-JIT runtime in CppInterOp's distribution. Out-of-process JIT needs `liborc_rt*.a` (fed to `IncrementalExecutorBuilder::OrcRuntimePath`) and `llvm-jitlink-executor`. Upstream's auto-discovery validates the runtime path against `parent_path(D.Dir)`, which only matches when `libclangCppInterOp.so` lives inside the LLVM install tree -- test binaries under `<build>/unittests/...` trip the safety check. Bundle both artifacts under `<libdir>/cppinterop-rt/` via a new `FindLLVMOrcRuntime` cmake module and configure_file/install rules, and hand the paths to `IncrementalExecutorBuilder` directly with a no-op `UpdateOrcRuntimePathCB`. The locations are baked at build time (`CPPINTEROP_RUNTIME_{BUILD,INSTALL}_DIR`); when the runtime parts are missing the OOP path falls back to in-process JIT with a logged warning. Relocatable-install support (sysadmin-overridable runtime dir, `dladdr`-based self-DSO probe) is a separate follow-up PR layered on top of this baked probe. Drops the now-unused `LLVM_BUILT_WITH_OOP_JIT` cmake option and the `LLVM_BINARY_LIB_DIR` define (its only consumer was the old hand-built executor path); README, InstallationAndUsage.rst, and DevelopersDocumentation.rst are updated to describe auto-detection. * [ci] Build the bundled OOP-JIT runtime in non-cling LLVM>=22 caches. Activates the bundling design from `[jit] Self-contain the OOP-JIT runtime in CppInterOp's distribution.`: - `Build_LLVM/action.yml`: for non-cling rows with `clang-runtime >= 22`, set `LLVM_ENABLE_PROJECTS="clang;compiler-rt"` and ninja `llvm-jitlink-executor` plus every `orc_rt*` target ninja exposes (other compiler-rt components are turned off so build cost is bounded to the ORC runtime). The matrix `llvm_enable_projects` override is no longer load-bearing: the projects list is now picked entirely from `NEED_OOP`. - `Build_and_Test_CppInterOp/action.yml`: drop `-DLLVM_BUILT_WITH_OOP_JIT`; CppInterOp auto-detects via `find_package(LLVMOrcRuntime)`. The Valgrind suppression file selection moves from `matrix.oop-jit` to `clang-runtime >= 22`, matching the auto-detect condition that now drives OOP at runtime. Adds two post-build assertions: (a) the typed-test fixtures registered match the source-side gate -- the `OutOfProcessJIT` fixture must NOT be present on `clang-runtime <= 21`, catching accidental regressions of the `LLVM_VERSION_MAJOR > 21` guard in `unittests/CppInterOp/Utils.h`; (b) an install-layout smoke test that installs into a scratch prefix and asserts `<libdir>/cppinterop-rt/liborc_rt.a` is shipped and `llvm-jitlink-executor` retains its executable bit, catching install(FILES/PROGRAMS) destination/mode regressions. - `main.yml`: drop the `-oop` cache-key suffix and the `oop-jit` matrix dimension along with its rows. `osx26-arm-clang-llvm22-oop` was a duplicate of `osx26-arm-clang-llvm22` once the OOP knob retired; `ubu24-x86-gcc12-llvm22-oop-vg` was unique only for its Valgrind axis and is renamed to `ubu24-x86-gcc12-llvm22-vg`. OOP and in-process rows on the same axes now share a cache slot; existing entries match the new key but need a refresh to gain the runtime parts -- transitional rows fall back to in-process JIT with a logged warning.
1 parent cbef716 commit 2da895b

11 files changed

Lines changed: 271 additions & 78 deletions

File tree

.github/actions/Build_LLVM/action.yml

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
mkdir build
2424
if [[ "${cling_on}" == "ON" ]]; then
2525
cd build
26-
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects || 'clang' }}" \
26+
cmake -DLLVM_ENABLE_PROJECTS="clang" \
2727
-DLLVM_EXTERNAL_PROJECTS=cling \
2828
-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \
2929
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build || 'host;NVPTX' }}" \
@@ -39,8 +39,32 @@ runs:
3939
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
4040
ninja clingInterpreter -j ${{ env.ncpus }}
4141
else
42+
# Non-cling, LLVM >= 22: bundle the OOP-JIT runtime into the
43+
# cache. compiler-rt is enabled with everything except the
44+
# ORC runtime turned off so the build stays cheap.
45+
NEED_OOP=0
46+
if [[ "${{ matrix.clang-runtime }}" -ge 22 ]]; then
47+
NEED_OOP=1
48+
fi
49+
if [[ "${NEED_OOP}" == "1" ]]; then
50+
PROJECTS="clang;compiler-rt"
51+
COMPILER_RT_FLAGS=(
52+
-DCOMPILER_RT_BUILD_BUILTINS=OFF
53+
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF
54+
-DCOMPILER_RT_BUILD_PROFILE=OFF
55+
-DCOMPILER_RT_BUILD_MEMPROF=OFF
56+
-DCOMPILER_RT_BUILD_SANITIZERS=OFF
57+
-DCOMPILER_RT_BUILD_XRAY=OFF
58+
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF
59+
-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF
60+
)
61+
else
62+
PROJECTS="clang"
63+
COMPILER_RT_FLAGS=()
64+
fi
65+
4266
cd build
43-
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects || 'clang' }}" \
67+
cmake -DLLVM_ENABLE_PROJECTS="${PROJECTS}" \
4468
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build || 'host;NVPTX' }}" \
4569
-DCMAKE_BUILD_TYPE=Release \
4670
-DLLVM_ENABLE_ASSERTIONS=ON \
@@ -53,15 +77,17 @@ runs:
5377
-DLLVM_USE_SANITIZER="${{ matrix.sanitizer }}" \
5478
-DLLVM_INCLUDE_EXAMPLES=OFF \
5579
-DLLVM_INCLUDE_TESTS=OFF \
80+
"${COMPILER_RT_FLAGS[@]}" \
5681
../llvm
5782
ninja clang clangInterpreter clangStaticAnalyzerCore
58-
if [[ "${{ matrix.oop-jit }}" == "On" ]]; then
59-
if [[ "${{ matrix.os }}" == macos* ]]; then
60-
SUFFIX="_osx"
61-
elif [[ "${{ matrix.os }}" == ubuntu* ]]; then
62-
SUFFIX="-x86_64"
63-
fi
64-
ninja llvm-jitlink-executor orc_rt${SUFFIX} -j ${{ env.ncpus }}
83+
if [[ "${NEED_OOP}" == "1" ]]; then
84+
# orc_rt's per-target ninja target name varies; find it by
85+
# asking ninja for everything matching `orc_rt*`. Building
86+
# the executor unconditionally is safe -- it's always a
87+
# valid target when compiler-rt is in the build.
88+
OOP_TARGETS=$(ninja -t targets all 2>/dev/null | \
89+
awk -F: '/^orc_rt[^:]*:/{print $1}' | sort -u | tr '\n' ' ')
90+
ninja llvm-jitlink-executor ${OOP_TARGETS} -j ${{ env.ncpus }}
6591
fi
6692
cd ./tools/
6793
rm -rf $(find . -maxdepth 1 ! -name "clang" ! -name ".")
@@ -110,7 +136,7 @@ runs:
110136
if ( "${{ matrix.cling }}" -imatch "On" )
111137
{
112138
cd build
113-
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects || 'clang' }}" `
139+
cmake -DLLVM_ENABLE_PROJECTS="clang" `
114140
-DLLVM_EXTERNAL_PROJECTS=cling `
115141
-DLLVM_EXTERNAL_CLING_SOURCE_DIR="$env:CLING_DIR" `
116142
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build || 'host;NVPTX' }}" `
@@ -129,7 +155,7 @@ runs:
129155
{
130156
cd build
131157
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
132-
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects || 'clang' }}" `
158+
cmake -DLLVM_ENABLE_PROJECTS="clang" `
133159
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build || 'host;NVPTX' }}" `
134160
-DCMAKE_BUILD_TYPE=Release `
135161
-DLLVM_ENABLE_ASSERTIONS=ON `

.github/actions/Build_and_Test_CppInterOp/action.yml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ runs:
5454
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
5555
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
5656
-DLLVM_ENABLE_WERROR=On \
57-
-DLLVM_BUILT_WITH_OOP_JIT=${{ matrix.oop-jit }} \
5857
../
5958
fi
6059
docs_on=$(echo "${{ matrix.documentation }}" | tr '[:lower:]' '[:upper:]')
@@ -63,10 +62,57 @@ runs:
6362
cmake --build . --target sphinx-cppinterop --parallel ${{ env.ncpus }}
6463
else
6564
cmake --build . --target check-cppinterop --parallel ${{ env.ncpus }}
65+
# Verify the source-side `LLVM_VERSION_MAJOR > 21 &&
66+
# !defined(_WIN32)` gate in unittests/CppInterOp/Utils.h:
67+
# `InProcessJIT` always registers; `OutOfProcessJIT` must
68+
# not register on clang-runtime <= 21. Missing OOP fixture
69+
# on clang-runtime >= 22 is currently allowed (transitional;
70+
# tighten to required once every cache row is rebuilt with
71+
# compiler-rt).
72+
TESTS_BIN=unittests/CppInterOp/bin/${{ env.BUILD_TYPE }}/CppInterOpTests
73+
if [[ -x "${TESTS_BIN}" ]]; then
74+
FIXTURES=$("${TESTS_BIN}" --gtest_list_tests 2>/dev/null | \
75+
grep '^CppInterOpTest/' || true)
76+
if ! echo "${FIXTURES}" | grep -q '^CppInterOpTest/InProcessJIT'; then
77+
echo "FAIL: InProcessJIT fixture missing -- typed-test setup broken"
78+
exit 1
79+
fi
80+
if [[ "${{ matrix.clang-runtime }}" -lt 22 ]]; then
81+
if echo "${FIXTURES}" | grep -q '^CppInterOpTest/OutOfProcessJIT'; then
82+
echo "FAIL: OutOfProcessJIT fixture registered on clang-runtime=${{ matrix.clang-runtime }}; LLVM_VERSION_MAJOR>21 source gate broken"
83+
exit 1
84+
fi
85+
fi
86+
fi
87+
# Install-layout smoke test: install into a scratch prefix
88+
# and assert the bundled runtime parts ship to
89+
# `<libdir>/cppinterop-rt/` with the right modes. Catches
90+
# install(FILES/PROGRAMS) destination/exec-bit regressions
91+
# the in-tree path doesn't see.
92+
INSTALL_DIR="${RUNNER_TEMP:-/tmp}/cppinterop-install-check"
93+
rm -rf "${INSTALL_DIR}"
94+
cmake --install . --prefix "${INSTALL_DIR}" >/dev/null
95+
ls "${INSTALL_DIR}"/lib/libclangCppInterOp.* >/dev/null 2>&1 || \
96+
{ echo "FAIL: libclangCppInterOp not installed"; exit 1; }
97+
if [[ -d "${INSTALL_DIR}/lib/cppinterop-rt" ]]; then
98+
test -f "${INSTALL_DIR}/lib/cppinterop-rt/liborc_rt.a" || \
99+
{ echo "FAIL: liborc_rt.a missing from install"; exit 1; }
100+
test -x "${INSTALL_DIR}/lib/cppinterop-rt/llvm-jitlink-executor" || \
101+
{ echo "FAIL: llvm-jitlink-executor missing or not executable"; exit 1; }
102+
echo "OK: bundled OOP runtime installed under lib/cppinterop-rt/"
103+
elif [[ "${{ matrix.clang-runtime }}" -lt 22 ]]; then
104+
echo "OK: lib/cppinterop-rt/ absent, expected for clang-runtime <= 21"
105+
else
106+
echo "INFO: lib/cppinterop-rt/ absent on clang-runtime=${{ matrix.clang-runtime }} (transitional cache row without compiler-rt)"
107+
fi
66108
os="${{ matrix.os }}"
67109
if [[ "${os}" != "macos"* && "${{ matrix.Valgrind }}" == "On" ]]; then
68110
CLANG_VERSION="${{ matrix.clang-runtime }}"
69-
if [[ "${{ matrix.oop-jit }}" == "On" ]]; then
111+
if [[ "${CLANG_VERSION}" -ge 22 ]]; then
112+
# OOP-JIT runs by default on LLVM 22+ where the bundled
113+
# runtime is available; OOP introduces extra valgrind
114+
# noise (fork/exec, pipes) that the suppression file
115+
# filters out.
70116
SUPPRESSION_FILE="../etc/clang${CLANG_VERSION}-valgrind.supp"
71117
valgrind --show-error-list=yes --track-origins=yes --error-exitcode=1 \
72118
--show-leak-kinds=definite,possible \

.github/workflows/main.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ jobs:
7474
matrix:
7575
# Rows omit fields that match these defaults (applied in
7676
# Build_LLVM and in the setup-python step):
77-
# llvm_enable_projects: "clang"
7877
# llvm_targets_to_build: "host;NVPTX"
7978
# python-version: '3.14'
8079
include:
@@ -91,24 +90,15 @@ jobs:
9190
compiler: gcc-12
9291
clang-runtime: '22'
9392
coverage: true
94-
- name: ubu24-x86-gcc12-llvm22-oop-vg
93+
- name: ubu24-x86-gcc12-llvm22-vg
9594
os: ubuntu-24.04
9695
compiler: gcc-12
9796
clang-runtime: '22'
98-
llvm_enable_projects: "clang;compiler-rt"
99-
oop-jit: On
10097
Valgrind: On
10198
# MacOS Arm
10299
- { name: osx26-arm-clang-llvm22, os: macos-26, compiler: clang, clang-runtime: '22', llvm_targets_to_build: host }
103100
- { name: osx26-arm-clang-llvm21-cppyy, os: macos-26, compiler: clang, clang-runtime: '21', cppyy: On, llvm_targets_to_build: host }
104101
- { name: osx26-arm-clang-cling-llvm20-cppyy, os: macos-26, compiler: clang, clang-runtime: '20', cling: On, cppyy: On, root-llvm-tag: *root_llvm_tag }
105-
- name: osx26-arm-clang-llvm22-oop
106-
os: macos-26
107-
compiler: clang
108-
clang-runtime: '22'
109-
llvm_enable_projects: "clang;compiler-rt"
110-
llvm_targets_to_build: host
111-
oop-jit: On
112102
# MacOS X86
113103
- { name: osx26-x86-clang-llvm21-cppyy, os: macos-26-intel, compiler: clang, clang-runtime: '21', cppyy: On, llvm_targets_to_build: host }
114104
- { name: osx26-x86-clang-cling-llvm20-cppyy, os: macos-26-intel, compiler: clang, clang-runtime: '20', cling: On, cppyy: On, root-llvm-tag: *root_llvm_tag }
@@ -136,7 +126,7 @@ jobs:
136126
path: |
137127
llvm-project
138128
${{ matrix.cling=='On' && 'cling' || '' }}
139-
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}-${{ matrix.root-llvm-tag || 'none' }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}${{ matrix.oop-jit == 'On' && '-oop' || '' }}${{ matrix.sanitizer || '' }}
129+
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}-${{ matrix.root-llvm-tag || 'none' }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}${{ matrix.sanitizer || '' }}
140130
- name: Setup default Build Type
141131
uses: ./.github/actions/Miscellaneous/Select_Default_Build_Type
142132

CMakeLists.txt

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,16 +339,52 @@ include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
339339
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
340340
add_definitions(${LLVM_DEFINITIONS_LIST})
341341

342-
string(REGEX REPLACE "/lib/cmake/llvm$" "" LLVM_BINARY_LIB_DIR "${LLVM_DIR}")
343-
add_definitions(-DLLVM_BINARY_LIB_DIR="${LLVM_BINARY_LIB_DIR}")
342+
# Bundle the ORC runtime + executor inside CppInterOp's distribution
343+
# so the OOP-JIT path is self-contained: no extra package to install,
344+
# no resource-dir scan in the host's clang tree at runtime. Paths are
345+
# baked at build time (CPPINTEROP_RUNTIME_{BUILD,INSTALL}_DIR in
346+
# Compatibility.h) and probed via fs::exists.
347+
set(CPPINTEROP_RUNTIME_SUBDIR "cppinterop-rt")
348+
set(CPPINTEROP_RUNTIME_BUILDTREE_DIR
349+
"${CMAKE_BINARY_DIR}/lib/${CPPINTEROP_RUNTIME_SUBDIR}")
350+
351+
if(LLVM_VERSION_MAJOR GREATER 21)
352+
find_package(LLVMOrcRuntime QUIET MODULE)
353+
endif()
344354

345-
if(LLVM_BUILT_WITH_OOP_JIT)
346-
if((CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") OR
347-
(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|aarch64|arm64"))
348-
add_definitions(-DLLVM_BUILT_WITH_OOP_JIT)
349-
else()
350-
message(FATAL_ERROR "LLVM_BUILT_WITH_OOP_JIT is only supported on MacOS arm64 or Linux (x86_64/aarch64). Build aborted.")
351-
endif()
355+
if(LLVMOrcRuntime_FOUND)
356+
message(STATUS "CppInterOp OOP-JIT runtime:")
357+
message(STATUS " orc_rt: ${LLVMOrcRuntime_LIBRARY}")
358+
message(STATUS " executor: ${LLVMOrcRuntime_EXECUTOR}")
359+
360+
file(MAKE_DIRECTORY "${CPPINTEROP_RUNTIME_BUILDTREE_DIR}")
361+
configure_file("${LLVMOrcRuntime_LIBRARY}"
362+
"${CPPINTEROP_RUNTIME_BUILDTREE_DIR}/liborc_rt.a"
363+
COPYONLY)
364+
configure_file("${LLVMOrcRuntime_EXECUTOR}"
365+
"${CPPINTEROP_RUNTIME_BUILDTREE_DIR}/llvm-jitlink-executor"
366+
COPYONLY)
367+
368+
install(FILES "${LLVMOrcRuntime_LIBRARY}"
369+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${CPPINTEROP_RUNTIME_SUBDIR}"
370+
RENAME liborc_rt.a)
371+
install(PROGRAMS "${LLVMOrcRuntime_EXECUTOR}"
372+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${CPPINTEROP_RUNTIME_SUBDIR}"
373+
RENAME llvm-jitlink-executor)
374+
375+
# Bake build-tree and install-tree runtime locations into the library
376+
# so it can locate the bundled parts at runtime without dladdr or any
377+
# platform-specific self-DSO discovery.
378+
add_definitions(
379+
"-DCPPINTEROP_RUNTIME_BUILD_DIR=\"${CPPINTEROP_RUNTIME_BUILDTREE_DIR}\""
380+
"-DCPPINTEROP_RUNTIME_INSTALL_DIR=\"${CMAKE_INSTALL_FULL_LIBDIR}/${CPPINTEROP_RUNTIME_SUBDIR}\"")
381+
elseif(LLVM_VERSION_MAJOR GREATER 21)
382+
message(STATUS
383+
"CppInterOp: OOP-JIT runtime (liborc_rt + llvm-jitlink-executor) "
384+
"not found in ${LLVM_LIBRARY_DIR}. Out-of-process JIT support will "
385+
"be unavailable. To enable it, build LLVM with compiler-rt and "
386+
"ninja the llvm-jitlink-executor + orc_rt* targets, or install a "
387+
"compiler-rt package that ships them.")
352388
endif()
353389

354390
# If the llvm sources are present add them with higher priority.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ cmake -DBUILD_SHARED_LIBS=ON -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_D
213213
cmake --build . --target install --parallel $(nproc --all)
214214
```
215215

216-
and
217-
218-
> Do make sure to pass ``DLLVM_BUILT_WITH_OOP_JIT=ON``, if you want to have out-of-process JIT execution feature enabled.
216+
> Out-of-process JIT auto-enables when CppInterOp is built against
217+
> LLVM 22+ with compiler-rt's ORC runtime available
218+
> (`liborc_rt*.a` and `llvm-jitlink-executor`). When detected, the
219+
> two artifacts are bundled under `<libdir>/cppinterop-rt/` so the
220+
> distribution is self-contained.
219221
220222
#### Testing CppInterOp
221223

cmake/FindLLVMOrcRuntime.cmake

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Locates the ORC runtime archive (compiler-rt's `orc_rt`) and the
2+
# `llvm-jitlink-executor` binary inside the LLVM tree we are linking
3+
# against. Used to bundle them into CppInterOp's distribution so the
4+
# OOP-JIT path works without an external `compiler-rt` install.
5+
#
6+
# Expects find_package(LLVM) to have run already (provides the input
7+
# variables below).
8+
#
9+
# Inputs:
10+
# LLVM_LIBRARY_DIR
11+
# LLVM_TOOLS_BINARY_DIR
12+
# LLVM_VERSION_MAJOR
13+
#
14+
# Output cache variables:
15+
# LLVMOrcRuntime_FOUND
16+
# LLVMOrcRuntime_LIBRARY Path to libclang_rt.orc_rt*.a / liborc_rt*.a
17+
# LLVMOrcRuntime_EXECUTOR Path to llvm-jitlink-executor
18+
19+
include(FindPackageHandleStandardArgs)
20+
21+
# compiler-rt installs into `clang/<ver>/lib/<triple>/`; the triple
22+
# subdir is host-derived (`darwin`, `x86_64-unknown-linux-gnu`, etc.).
23+
# Enumerate them at configure time rather than hard-coding the triple.
24+
file(GLOB _orc_hint_dirs LIST_DIRECTORIES TRUE
25+
"${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}/lib/*")
26+
27+
# NAMES covers the spread of compiler-rt archive names across versions
28+
# and platforms: `libclang_rt.orc_rt.a` (modern, per-triple subdir),
29+
# `liborc_rt.a` (legacy unsuffixed), and the arch/OS-suffixed variants
30+
# `_osx` (macOS universal), `-x86_64`, `-aarch64`. NO_DEFAULT_PATH so
31+
# we never pick up a system-installed orc_rt with a different ABI than
32+
# the LLVM we're linking against.
33+
find_library(LLVMOrcRuntime_LIBRARY
34+
NAMES
35+
clang_rt.orc_rt
36+
orc_rt
37+
orc_rt_osx
38+
orc_rt-x86_64
39+
orc_rt-aarch64
40+
HINTS ${_orc_hint_dirs}
41+
NO_DEFAULT_PATH)
42+
43+
find_program(LLVMOrcRuntime_EXECUTOR
44+
NAMES llvm-jitlink-executor
45+
HINTS "${LLVM_TOOLS_BINARY_DIR}"
46+
NO_DEFAULT_PATH)
47+
48+
find_package_handle_standard_args(LLVMOrcRuntime
49+
REQUIRED_VARS LLVMOrcRuntime_LIBRARY LLVMOrcRuntime_EXECUTOR)
50+
51+
mark_as_advanced(LLVMOrcRuntime_LIBRARY LLVMOrcRuntime_EXECUTOR)

docs/DevelopersDocumentation.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,11 @@ commands on Linux and MacOS
292292
293293
.. note::
294294

295-
Do make sure to pass ``DLLVM_BUILT_WITH_OOP_JIT=ON``, if you want to have out-of-process JIT execution feature enabled.
295+
Out-of-process JIT auto-enables when CppInterOp is built against
296+
LLVM 22+ with compiler-rt's ORC runtime available
297+
(``liborc_rt*.a`` and ``llvm-jitlink-executor``). When detected,
298+
the two artifacts are bundled under ``<libdir>/cppinterop-rt/`` so
299+
the distribution is self-contained.
296300

297301
and
298302

docs/InstallationAndUsage.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,11 @@ commands on Linux and MacOS
294294
295295
.. note::
296296

297-
Do make sure to pass ``DLLVM_BUILT_WITH_OOP_JIT=ON``, if you want to have out-of-process JIT execution feature enabled.
297+
Out-of-process JIT auto-enables when CppInterOp is built against
298+
LLVM 22+ with compiler-rt's ORC runtime available
299+
(``liborc_rt*.a`` and ``llvm-jitlink-executor``). When detected,
300+
the two artifacts are bundled under ``<libdir>/cppinterop-rt/`` so
301+
the distribution is self-contained.
298302

299303
and
300304

0 commit comments

Comments
 (0)