Skip to content

Commit f8707c0

Browse files
oquenchilcopybara-github
authored andcommitted
Account for interface libraries in cc_shared_library
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 RELNOTES:none PiperOrigin-RevId: 434705871
1 parent 8d22e46 commit f8707c0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl

+8-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ def _build_link_once_static_libs_map(merged_shared_library_infos):
147147
return link_once_static_libs_map
148148

149149
def _is_dynamic_only(library_to_link):
150-
if library_to_link.static_library == None and library_to_link.pic_static_library == None:
150+
if (library_to_link.static_library == None and
151+
library_to_link.pic_static_library == None and
152+
(library_to_link.objects == None or len(library_to_link.objects) == 0) and
153+
(library_to_link.pic_objects == None or len(library_to_link.pic_objects) == 0)):
151154
return True
152155
return False
153156

@@ -501,7 +504,10 @@ def _cc_shared_library_impl(ctx):
501504

502505
precompiled_only_dynamic_libraries_runfiles = []
503506
for precompiled_dynamic_library in precompiled_only_dynamic_libraries:
504-
precompiled_only_dynamic_libraries_runfiles.append(precompiled_dynamic_library.dynamic_library)
507+
# precompiled_dynamic_library.dynamic_library could be None if the library to link just contains
508+
# an interface library which is valid if the actual library is obtained from the system.
509+
if precompiled_dynamic_library.dynamic_library != None:
510+
precompiled_only_dynamic_libraries_runfiles.append(precompiled_dynamic_library.dynamic_library)
505511
if precompiled_dynamic_library.resolved_symlink_dynamic_library != None:
506512
precompiled_only_dynamic_libraries_runfiles.append(precompiled_dynamic_library.resolved_symlink_dynamic_library)
507513

0 commit comments

Comments
 (0)