diff --git a/examples/experimental_cc_shared_library.bzl b/examples/experimental_cc_shared_library.bzl index acda49f..608f4c6 100644 --- a/examples/experimental_cc_shared_library.bzl +++ b/examples/experimental_cc_shared_library.bzl @@ -109,7 +109,7 @@ def _build_exports_map_from_only_dynamic_deps(merged_shared_library_infos): if export in exports_map: fail("Two shared libraries in dependencies export the same symbols. Both " + exports_map[export].libraries[0].dynamic_library.short_path + - " and " + linker_input.dynamic_library.short_path + + " and " + linker_input.libraries[0].dynamic_library.short_path + " export " + export) exports_map[export] = linker_input return exports_map diff --git a/examples/test_cc_shared_library/BUILD b/examples/test_cc_shared_library/BUILD index 9c3acda..16ce79e 100644 --- a/examples/test_cc_shared_library/BUILD +++ b/examples/test_cc_shared_library/BUILD @@ -21,6 +21,16 @@ cc_binary( deps = ["foo"], ) +cc_binary( + name = "binary_with_bar_so_twice", + srcs = ["main.cc"], + dynamic_deps = [ + "foo_so", + "bar_so", + ], + deps = ["foo"], +) + cc_shared_library( name = "foo_so", additional_linker_inputs = [ @@ -212,3 +222,15 @@ cc_shared_library_permissions( ], visibility = ["//examples/test_cc_shared_library/diamond_inheritance:__pkg__"], ) + +build_failure_test( + name = "two_dynamic_deps_same_export_in_so_test", + message = "Two shared libraries in dependencies export the same symbols", + target_under_test = "//examples/test_cc_shared_library/failing_targets:two_dynamic_deps_same_export_in_so", +) + +build_failure_test( + name = "two_dynamic_deps_same_export_in_binary_test", + message = "Two shared libraries in dependencies export the same symbols", + target_under_test = "//examples/test_cc_shared_library/failing_targets:two_dynamic_deps_same_export_in_binary", +) diff --git a/examples/test_cc_shared_library/failing_targets/BUILD b/examples/test_cc_shared_library/failing_targets/BUILD index 16e4b47..f0bf796 100644 --- a/examples/test_cc_shared_library/failing_targets/BUILD +++ b/examples/test_cc_shared_library/failing_targets/BUILD @@ -1,4 +1,4 @@ -load("//cc:defs.bzl", "cc_binary") +load("//cc:defs.bzl", "cc_binary", "cc_library") load("//examples:experimental_cc_shared_library.bzl", "cc_shared_library", "cc_shared_library_permissions") package( @@ -35,3 +35,56 @@ cc_shared_library_permissions( "//examples/test_cc_shared_library:foo", ], ) + +cc_library( + name = "a", + srcs = ["a.cc"], +) + +cc_library( + name = "b", + srcs = ["b.cc"], +) + +cc_library( + name = "c", + srcs = ["c.cc"], +) + +cc_shared_library( + name = "two_dynamic_deps_same_export_in_so", + dynamic_deps = [ + ":b_so", + ":b2_so", + ], + roots = [ + ":a", + ], + tags = TAGS, +) + +cc_binary( + name = "two_dynamic_deps_same_export_in_binary", + srcs = ["main.cc"], + dynamic_deps = [ + ":b_so", + ":b2_so", + ], + tags = TAGS, +) + +cc_shared_library( + name = "b_so", + roots = [ + ":b", + ], + tags = TAGS, +) + +cc_shared_library( + name = "b2_so", + roots = [ + ":b", + ], + tags = TAGS, +) diff --git a/examples/test_cc_shared_library/failing_targets/a.cc b/examples/test_cc_shared_library/failing_targets/a.cc new file mode 100644 index 0000000..e69de29 diff --git a/examples/test_cc_shared_library/failing_targets/b.cc b/examples/test_cc_shared_library/failing_targets/b.cc new file mode 100644 index 0000000..e69de29 diff --git a/examples/test_cc_shared_library/failing_targets/c.cc b/examples/test_cc_shared_library/failing_targets/c.cc new file mode 100644 index 0000000..e69de29 diff --git a/examples/test_cc_shared_library/failing_targets/main.cc b/examples/test_cc_shared_library/failing_targets/main.cc new file mode 100644 index 0000000..e69de29