Skip to content

Conversation

@franramirez688
Copy link
Contributor

@franramirez688 franramirez688 commented Nov 3, 2025

Changelog: Fix: [BazelDeps] Adding RPATH flag in linkopts field for dynamic builds and UNIX systems.
Docs: omit
Closes: #19135
Closes: #19190

Rationale

For instance, the csm library creates these binaries:

.
├── libcsmapi.3.0.4.dylib
├── libcsmapi.3.dylib -> libcsmapi.3.0.4.dylib
└── libcsmapi.dylib -> libcsmapi.3.dylib

And the csm/BUILD.bazel file has this:

shared_library = "lib/libcsmapi.dylib"

Any application linking with that will show this:

$ otool -L bazel-bin/main/demo
bazel-bin/main/demo:
    @rpath/libcsmapi.3.dylib (compatibility version 3.0.0, current version 3.0.4)

It points to the symlink, but Bazel only copies the matched library into its own cache (libcsmapi.dylib). Adding the rpath flag, we solve that problem.

@franramirez688 franramirez688 marked this pull request as ready for review November 4, 2025 15:08
# Issue: https://github.com/conan-io/conan/issues/19135
# (UNIX) Adding the rpath flag as any application could link through the library
# which points out a symlink, but that name does not appear in the library location
info["linkopts"] = [f'"-Wl,-rpath,{cpp_info.libdirs[0]}"']
Copy link
Member

Choose a reason for hiding this comment

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

I didn't know that -rpath link flag could be used for this symlink purpose, so far I thought it was mostly for transitive shared libs linkage.
So probably I don't know enough to validate if this is ok and safe, or it could have some issues.

Otherwise, looks good to me!

@franramirez688 franramirez688 requested a review from jcar87 November 4, 2025 16:03
@czoido czoido merged commit cc6dae1 into conan-io:develop2 Nov 25, 2025
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants