Skip to content

fix(bundle): fix MakeBundle and RPATH issues on Linux#2148

Open
predat wants to merge 3 commits into
developfrom
fix/bundle-symlink
Open

fix(bundle): fix MakeBundle and RPATH issues on Linux#2148
predat wants to merge 3 commits into
developfrom
fix/bundle-symlink

Conversation

@predat

@predat predat commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Three bugs affecting the bundle target on Linux (Rocky/RHEL):

  • Stray libs in bin/: fixup_bundle may leave dangling symlinks (e.g. libAlembic.so.1.8) in bin/ because their targets remain in lib/. file(COPY) cannot duplicate dangling symlinks; replaced with file(RENAME) in a foreach loop.

  • lib64 -> lib symlink broken in bundle: on systems where CMAKE_INSTALL_LIBDIR resolves to lib64 (a symlink to lib), file(COPY) reproduced the symlink without copying its target, leaving a dangling lib64 -> lib in the bundle. Now detects IS_SYMLINK, copies the real directory, and recreates the symlink.

  • $ORIGIN RPATH written as \$ORIGIN: \\$ORIGIN in the CMake string produced a literal \$ORIGIN in the ELF RPATH, which the dynamic linker does not recognise as the executable-relative token. Changed to \$ORIGIN (single backslash) which produces the correct $ORIGIN in the binary.

Test plan

  • Build AliceVision with -DALICEVISION_BUILD_DEPENDENCIES=OFF against pre-built deps on a Rocky 9 / RHEL system
  • Run cmake --build . --target bundle and verify it completes without errors
  • Confirm readelf -d <bundle>/bin/aliceVision_* | grep RPATH shows $ORIGIN/../lib64:$ORIGIN
  • Confirm bundle/lib64 is a valid symlink pointing to an existing bundle/lib/
  • Run a bundled executable outside the install prefix to verify runtime linking

Sylvain Maziere added 3 commits June 26, 2026 08:37
fixup_bundle can drop a dangling symlink into bin/ (e.g. libAlembic.so.1.8
whose target stayed in lib/). The cleanup step then ran file(COPY) on it,
which fails with "cannot duplicate symlink ... No such file or directory"
and aborts `make bundle`.

Move each stray lib with file(RENAME) instead: it relocates the symlink
as-is (without dereferencing), so the link resolves again once in lib/.
Also fix the log line, which referenced the undefined CMAKE_LIST_LENGTH.
On systems where CMAKE_INSTALL_LIBDIR resolves to lib64 and lib64 is a
symlink to lib, file(COPY) was reproducing the symlink without its target,
leaving a dangling lib64 -> lib in the bundle. Detect IS_SYMLINK, copy the
real directory, then recreate the symlink so both names work in the bundle.
\\$ORIGIN in a CMake string produces a literal \$ORIGIN in the binary
RPATH, which the dynamic linker does not recognise. A single \$ is
sufficient to protect the $ from CMake variable expansion.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes the escaping of $ORIGIN in CMAKE_INSTALL_RPATH within src/CMakeLists.txt. Additionally, it updates src/cmake/MakeBundle.cmake to properly handle symlink directories by copying the real directory and recreating the symlink, and changes the moving of stray libraries from bin/ to lib/ to use file(RENAME) instead of file(COPY) to preserve symlinks. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant