Keep build-machine paths out of the Linux RUNPATH - #53
Conversation
CMakeLists already asked for $ORIGIN, but CMake prepends it to the automatic build-tree RPATH rather than replacing it: because the target links libCr_Core and the OpenCV libs by absolute path, their source-tree directories were appended and shipped inside the binary. Those entries were pure redundancy — POST_BUILD already copies every runtime lib next to the executable, so $ORIGIN alone resolves everything. Their only real effect was to let the loader fall back to the build machine's checkout, which is how the missing OpenCV in the .mcpb (#33) stayed invisible: the bundle tested fine on the machine that built it and failed with exit 127 everywhere else. BUILD_WITH_INSTALL_RPATH makes the build-tree link use INSTALL_RPATH directly and skips the automatic computation, leaving RUNPATH as just $ORIGIN. macOS is left alone — it likely has the same leak, but there is no hardware here to verify it and the CrAdapter layout there is delicate. Fixes #52 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Re-land: keep build-machine paths out of the Linux RUNPATH (#53 never reached main)
|
Heads-up: this PR is marked MERGED, but its change never reached It was opened with My error: I checked Re-landed in #55 as a clean Worth being aware of the general shape: a stacked PR whose base gets merged first ends up MERGED with its change nowhere, and nothing in the UI flags it. |
Fixes #52. Stacked on #51 — base is
fix/linux-opencv-mcpb-bundling, so this diff is just the CMake change. Retarget tomainonce #51 merges.The bug
api/server/CMakeLists.txtalready asked for$ORIGIN, but CMake prepends it to the automatic build-tree RPATH instead of replacing it. Because the target linkslibCr_Core.soand the OpenCV libs by absolute path, their source-tree directories were appended — and shipped inside the binary, into the.mcpb:Those entries were pure redundancy:
POST_BUILD(lines 153-163) already copies every runtime lib next to the executable, so$ORIGINalone resolves everything in both the build tree and the bundle.Their only real effect was harmful — they let the loader fall back to the build machine's checkout. That is exactly how #33 hid: the bundle shipped with no OpenCV at all, tested fine on the machine that built it, and failed with exit 127 everywhere else.
The change
BUILD_WITH_INSTALL_RPATHmakes the build-tree link useINSTALL_RPATHdirectly and skips the automatic computation, leavingRUNPATHas just$ORIGIN.macOS deliberately untouched. It likely has the same leak —
BUILD_RPATH "@executable_path"gets the same augmentation and noINSTALL_RPATHis set — but there is no macOS hardware here to verify, and the CrAdapter layout there is delicate after 4e1927a. Noted in #52 as follow-up.Test plan
linux-arm64 (Raspberry Pi), CMake 3.28.3, SDK V2.02.00.
RUNPATHis now[$ORIGIN]— absolute paths goneapi/server/build/CameraWebAppresolves everything frombuild/, 0 unresolved.mcpbshows[$ORIGIN]and 0 unresolved with no path rewriting needed (previously this required faking a clean machine)exit 127on the build machine. Before this change the same test silently succeeded by falling back to the source tree. This is the regression guard that would have caught Linux: OpenCV never bundled into .mcpb — opencvLibDir() paths cannot match what extract.ts writes #33 immediately.1024x680→ OSD composite640x480rendered correctly with full camera UI/proc/<pid>/mapsconfirms all three OpenCV libs mapped from the bundle, 0 libs resolved from the source treeTested on a different body (ILCE-1M2) than #51 (ILCE-7M5), so the pair covers two models.
Note:
terminate called without an active exceptionat shutdown is pre-existing #42, unrelated.