Skip to content

Commit

Permalink
Fix interface_library-only libraries_to_link for cc_shared_library (b…
Browse files Browse the repository at this point in the history
…azelbuild#15046)

Take into account libraries_to_link which just contain an interface libary when building the runfiles of cc_shared_library. A library_to_link with only an interface library can come about in a cc_import rule for example where one can set system_provided=True

PiperOrigin-RevId: 434705871
  • Loading branch information
oquenchil authored Mar 15, 2022
1 parent 6cd6a27 commit 91a580a
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ def _build_link_once_static_libs_map(merged_shared_library_infos):
return link_once_static_libs_map

def _is_dynamic_only(library_to_link):
if library_to_link.static_library == None and library_to_link.pic_static_library == None:
if (library_to_link.static_library == None and
library_to_link.pic_static_library == None and
(library_to_link.objects == None or len(library_to_link.objects) == 0) and
(library_to_link.pic_objects == None or len(library_to_link.pic_objects) == 0)):
return True
return False

Expand Down Expand Up @@ -503,7 +506,10 @@ def _cc_shared_library_impl(ctx):

precompiled_only_dynamic_libraries_runfiles = []
for precompiled_dynamic_library in precompiled_only_dynamic_libraries:
precompiled_only_dynamic_libraries_runfiles.append(precompiled_dynamic_library.dynamic_library)
# precompiled_dynamic_library.dynamic_library could be None if the library to link just contains
# an interface library which is valid if the actual library is obtained from the system.
if precompiled_dynamic_library.dynamic_library != None:
precompiled_only_dynamic_libraries_runfiles.append(precompiled_dynamic_library.dynamic_library)
if precompiled_dynamic_library.resolved_symlink_dynamic_library != None:
precompiled_only_dynamic_libraries_runfiles.append(precompiled_dynamic_library.resolved_symlink_dynamic_library)

Expand Down

0 comments on commit 91a580a

Please sign in to comment.