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

Add versioned soname support to interface_library #16100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

m3rcuriel
Copy link
Contributor

@m3rcuriel m3rcuriel commented Aug 14, 2022

There doesn't seem to be a compelling reason to not support this, and there's no other way (it seems) to allow one to provide a shim (with a versioned filename) that won't end up in the runfiles tree.

This mostly consists of adding the VERSIONED_SHARED_LIBRARY support through to the interface_library and has the practical effect of allowing .dylib.VERSION and .so.VERSION for that field. I don't know enough about soname/versioning/Windows to claim confidently that these are the only two extensions one would put versions on but it's all I've ever seen and matches shared_library.

Probably fixes #7059

@m3rcuriel m3rcuriel marked this pull request as draft August 14, 2022 10:49
@m3rcuriel m3rcuriel force-pushed the add-versioned-soname-to-interface-library branch 3 times, most recently from 8e9315e to 52387b5 Compare August 14, 2022 20:25
@m3rcuriel m3rcuriel marked this pull request as ready for review August 15, 2022 16:48
@m3rcuriel m3rcuriel marked this pull request as draft August 15, 2022 16:49
@m3rcuriel m3rcuriel force-pushed the add-versioned-soname-to-interface-library branch from 52387b5 to c0ca3db Compare August 15, 2022 16:59
@m3rcuriel m3rcuriel marked this pull request as ready for review August 15, 2022 17:00
@sgowroji sgowroji added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Aug 16, 2022
@oquenchil oquenchil requested review from buildbreaker2021 and removed request for lberki and oquenchil August 17, 2022 12:43
@@ -57,6 +57,10 @@ def _perform_error_checks(
not cc_helper.is_shared_library_extension_valid(shared_library_artifact.basename)):
fail("'shared_library' does not produce any cc_import shared_library files (expected .so, .dylib or .dll)")

if (interface_library_artifact != None and
not cc_helper.is_interface_library_extension_valid(interface_library_artifact.basename)):
fail("'interface_library' does not produce any cc_import interface_library files (expected .ifso, .tbd, .dll.a, .dylib, .so, or .lib)")
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comma before "or" for consistency.

@@ -532,6 +532,9 @@ def _is_versioned_shared_library_extension_valid(shared_library_name):
return True
return False

def _is_versioned_shared_library_extension_valid(shared_library_name):
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding this, could we rename _is_versioned_shared_library_extension_valid to _is_versioned_library_extension_valid and do a minor refactoring in cc_helper.bzl? _is_versioned_shared_library_extension_valid is private and not exported so it should just touch one file.

@buildbreaker2021 buildbreaker2021 added awaiting-user-response Awaiting a response from the author and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jan 27, 2023
@m3rcuriel m3rcuriel force-pushed the add-versioned-soname-to-interface-library branch from 2825199 to af98999 Compare January 29, 2023 20:46
@buildbreaker2021 buildbreaker2021 added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-user-response Awaiting a response from the author labels Jan 30, 2023
@sgowroji
Copy link
Member

Hello @m3rcuriel, Could you please fix the buildkite errors. Above PR is awaiting to merge. Thanks!

@sgowroji sgowroji added awaiting-user-response Awaiting a response from the author and removed awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally labels Feb 10, 2023
@malt3
Copy link
Contributor

malt3 commented Jul 5, 2023

Does this allow linking two versions of the same library?

I'm seeing this issue when doing so:

        File "/virtual_builtins_bzl/common/cc/cc_library.bzl", line 188, column 78, in _cc_library_impl
        File "/virtual_builtins_bzl/common/cc/cc_library.bzl", line 370, column 58, in _convert_precompiled_libraries_to_library_to_link
        File "/virtual_builtins_bzl/common/cc/cc_library.bzl", line 453, column 17, in _build_map_identifier_to_artifact
Error in fail: attribute srcs: Trying to link twice a library with the same identifier 'rpm/libvirt-libs/libunistring.so',files: rpm/libvirt-libs/libunistring.so.5 and rpm/libvirt-libs/libunistring.so.2

The same example can be linked successfully outside of Bazel.

@sgowroji
Copy link
Member

Hi @m3rcuriel, Could you provide an update on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting a response from the author team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] Support cc_import of .so with soname
4 participants