Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow controlling whether the soname is set in cc_shared_library. #18798

Closed
oquenchil opened this issue Jun 28, 2023 · 2 comments
Closed

Allow controlling whether the soname is set in cc_shared_library. #18798

oquenchil opened this issue Jun 28, 2023 · 2 comments
Labels
help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-CPP Issues for C++ rules type: feature request

Comments

@oquenchil
Copy link
Contributor

oquenchil commented Jun 28, 2023

Add new toolchain feature to allow the soname to be added to cc_shared_libraries when the feature is enabled.

The following condition (https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java;drc=044a14cca2747aeff258fc71eaeb153c08cb34d5;l=687) should have:

|| (dynamicLinkType == LinkTargetType.DYNAMIC_LIBRARY && featureConfiguration.isEnabled("add_soname_to_transitive_shared_libraries")

The feature "add_soname_to_transitive_shared_libraries" doesn't exist yet and needs to be added to the default unix_cc_toolchain_config.bzl toolchain.

This is an incompatible change and projects would have to explicitly enable the feature for all their shared libraries or individual ones. This is an incompatible change because existing builds copy and rename the cc_shared_library library output, if the soname is set then whatever links against it will use the soname and the library won't be found at runtime.

A workaround is to pass the flag -Wl,-soname=libA.so via cc_shared_library.user_link_flags.

Originally posted by @Distancess in #18765 (reply in thread)

@oquenchil oquenchil added P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request team-Rules-CPP Issues for C++ rules help wanted Someone outside the Bazel team could own this labels Jun 28, 2023
keith added a commit to keith/bazel that referenced this issue Oct 1, 2024
This allows correctly setting the `soname` for shared libraries on
Linux. This is useful for similar reasons to the macOS
`set_install_name` feature.

Fixes bazelbuild#18798
@keith
Copy link
Member

keith commented Oct 1, 2024

#23839

keith added a commit to keith/bazel that referenced this issue Oct 3, 2024
This allows correctly setting the `soname` for shared libraries on
Linux. This is useful for similar reasons to the macOS
`set_install_name` feature.

Fixes bazelbuild#18798

Closes bazelbuild#23839.

PiperOrigin-RevId: 681847016
Change-Id: I2d3584c9d91564b41c2501e6664e2956f9760e41
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 7.4.0 RC1. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=7.4.0rc1. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-CPP Issues for C++ rules type: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants