C++: Updates linking for cc_shared_library
Order of libraries should be topological sort when constructing depset for
LinkingContext.
Also remove condition that failed when it shouldn't with a valid combination of
libraries.
RELNOTES:none
PiperOrigin-RevId: 282943411
Change-Id: I0b727c4cdeaf484e1c4177a714542eae7f167613
diff --git a/examples/experimental_cc_shared_library.bzl b/examples/experimental_cc_shared_library.bzl
index 8c21896..4694653 100644
--- a/examples/experimental_cc_shared_library.bzl
+++ b/examples/experimental_cc_shared_library.bzl
@@ -49,7 +49,7 @@
linker_inputs.extend(static_linker_inputs)
return cc_common.create_linking_context(
- linker_inputs = depset(linker_inputs),
+ linker_inputs = depset(linker_inputs, order = "topological"),
)
def _merge_cc_shared_library_infos(ctx):
@@ -155,8 +155,6 @@
if not can_be_linked_statically:
fail("We can't link " +
str(owner) + " either statically or dynamically")
- else:
- fail("Implementation error, this should not happen")
# Every direct dynamic_dep of this rule will be linked dynamically even if we
# didn't reach a cc_library exported by one of these dynamic_deps. In other