Commit fc2e662
authored
[jit] Add a layered probe chain for relocatable OOP runtime discovery. (#942)
* [jit] Add a layered probe chain for relocatable OOP runtime discovery.
The bake-at-build-time install path from `[jit] Self-contain the
OOP-JIT runtime in CppInterOp's distribution.` is fragile under
relocation: an installed CppInterOp moved to a different prefix
(rpm `--prefix`, conda relocation, AppImage) can't find the runtime
parts because the macro holds the original
`CMAKE_INSTALL_FULL_LIBDIR`.
`configureBundledOOPRuntime` now probes a layered list, most-reliable
first, before falling back to the baked path:
1. `$CPPINTEROP_RUNTIME_DIR` -- sysadmin override; trumps every
other source so packagers can point CppInterOp at a runtime
extracted to a separate location.
2. `<dir of libclangCppInterOp>/cppinterop-rt` -- self-DSO discovery
via `dladdr` (POSIX). Works for any non-static link: if the
`.so` moves, the runtime moves with it, no env-var needed.
3. `CPPINTEROP_RUNTIME_BUILD_DIR` -- in-tree test runs.
4. `CPPINTEROP_RUNTIME_INSTALL_DIR` -- baked install path; last
resort when self-DSO discovery isn't available (Windows, or
CppInterOp statically linked into a host binary).
Windows has no self-DSO discovery yet -- a `GetModuleHandleEx` port
can be added when Windows OOP support arrives. The clang resource
directory (`CLANG_RESOURCE_DIR`) suffers the same
bake-at-build-time-vs-relocation problem and would benefit from the
same layering; left as follow-up.
* [ci] Verify the OOP runtime probe chain via relocation + env-var.
The layered probe chain in `configureBundledOOPRuntime` from
`[jit] Add a layered probe chain for relocatable OOP runtime
discovery.` adds two new lookup layers (`CPPINTEROP_RUNTIME_DIR`
env-var override and `dladdr`-based self-DSO probe) that the
existing in-tree test path doesn't exercise -- in-tree the baked
`CPPINTEROP_RUNTIME_BUILD_DIR` probe wins first, so a regression
in either new layer would be silent.
After the install-layout assertion succeeds, move the install to
a fresh prefix and re-run the OOP-tagged tests with
`DYLD_LIBRARY_PATH`/`LD_LIBRARY_PATH` pointing at the moved tree:
the `dladdr` probe must follow the relocated `.so` and find the
runtime alongside it. Then stage the runtime parts at a third
location, wipe the moved `cppinterop-rt/` subdir, and re-run with
`CPPINTEROP_RUNTIME_DIR` set to the staged copy: only the env-var
probe can win.
Both runs assert that the
`[CreateClangInterpreter]: --use-oop-jit requested but the bundled
OOP runtime ... is missing` fallback warning does NOT appear in
the test output. Negative-control verified locally -- with all
probe locations wiped the warning does fire, confirming the
assertion isn't dead.
Filter is `CppInterOpTest/OutOfProcessJIT.Jit_StreamRedirectJIT`,
the only OOP-tagged test that calls `CreateInterpreter()` before
its skip check; the test itself fails with a preexisting
`stdio.h not found` issue in the OOP child interpreter, which is
orthogonal to the probe chain and doesn't trip the bundling
warning.
* [test] Skip OOP+sanitizer-incompatible reflection tests.
The asan-ubsan CI row started exercising the OOP-JIT path after
`[ci] Build the bundled OOP-JIT runtime in non-cling LLVM>=22
caches.` (#940) made OOP run by default for every llvm22+ row.
Two tests then trip the assertion at
`llvm/lib/ExecutionEngine/Orc/Core.cpp:2800`:
Resolving symbol with incorrect flags
ASan instruments globals with extra metadata that changes the
`JITSymbolFlags` declared in the host process; when the EPC-based
out-of-process executor reports back the resolved flags, they
don't match. The in-process JIT path doesn't compare across an
IPC boundary so it's unaffected, and other OOP tests don't define
the kinds of common symbols that hit the resolution path.
Skip the failing tests under OOP-when-sanitized rather than
disabling the OOP fixture wholesale -- the remaining OOP tests on
the asan-ubsan row keep running:
- `EnumReflection_GetEnums`
- `FunctionReflection_InstantiateTemplateFunctionFromString`
Likely upstream LLVM bug; can be removed once the EPC symbol-flag
tracking is fixed.1 parent 2626ddd commit fc2e662
4 files changed
Lines changed: 108 additions & 12 deletions
File tree
- .github/actions/Build_and_Test_CppInterOp
- lib/CppInterOp
- unittests/CppInterOp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
103 | 138 | | |
104 | 139 | | |
105 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
248 | 249 | | |
249 | 250 | | |
250 | 251 | | |
| |||
371 | 372 | | |
372 | 373 | | |
373 | 374 | | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
380 | 404 | | |
381 | 405 | | |
382 | 406 | | |
383 | 407 | | |
384 | 408 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
390 | 424 | | |
391 | 425 | | |
392 | 426 | | |
| |||
400 | 434 | | |
401 | 435 | | |
402 | 436 | | |
403 | | - | |
404 | 437 | | |
405 | 438 | | |
406 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
257 | 271 | | |
258 | 272 | | |
259 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
705 | 719 | | |
706 | 720 | | |
707 | 721 | | |
| |||
0 commit comments